cause,
recursion_depth: 0,
param_env,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(infcx.tcx),
},
);
}
tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Elaborator<'tcx> {
- elaborate_predicates(tcx, std::iter::once(trait_ref.without_const().to_predicate()))
+ elaborate_predicates(tcx, std::iter::once(trait_ref.without_const().to_predicate(tcx)))
}
pub fn elaborate_trait_refs<'tcx>(
tcx: TyCtxt<'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Elaborator<'tcx> {
- let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate());
+ let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate(tcx));
elaborate_predicates(tcx, predicates)
}
}
pub trait ToPredicate<'tcx> {
- fn to_predicate(&self) -> Predicate<'tcx>;
+ fn to_predicate(&self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>;
}
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
ty::PredicateKind::Trait(
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value }),
self.constness,
}
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
ty::PredicateKind::Trait(
ty::Binder::dummy(ty::TraitPredicate { trait_ref: *self.value }),
self.constness,
}
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
}
}
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&PolyTraitRef<'tcx>> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateKind::RegionOutlives(*self)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateKind::TypeOutlives(*self)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
- fn to_predicate(&self) -> Predicate<'tcx> {
+ fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateKind::Projection(*self)
}
}
pub value: T,
}
-// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate()` to ensure that
+// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
// the constness of trait bounds is being propagated correctly.
pub trait WithConstness: Sized {
#[inline]
use crate::ty::ToPredicate;
match *self.skip_binder() {
ExistentialPredicate::Trait(tr) => {
- Binder(tr).with_self_ty(tcx, self_ty).without_const().to_predicate()
+ Binder(tr).with_self_ty(tcx, self_ty).without_const().to_predicate(tcx)
}
ExistentialPredicate::Projection(p) => {
ty::PredicateKind::Projection(Binder(p.with_self_ty(tcx, self_ty)))
ExistentialPredicate::AutoTrait(did) => {
let trait_ref =
Binder(ty::TraitRef { def_id: did, substs: tcx.mk_substs_trait(self_ty, &[]) });
- trait_ref.without_const().to_predicate()
+ trait_ref.without_const().to_predicate(tcx)
}
}
}
"{}",
message.unwrap_or_else(|| format!(
"the trait bound `{}` is not satisfied{}",
- trait_ref.without_const().to_predicate(),
+ trait_ref.without_const().to_predicate(tcx),
post_message,
))
);
fn note_obligation_cause(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut DiagnosticBuilder<'tcx>,
obligation: &PredicateObligation<'tcx>,
);
fn suggest_unsized_bound_if_applicable(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut DiagnosticBuilder<'tcx>,
obligation: &PredicateObligation<'tcx>,
);
) -> PredicateObligation<'tcx> {
let new_trait_ref =
ty::TraitRef { def_id, substs: self.tcx.mk_substs_trait(output_ty, &[]) };
- Obligation::new(cause, param_env, new_trait_ref.without_const().to_predicate())
+ Obligation::new(cause, param_env, new_trait_ref.without_const().to_predicate(self.tcx))
}
fn maybe_report_ambiguity(
let obligation = Obligation::new(
ObligationCause::dummy(),
param_env,
- cleaned_pred.without_const().to_predicate(),
+ cleaned_pred.without_const().to_predicate(selcx.tcx()),
);
self.predicate_may_hold(&obligation)
fn note_obligation_cause(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut DiagnosticBuilder<'tcx>,
obligation: &PredicateObligation<'tcx>,
) {
// First, attempt to add note to this error with an async-await-specific
fn suggest_unsized_bound_if_applicable(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut DiagnosticBuilder<'tcx>,
obligation: &PredicateObligation<'tcx>,
) {
if let (
fn suggest_restricting_param_bound(
&self,
err: &mut DiagnosticBuilder<'_>,
- trait_ref: ty::PolyTraitRef<'_>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
body_id: hir::HirId,
);
fn suggest_borrow_on_unsized_slice(
&self,
code: &ObligationCauseCode<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
);
fn get_closure_name(
fn suggest_add_reference_to_arg(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool,
fn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
);
fn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
points_at_arg: bool,
);
fn suggest_semicolon_removal(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
);
fn suggest_impl_trait(
&self,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
fn point_at_returns_when_relevant(
&self,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
);
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<hir::HirId>, Option<Span>)>,
- inner_generator_body: Option<&hir::Body<'_>>,
+ inner_generator_body: Option<&hir::Body<'tcx>>,
outer_generator: Option<DefId>,
- trait_ref: ty::TraitRef<'_>,
+ trait_ref: ty::TraitRef<'tcx>,
target_ty: Ty<'tcx>,
- tables: &ty::TypeckTables<'_>,
+ tables: &ty::TypeckTables<'tcx>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>,
);
/// it can also be an `impl Trait` param that needs to be decomposed to a type
/// param for cleaner code.
fn suggest_restriction(
- generics: &hir::Generics<'_>,
+ tcx: TyCtxt<'tcx>,
+ generics: &hir::Generics<'tcx>,
msg: &str,
err: &mut DiagnosticBuilder<'_>,
fn_sig: Option<&hir::FnSig<'_>>,
projection: Option<&ty::ProjectionTy<'_>>,
- trait_ref: ty::PolyTraitRef<'_>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
super_traits: Option<(&Ident, &hir::GenericBounds<'_>)>,
) {
// When we are dealing with a trait, `super_traits` will be `Some`:
// FIXME: modify the `trait_ref` instead of string shenanigans.
// Turn `<impl Trait as Foo>::Bar: Qux` into `<T as Foo>::Bar: Qux`.
- let pred = trait_ref.without_const().to_predicate().to_string();
+ let pred = trait_ref.without_const().to_predicate(tcx).to_string();
let pred = pred.replace(&impl_trait_str, &type_param_name);
let mut sugg = vec![
match generics
} else {
// Trivial case: `T` needs an extra bound: `T: Bound`.
let (sp, suggestion) = match super_traits {
- None => {
- predicate_constraint(generics, trait_ref.without_const().to_predicate().to_string())
- }
+ None => predicate_constraint(
+ generics,
+ trait_ref.without_const().to_predicate(tcx).to_string(),
+ ),
Some((ident, bounds)) => match bounds {
[.., bound] => (
bound.span().shrink_to_hi(),
fn suggest_restricting_param_bound(
&self,
mut err: &mut DiagnosticBuilder<'_>,
- trait_ref: ty::PolyTraitRef<'_>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
body_id: hir::HirId,
) {
let self_ty = trait_ref.self_ty();
assert!(param_ty);
// Restricting `Self` for a single method.
suggest_restriction(
+ self.tcx,
&generics,
"`Self`",
err,
assert!(param_ty);
// Restricting `Self` for a single method.
suggest_restriction(
- &generics, "`Self`", err, None, projection, trait_ref, None,
+ self.tcx, &generics, "`Self`", err, None, projection, trait_ref, None,
);
return;
}
}) if projection.is_some() => {
// Missing restriction on associated type of type parameter (unmet projection).
suggest_restriction(
+ self.tcx,
&generics,
"the associated type",
err,
}) if projection.is_some() => {
// Missing restriction on associated type of type parameter (unmet projection).
suggest_restriction(
+ self.tcx,
&generics,
"the associated type",
err,
fn suggest_borrow_on_unsized_slice(
&self,
code: &ObligationCauseCode<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
) {
if let &ObligationCauseCode::VariableType(hir_id) = code {
let parent_node = self.tcx.hir().get_parent_node(hir_id);
fn suggest_add_reference_to_arg(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool,
let new_obligation = Obligation::new(
ObligationCause::dummy(),
param_env,
- new_trait_ref.without_const().to_predicate(),
+ new_trait_ref.without_const().to_predicate(self.tcx),
);
if self.predicate_must_hold_modulo_regions(&new_obligation) {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
fn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
) {
let trait_ref = trait_ref.skip_binder();
fn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
points_at_arg: bool,
) {
fn suggest_semicolon_removal(
&self,
obligation: &PredicateObligation<'tcx>,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
) {
/// emitted.
fn suggest_impl_trait(
&self,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
fn point_at_returns_when_relevant(
&self,
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
) {
match obligation.cause.code.peel_derives() {
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<hir::HirId>, Option<Span>)>,
- inner_generator_body: Option<&hir::Body<'_>>,
+ inner_generator_body: Option<&hir::Body<'tcx>>,
outer_generator: Option<DefId>,
- trait_ref: ty::TraitRef<'_>,
+ trait_ref: ty::TraitRef<'tcx>,
target_ty: Ty<'tcx>,
- tables: &ty::TypeckTables<'_>,
+ tables: &ty::TypeckTables<'tcx>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>,
) {
err.note(&format!("required because it appears within the type `{}`", ty));
obligated_types.push(ty);
- let parent_predicate = parent_trait_ref.without_const().to_predicate();
+ let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
if !self.is_recursive_obligation(obligated_types, &data.parent_code) {
self.note_obligation_cause_code(
err,
parent_trait_ref.print_only_trait_path(),
parent_trait_ref.skip_binder().self_ty()
));
- let parent_predicate = parent_trait_ref.without_const().to_predicate();
+ let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
self.note_obligation_cause_code(
err,
&parent_predicate,
}
ObligationCauseCode::DerivedObligation(ref data) => {
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
- let parent_predicate = parent_trait_ref.without_const().to_predicate();
+ let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
self.note_obligation_cause_code(
err,
&parent_predicate,
}
fn suggest_trait_object_return_type_alternatives(
- err: &mut DiagnosticBuilder<'tcx>,
+ err: &mut DiagnosticBuilder<'_>,
ret_ty: Span,
trait_obj: &str,
is_object_safe: bool,
param_env,
cause: ObligationCause::misc(span, hir::CRATE_HIR_ID),
recursion_depth: 0,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(infcx.tcx),
};
let result = infcx.predicate_must_hold_modulo_regions(&obligation);
cause: ObligationCause::dummy(),
param_env,
recursion_depth: 0,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(tcx),
};
tcx.infer_ctxt().enter(|infcx| infcx.predicate_must_hold_modulo_regions(&obligation))
}
substs: tcx.mk_substs_trait(tcx.types.self_param, &[unsized_self_ty.into()]),
}
.without_const()
- .to_predicate();
+ .to_predicate(tcx);
// U: Trait<Arg1, ..., ArgN>
let trait_predicate = {
}
});
- ty::TraitRef { def_id: unsize_did, substs }.without_const().to_predicate()
+ ty::TraitRef { def_id: unsize_did, substs }.without_const().to_predicate(tcx)
};
let caller_bounds: Vec<Predicate<'tcx>> = param_env
substs: tcx.mk_substs_trait(receiver_ty, &[unsized_receiver_ty.into()]),
}
.without_const()
- .to_predicate();
+ .to_predicate(tcx);
Obligation::new(ObligationCause::dummy(), param_env, predicate)
};
});
let projection = ty::Binder::dummy(ty::ProjectionPredicate { projection_ty, ty: ty_var });
let obligation =
- Obligation::with_depth(cause, depth + 1, param_env, projection.to_predicate());
+ Obligation::with_depth(cause, depth + 1, param_env, projection.to_predicate(tcx));
obligations.push(obligation);
ty_var
})
cause,
recursion_depth: depth,
param_env,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(infcx.tcx),
}
}
cause,
recursion_depth: depth,
param_env,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(selcx.tcx()),
};
let tcx = selcx.infcx().tcx;
let def_id = projection_ty.item_def_id;
object_ty
),
};
- let env_predicates =
- data.projection_bounds().map(|p| p.with_self_ty(selcx.tcx(), object_ty).to_predicate());
+ let env_predicates = data
+ .projection_bounds()
+ .map(|p| p.with_self_ty(selcx.tcx(), object_ty).to_predicate(selcx.tcx()));
let env_predicate = {
let env_predicates = elaborate_predicates(selcx.tcx(), env_predicates);
cause,
obligation.recursion_depth + 1,
obligation.param_env,
- ty::Binder::bind(outlives).to_predicate(),
+ ty::Binder::bind(outlives).to_predicate(tcx),
));
}
tcx.require_lang_item(lang_items::SizedTraitLangItem, None),
tcx.mk_substs_trait(source, &[]),
);
- nested.push(predicate_to_obligation(tr.without_const().to_predicate()));
+ nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
// If the type is `Foo + 'a`, ensure that the type
// being cast to `Foo + 'a` outlives `'a`:
let outlives = ty::OutlivesPredicate(source, r);
- nested.push(predicate_to_obligation(ty::Binder::dummy(outlives).to_predicate()));
+ nested.push(predicate_to_obligation(ty::Binder::dummy(outlives).to_predicate(tcx)));
}
// `[T; n]` -> `[T]`
fn expand(&mut self, item: &TraitAliasExpansionInfo<'tcx>) -> bool {
let tcx = self.tcx;
let trait_ref = item.trait_ref();
- let pred = trait_ref.without_const().to_predicate();
+ let pred = trait_ref.without_const().to_predicate(tcx);
debug!("expand_trait_aliases: trait_ref={:?}", trait_ref);
// Don't recurse if this trait alias is already on the stack for the DFS search.
let anon_pred = anonymize_predicate(tcx, &pred);
if item.path.iter().rev().skip(1).any(|(tr, _)| {
- anonymize_predicate(tcx, &tr.without_const().to_predicate()) == anon_pred
+ anonymize_predicate(tcx, &tr.without_const().to_predicate(tcx)) == anon_pred
}) {
return false;
}
}
pub fn predicate_for_trait_ref<'tcx>(
+ tcx: TyCtxt<'tcx>,
cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
cause,
param_env,
recursion_depth,
- predicate: trait_ref.without_const().to_predicate(),
+ predicate: trait_ref.without_const().to_predicate(tcx),
}
}
) -> PredicateObligation<'tcx> {
let trait_ref =
ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(self_ty, params) };
- predicate_for_trait_ref(cause, param_env, trait_ref, recursion_depth)
+ predicate_for_trait_ref(tcx, cause, param_env, trait_ref, recursion_depth)
}
/// Casts a trait reference into a reference to one of its super
self.compute_trait_ref(&trait_ref, Elaborate::None);
if !data.has_escaping_bound_vars() {
- let predicate = trait_ref.without_const().to_predicate();
+ let predicate = trait_ref.without_const().to_predicate(self.infcx.tcx);
let cause = self.cause(traits::ProjectionWf(data));
self.out.push(traits::Obligation::new(cause, self.param_env, predicate));
}
self.out.push(traits::Obligation::new(
cause,
self.param_env,
- trait_ref.without_const().to_predicate(),
+ trait_ref.without_const().to_predicate(self.infcx.tcx),
));
}
}
self.out.push(traits::Obligation::new(
cause,
self.param_env,
- outlives.to_predicate(),
+ outlives.to_predicate(self.infcx.tcx),
));
}
}
substs: tcx.mk_substs_trait(ty, &[]),
})
.without_const()
- .to_predicate();
+ .to_predicate(tcx);
let predicates = tcx.predicates_of(adtdef.did).predicates;
if predicates.iter().any(|(p, _)| *p == sized_predicate) { vec![] } else { vec![ty] }
}
def_id: sized,
substs: tcx.mk_substs_trait(param_ty, &[]),
});
- (trait_ref.without_const().to_predicate(), span)
+ (trait_ref.without_const().to_predicate(tcx), span)
})
});
// or it's a generic associated type that deliberately has escaping bound vars.
let region_bound = ty::fold::shift_region(tcx, region_bound, 1);
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
- (ty::Binder::bind(outlives).to_predicate(), span)
+ (ty::Binder::bind(outlives).to_predicate(tcx), span)
})
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
- let predicate = bound_trait_ref.with_constness(constness).to_predicate();
+ let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
(predicate, span)
}))
.chain(
self.projection_bounds
.iter()
- .map(|&(projection, span)| (projection.to_predicate(), span)),
+ .map(|&(projection, span)| (projection.to_predicate(tcx), span)),
),
)
.collect()
let obligation = traits::Obligation::new(
cause.clone(),
self.param_env,
- trait_ref.without_const().to_predicate(),
+ trait_ref.without_const().to_predicate(tcx),
);
if !self.infcx.predicate_may_hold(&obligation) {
debug!("overloaded_deref_ty: cannot match obligation");
span,
self.body_id,
self.param_env,
- poly_trait_ref.without_const().to_predicate(),
+ poly_trait_ref.without_const().to_predicate(self.tcx),
);
// Now we want to know if this can be matched
}
TraitCandidate(trait_ref) => {
- let predicate = trait_ref.without_const().to_predicate();
+ let predicate = trait_ref.without_const().to_predicate(self.tcx);
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
if !self.predicate_may_hold(&obligation) {
result = ProbeResult::NoMatch;
span,
self.body_id,
self.param_env,
- poly_trait_ref.without_const().to_predicate(),
+ poly_trait_ref.without_const().to_predicate(tcx),
);
self.predicate_may_hold(&obligation)
})
inherited.register_predicate(traits::Obligation::new(
cause,
param_env,
- trait_ref.without_const().to_predicate(),
+ trait_ref.without_const().to_predicate(tcx),
));
}
}
substs: fcx.tcx.mk_substs_trait(receiver_ty, &[]),
};
- let obligation =
- traits::Obligation::new(cause, fcx.param_env, trait_ref.without_const().to_predicate());
+ let obligation = traits::Obligation::new(
+ cause,
+ fcx.param_env,
+ trait_ref.without_const().to_predicate(fcx.tcx),
+ );
if fcx.predicate_must_hold_modulo_regions(&obligation) {
true
if param_id == item_hir_id {
let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id);
extend =
- Some((identity_trait_ref.without_const().to_predicate(), item.span));
+ Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
}
generics
}
let span = tcx.sess.source_map().guess_head_span(tcx.def_span(def_id));
result.predicates =
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
- ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(),
+ ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(tcx),
span,
))));
}
// set of defaults that can be incorporated into another impl.
if let Some(trait_ref) = is_default_impl_trait {
predicates.push((
- trait_ref.to_poly_trait_ref().without_const().to_predicate(),
+ trait_ref.to_poly_trait_ref().without_const().to_predicate(tcx),
tcx.def_span(def_id),
));
}
hir::GenericBound::Outlives(lt) => {
let bound = AstConv::ast_region_to_region(&icx, <, None);
let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound));
- predicates.push((outlives.to_predicate(), lt.span));
+ predicates.push((outlives.to_predicate(tcx), lt.span));
}
_ => bug!(),
});
match infcx.evaluate_obligation(&traits::Obligation::new(
cause,
param_env,
- trait_ref.without_const().to_predicate(),
+ trait_ref.without_const().to_predicate(infcx.tcx),
)) {
Ok(eval_result) => eval_result.may_apply(),
Err(traits::OverflowError) => true, // overflow doesn't mean yes *or* no