Replace tcx.mk_trait_ref with ty::TraitRef::new
This commit is contained in:
@@ -454,7 +454,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
obligation.param_env,
|
||||
self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred| {
|
||||
pred.trait_ref =
|
||||
self.tcx().mk_trait_ref(fn_ptr_trait, [pred.trait_ref.self_ty()]);
|
||||
ty::TraitRef::new(self.tcx(), fn_ptr_trait, [pred.trait_ref.self_ty()]);
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(pred))
|
||||
})),
|
||||
);
|
||||
@@ -629,7 +629,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
// <ty as Deref>
|
||||
let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, [ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, tcx.lang_items().deref_trait()?, [ty]);
|
||||
|
||||
let obligation =
|
||||
traits::Obligation::new(tcx, cause.clone(), param_env, ty::Binder::dummy(trait_ref));
|
||||
|
||||
@@ -646,8 +646,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
output_ty,
|
||||
&mut nested,
|
||||
);
|
||||
let tr =
|
||||
ty::Binder::dummy(self.tcx().at(cause.span).mk_trait_ref(LangItem::Sized, [output_ty]));
|
||||
let tr = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Sized,
|
||||
[output_ty],
|
||||
));
|
||||
nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
|
||||
|
||||
Ok(ImplSourceFnPointerData { fn_ty: self_ty, nested })
|
||||
@@ -1050,8 +1053,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
);
|
||||
|
||||
// We can only make objects from sized types.
|
||||
let tr =
|
||||
ty::Binder::dummy(tcx.at(cause.span).mk_trait_ref(LangItem::Sized, [source]));
|
||||
let tr = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
tcx.at(cause.span),
|
||||
LangItem::Sized,
|
||||
[source],
|
||||
));
|
||||
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
|
||||
|
||||
// If the type is `Foo + 'a`, ensure that the type
|
||||
@@ -1121,7 +1127,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// Construct the nested `TailField<T>: Unsize<TailField<U>>` predicate.
|
||||
let tail_unsize_obligation = obligation.with(
|
||||
tcx,
|
||||
tcx.mk_trait_ref(obligation.predicate.def_id(), [source_tail, target_tail]),
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id(),
|
||||
[source_tail, target_tail],
|
||||
),
|
||||
);
|
||||
nested.push(tail_unsize_obligation);
|
||||
}
|
||||
@@ -1146,8 +1156,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
nested.extend(obligations);
|
||||
|
||||
// Add a nested `T: Unsize<U>` predicate.
|
||||
let last_unsize_obligation = obligation
|
||||
.with(tcx, tcx.mk_trait_ref(obligation.predicate.def_id(), [a_last, b_last]));
|
||||
let last_unsize_obligation = obligation.with(
|
||||
tcx,
|
||||
ty::TraitRef::new(tcx, obligation.predicate.def_id(), [a_last, b_last]),
|
||||
);
|
||||
nested.push(last_unsize_obligation);
|
||||
}
|
||||
|
||||
@@ -1271,10 +1283,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
self_ty.rebind(ty::TraitPredicate {
|
||||
trait_ref: self
|
||||
.tcx()
|
||||
.at(cause.span)
|
||||
.mk_trait_ref(LangItem::Destruct, [nested_ty]),
|
||||
trait_ref: ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Destruct,
|
||||
[nested_ty],
|
||||
),
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
}),
|
||||
@@ -1295,10 +1308,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// or it's an ADT (and we need to check for a custom impl during selection)
|
||||
_ => {
|
||||
let predicate = self_ty.rebind(ty::TraitPredicate {
|
||||
trait_ref: self
|
||||
.tcx()
|
||||
.at(cause.span)
|
||||
.mk_trait_ref(LangItem::Destruct, [nested_ty]),
|
||||
trait_ref: ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Destruct,
|
||||
[nested_ty],
|
||||
),
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
});
|
||||
|
||||
@@ -2412,7 +2412,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
self.tcx(),
|
||||
cause.clone(),
|
||||
param_env,
|
||||
self.tcx().mk_trait_ref(trait_def_id, [normalized_ty]),
|
||||
ty::TraitRef::new(self.tcx(), trait_def_id, [normalized_ty]),
|
||||
);
|
||||
obligations.push(obligation);
|
||||
obligations
|
||||
|
||||
Reference in New Issue
Block a user