compiler: fold by value
This commit is contained in:
parent
3ec6720bf1
commit
2bf93bd852
140 changed files with 679 additions and 699 deletions
|
@ -229,7 +229,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
param_env: obligation.param_env,
|
||||
cause: obligation.cause.clone(),
|
||||
recursion_depth: obligation.recursion_depth,
|
||||
predicate: self.infcx().resolve_vars_if_possible(&obligation.predicate),
|
||||
predicate: self.infcx().resolve_vars_if_possible(obligation.predicate),
|
||||
};
|
||||
|
||||
if obligation.predicate.skip_binder().self_ty().is_ty_var() {
|
||||
|
@ -604,7 +604,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// The code below doesn't care about regions, and the
|
||||
// self-ty here doesn't escape this probe, so just erase
|
||||
// any LBR.
|
||||
let self_ty = self.tcx().erase_late_bound_regions(&obligation.self_ty());
|
||||
let self_ty = self.tcx().erase_late_bound_regions(obligation.self_ty());
|
||||
let poly_trait_ref = match self_ty.kind() {
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
|
||||
|
@ -639,9 +639,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
debug!(?poly_trait_ref, "assemble_candidates_from_object_ty");
|
||||
|
||||
let poly_trait_predicate = self.infcx().resolve_vars_if_possible(&obligation.predicate);
|
||||
let poly_trait_predicate = self.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||
let placeholder_trait_predicate =
|
||||
self.infcx().replace_bound_vars_with_placeholders(&poly_trait_predicate);
|
||||
self.infcx().replace_bound_vars_with_placeholders(poly_trait_predicate);
|
||||
|
||||
// Count only those upcast versions that match the trait-ref
|
||||
// we are looking for. Specifically, do not only check for the
|
||||
|
|
|
@ -126,7 +126,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let trait_predicate = self.infcx.shallow_resolve(obligation.predicate);
|
||||
let placeholder_trait_predicate =
|
||||
self.infcx().replace_bound_vars_with_placeholders(&trait_predicate);
|
||||
self.infcx().replace_bound_vars_with_placeholders(trait_predicate);
|
||||
let placeholder_self_ty = placeholder_trait_predicate.self_ty();
|
||||
let (def_id, substs) = match *placeholder_self_ty.kind() {
|
||||
ty::Projection(proj) => (proj.item_def_id, proj.substs),
|
||||
|
@ -144,7 +144,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&candidate,
|
||||
candidate,
|
||||
&mut obligations,
|
||||
);
|
||||
|
||||
|
@ -163,7 +163,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&predicate,
|
||||
predicate,
|
||||
&mut obligations,
|
||||
);
|
||||
obligations.push(Obligation::with_depth(
|
||||
|
@ -285,8 +285,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let trait_obligations: Vec<PredicateObligation<'_>> =
|
||||
self.infcx.commit_unconditionally(|_| {
|
||||
let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
|
||||
let trait_ref =
|
||||
self.infcx.replace_bound_vars_with_placeholders(&poly_trait_ref);
|
||||
let trait_ref = self.infcx.replace_bound_vars_with_placeholders(poly_trait_ref);
|
||||
let cause = obligation.derived_cause(ImplDerivedObligation);
|
||||
self.impl_or_trait_obligations(
|
||||
cause,
|
||||
|
@ -370,11 +369,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let tcx = self.tcx();
|
||||
debug!(?obligation, ?index, "confirm_object_candidate");
|
||||
|
||||
let trait_predicate =
|
||||
self.infcx.replace_bound_vars_with_placeholders(&obligation.predicate);
|
||||
let trait_predicate = self.infcx.replace_bound_vars_with_placeholders(obligation.predicate);
|
||||
let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty());
|
||||
let obligation_trait_ref = ty::Binder::dummy(trait_predicate.trait_ref);
|
||||
let data = match self_ty.kind() {
|
||||
let data = match *self_ty.kind() {
|
||||
ty::Dynamic(data, ..) => {
|
||||
self.infcx
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
|
@ -416,7 +414,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&unnormalized_upcast_trait_ref,
|
||||
unnormalized_upcast_trait_ref,
|
||||
&mut nested,
|
||||
);
|
||||
|
||||
|
@ -442,7 +440,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&super_trait,
|
||||
super_trait,
|
||||
&mut nested,
|
||||
);
|
||||
nested.push(Obligation::new(
|
||||
|
@ -480,7 +478,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&subst_bound,
|
||||
subst_bound,
|
||||
&mut nested,
|
||||
);
|
||||
nested.push(Obligation::new(
|
||||
|
@ -520,7 +518,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&trait_ref,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -541,8 +539,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
debug!(?obligation, ?alias_def_id, "confirm_trait_alias_candidate");
|
||||
|
||||
self.infcx.commit_unconditionally(|_| {
|
||||
let predicate =
|
||||
self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate);
|
||||
let predicate = self.infcx().replace_bound_vars_with_placeholders(obligation.predicate);
|
||||
let trait_ref = predicate.trait_ref;
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
let substs = trait_ref.substs;
|
||||
|
@ -584,7 +581,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&trait_ref,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -627,7 +624,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&trait_ref,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
|
|
|
@ -1019,7 +1019,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
let obligation = &stack.obligation;
|
||||
let predicate = self.infcx().resolve_vars_if_possible(&obligation.predicate);
|
||||
let predicate = self.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||
|
||||
// Okay to skip binder because of the nature of the
|
||||
// trait-ref-is-knowable check, which does not care about
|
||||
|
@ -1138,9 +1138,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
) -> smallvec::SmallVec<[usize; 2]> {
|
||||
let poly_trait_predicate = self.infcx().resolve_vars_if_possible(&obligation.predicate);
|
||||
let poly_trait_predicate = self.infcx().resolve_vars_if_possible(obligation.predicate);
|
||||
let placeholder_trait_predicate =
|
||||
self.infcx().replace_bound_vars_with_placeholders(&poly_trait_predicate);
|
||||
self.infcx().replace_bound_vars_with_placeholders(poly_trait_predicate);
|
||||
debug!(
|
||||
?placeholder_trait_predicate,
|
||||
"match_projection_obligation_against_definition_bounds"
|
||||
|
@ -1220,7 +1220,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&trait_bound,
|
||||
trait_bound,
|
||||
)
|
||||
});
|
||||
self.infcx
|
||||
|
@ -1266,12 +1266,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&data.map_bound_ref(|data| data.projection_ty),
|
||||
data.map_bound(|data| data.projection_ty),
|
||||
&mut nested_obligations,
|
||||
)
|
||||
})
|
||||
} else {
|
||||
data.map_bound_ref(|data| data.projection_ty)
|
||||
data.map_bound(|data| data.projection_ty)
|
||||
};
|
||||
|
||||
// FIXME(generic_associated_types): Compare the whole projections
|
||||
|
@ -1737,7 +1737,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/
|
||||
|
||||
self.infcx.commit_unconditionally(|_| {
|
||||
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(&ty);
|
||||
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
|
||||
let Normalized { value: normalized_ty, mut obligations } =
|
||||
ensure_sufficient_stack(|| {
|
||||
project::normalize_with_depth(
|
||||
|
@ -1745,7 +1745,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
param_env,
|
||||
cause.clone(),
|
||||
recursion_depth,
|
||||
&placeholder_ty,
|
||||
placeholder_ty,
|
||||
)
|
||||
});
|
||||
let placeholder_obligation = predicate_for_trait_def(
|
||||
|
@ -1807,7 +1807,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
let placeholder_obligation =
|
||||
self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate);
|
||||
self.infcx().replace_bound_vars_with_placeholders(obligation.predicate);
|
||||
let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;
|
||||
|
||||
let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span, impl_def_id);
|
||||
|
@ -1821,7 +1821,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
&impl_trait_ref,
|
||||
impl_trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -2028,7 +2028,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
param_env,
|
||||
cause.clone(),
|
||||
recursion_depth,
|
||||
&predicate.subst(tcx, substs),
|
||||
predicate.subst(tcx, substs),
|
||||
&mut obligations,
|
||||
);
|
||||
obligations.push(Obligation {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue