let infcx = selcx.infcx();
infcx.commit_if_ok(|_snapshot| {
let placeholder_predicate =
- infcx.replace_bound_vars_with_placeholders(&obligation.predicate);
+ infcx.replace_bound_vars_with_placeholders(obligation.predicate);
let placeholder_obligation = obligation.with(placeholder_predicate);
let result = project_and_unify_type(selcx, &placeholder_obligation)?;
selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
- value: &T,
+ value: T,
) -> Normalized<'tcx, T>
where
T: TypeFoldable<'tcx>,
selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
- value: &T,
+ value: T,
obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> T
where
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
- value: &T,
+ value: T,
) -> Normalized<'tcx, T>
where
T: TypeFoldable<'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize,
- value: &T,
+ value: T,
obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> T
where
AssocTypeNormalizer { selcx, param_env, cause, obligations, depth }
}
- fn fold<T: TypeFoldable<'tcx>>(&mut self, value: &T) -> T {
+ fn fold<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
let value = self.selcx.infcx().resolve_vars_if_possible(value);
if !value.has_projections() { value } else { value.fold_with(self) }
}
}
- ty::Projection(ref data) if !data.has_escaping_bound_vars() => {
+ ty::Projection(data) if !data.has_escaping_bound_vars() => {
// This is kind of hacky -- we need to be able to
// handle normalization within binders because
// otherwise we wind up a need to normalize when doing
let normalized_ty = normalize_projection_type(
self.selcx,
self.param_env,
- *data,
+ data,
self.cause.clone(),
self.depth,
&mut self.obligations,
) -> Result<Option<Ty<'tcx>>, InProgress> {
let infcx = selcx.infcx();
- let projection_ty = infcx.resolve_vars_if_possible(&projection_ty);
+ let projection_ty = infcx.resolve_vars_if_possible(projection_ty);
let cache_key = ProjectionCacheKey::new(projection_ty);
// FIXME(#20304) For now, I am caching here, which is good, but it
depth + 1,
&mut projected_obligations,
);
- let normalized_ty = normalizer.fold(&projected_ty);
+ let normalized_ty = normalizer.fold(projected_ty);
debug!(?normalized_ty, ?depth);
if !selcx.tcx().sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
debug!("project: overflow!");
- match selcx.query_mode() {
- super::TraitQueryMode::Standard => {
- selcx.infcx().report_overflow_error(&obligation, true);
- }
- super::TraitQueryMode::Canonical => {
- return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
- }
- }
+ // This should really be an immediate error, but some existing code
+ // relies on being able to recover from this.
+ return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
}
let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());
// If we are resolving `<T as TraitRef<...>>::Item == Type`,
// start out by selecting the predicate `T as TraitRef<...>`:
- let poly_trait_ref = obligation_trait_ref.to_poly_trait_ref();
+ let poly_trait_ref = ty::Binder::dummy(*obligation_trait_ref);
let trait_obligation = obligation.with(poly_trait_ref.to_poly_trait_predicate());
let _ = selcx.infcx().commit_if_ok(|_| {
let impl_source = match selcx.select(&trait_obligation) {
// type.
//
// NOTE: This should be kept in sync with the similar code in
- // `rustc_ty::instance::resolve_associated_item()`.
+ // `rustc_ty_utils::instance::resolve_associated_item()`.
let node_item =
assoc_ty_def(selcx, impl_data.impl_def_id, obligation.predicate.item_def_id)
.map_err(|ErrorReported| ())?;
if obligation.param_env.reveal() == Reveal::All {
// NOTE(eddyb) inference variables can resolve to parameters, so
// assume `poly_trait_ref` isn't monomorphic, if it contains any.
- let poly_trait_ref =
- selcx.infcx().resolve_vars_if_possible(&poly_trait_ref);
+ let poly_trait_ref = selcx.infcx().resolve_vars_if_possible(poly_trait_ref);
!poly_trait_ref.still_further_specializable()
} else {
debug!(
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- &gen_sig,
+ gen_sig,
);
debug!(?obligation, ?gen_sig, ?obligations, "confirm_generator_candidate");
ty: self_ty.discriminant_ty(tcx),
};
- confirm_param_env_candidate(selcx, obligation, ty::Binder::bind(predicate), false)
+ // We get here from `poly_project_and_unify_type` which replaces bound vars
+ // with placeholders, so dummy is okay here.
+ confirm_param_env_candidate(selcx, obligation, ty::Binder::dummy(predicate), false)
}
fn confirm_fn_pointer_candidate<'cx, 'tcx>(
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- &sig,
+ sig,
);
confirm_callable_candidate(selcx, obligation, sig, util::TupleArgumentsFlag::Yes)
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- &closure_sig,
+ closure_sig,
);
debug!(?obligation, ?closure_sig, ?obligations, "confirm_closure_candidate");
let (cache_entry, _) = infcx.replace_bound_vars_with_fresh_vars(
cause.span,
LateBoundRegionConversionTime::HigherRankedType,
- &poly_cache_entry,
+ poly_cache_entry,
);
let cache_trait_ref = cache_entry.projection_ty.trait_ref(infcx.tcx);
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- &cache_trait_ref,
+ cache_trait_ref,
&mut nested_obligations,
)
})
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- &predicate,
+ predicate,
nested,
);
nested.push(Obligation::with_depth(
// from a specific call to `opt_normalize_projection_type` - if
// there's no precise match, the original cache entry is "stranded"
// anyway.
- infcx.resolve_vars_if_possible(&predicate.projection_ty),
+ infcx.resolve_vars_if_possible(predicate.projection_ty),
)
})
}