1
Fork 0

Switch ty::TraitRef::from_lang_item from using TyCtxtAt to TyCtxt and a Span

This commit is contained in:
Maybe Waffle 2023-04-26 10:55:11 +00:00
parent 071f737a57
commit 4f2532fb53
10 changed files with 33 additions and 24 deletions

View file

@ -275,7 +275,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
}
};
let output_is_sized_pred = tupled_inputs_and_output.map_bound(|(_, output)| {
ty::TraitRef::from_lang_item(tcx.at(DUMMY_SP), LangItem::Sized, [output])
ty::TraitRef::from_lang_item(tcx, LangItem::Sized, DUMMY_SP, [output])
});
let pred = tupled_inputs_and_output
@ -335,8 +335,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
ty::Alias(_, _) | ty::Param(_) | ty::Placeholder(..) => {
// FIXME(ptr_metadata): It would also be possible to return a `Ok(Ambig)` with no constraints.
let sized_predicate = ty::TraitRef::from_lang_item(
tcx.at(DUMMY_SP),
tcx,
LangItem::Sized,
DUMMY_SP,
[ty::GenericArg::from(goal.predicate.self_ty())],
);
ecx.add_goal(goal.with(tcx, sized_predicate));

View file

@ -243,7 +243,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
}
};
let output_is_sized_pred = tupled_inputs_and_output.map_bound(|(_, output)| {
ty::TraitRef::from_lang_item(tcx.at(DUMMY_SP), LangItem::Sized, [output])
ty::TraitRef::from_lang_item(tcx, LangItem::Sized, DUMMY_SP, [output])
});
let pred = tupled_inputs_and_output

View file

@ -1683,7 +1683,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
&obligation.with(
selcx.tcx(),
ty::Binder::dummy(
ty::TraitRef::from_lang_item(selcx.tcx().at(obligation.cause.span()), LangItem::Sized, [self_ty]),
ty::TraitRef::from_lang_item(selcx.tcx(), LangItem::Sized, obligation.cause.span(),[self_ty]),
)
.without_const(),
),
@ -1949,8 +1949,9 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
});
if check_is_sized {
let sized_predicate = ty::Binder::dummy(ty::TraitRef::from_lang_item(
tcx.at(obligation.cause.span()),
tcx,
LangItem::Sized,
obligation.cause.span(),
[self_ty],
))
.without_const();

View file

@ -646,8 +646,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
output_ty,
&mut nested,
);
let tr =
ty::TraitRef::from_lang_item(self.tcx().at(cause.span), LangItem::Sized, [output_ty]);
let tr = ty::TraitRef::from_lang_item(self.tcx(), LangItem::Sized, cause.span, [output_ty]);
nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
Ok(ImplSourceFnPointerData { fn_ty: self_ty, nested })
@ -1051,8 +1050,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// We can only make objects from sized types.
let tr = ty::Binder::dummy(ty::TraitRef::from_lang_item(
tcx.at(cause.span),
tcx,
LangItem::Sized,
cause.span,
[source],
));
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
@ -1281,8 +1281,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation.recursion_depth + 1,
self_ty.rebind(ty::TraitPredicate {
trait_ref: ty::TraitRef::from_lang_item(
self.tcx().at(cause.span),
self.tcx(),
LangItem::Destruct,
cause.span,
[nested_ty],
),
constness: ty::BoundConstness::ConstIfConst,
@ -1306,8 +1307,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
_ => {
let predicate = self_ty.rebind(ty::TraitPredicate {
trait_ref: ty::TraitRef::from_lang_item(
self.tcx().at(cause.span),
self.tcx(),
LangItem::Destruct,
cause.span,
[nested_ty],
),
constness: ty::BoundConstness::ConstIfConst,

View file

@ -449,7 +449,7 @@ impl<'tcx> WfPredicates<'tcx> {
if !subty.has_escaping_bound_vars() {
let cause = self.cause(cause);
let trait_ref =
ty::TraitRef::from_lang_item(self.tcx.at(cause.span), LangItem::Sized, [subty]);
ty::TraitRef::from_lang_item(self.tcx, LangItem::Sized, cause.span, [subty]);
self.out.push(traits::Obligation::with_depth(
self.tcx,
cause,