1
Fork 0

Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnr

Replace `tcx.mk_trait_ref` with `TraitRef::new`

First step in implementing https://github.com/rust-lang/compiler-team/issues/616
r? `@lcnr`
This commit is contained in:
bors 2023-05-04 05:54:09 +00:00
commit 6f8c0557e0
49 changed files with 246 additions and 181 deletions

View file

@ -1120,7 +1120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
});
}
if let Some(clone_trait) = tcx.lang_items().clone_trait()
&& let trait_ref = tcx.mk_trait_ref(clone_trait, [ty])
&& let trait_ref = ty::TraitRef::new(tcx, clone_trait, [ty])
&& let o = Obligation::new(
tcx,
ObligationCause::dummy(),

View file

@ -538,7 +538,8 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
let tcx = self.tcx();
let trait_ref = tcx.at(self.last_span).mk_trait_ref(LangItem::Copy, [place_ty.ty]);
let trait_ref =
ty::TraitRef::from_lang_item(tcx, LangItem::Copy, self.last_span, [place_ty.ty]);
// To have a `Copy` operand, the type `T` of the
// value must be `Copy`. Note that we prove that `T: Copy`,
@ -1237,8 +1238,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.check_rvalue(body, rv, location);
if !self.unsized_feature_enabled() {
let trait_ref =
tcx.at(self.last_span).mk_trait_ref(LangItem::Sized, [place_ty]);
let trait_ref = ty::TraitRef::from_lang_item(
tcx,
LangItem::Sized,
self.last_span,
[place_ty],
);
self.prove_trait_ref(
trait_ref,
location.to_locations(),
@ -1810,7 +1815,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Operand::Move(place) => {
// Make sure that repeated elements implement `Copy`.
let ty = place.ty(body, tcx).ty;
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Copy, [ty]);
let trait_ref =
ty::TraitRef::from_lang_item(tcx, LangItem::Copy, span, [ty]);
self.prove_trait_ref(
trait_ref,
@ -1823,7 +1829,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [ty]);
let trait_ref = ty::TraitRef::from_lang_item(tcx, LangItem::Sized, span, [ty]);
self.prove_trait_ref(
trait_ref,
@ -1835,7 +1841,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Rvalue::ShallowInitBox(operand, ty) => {
self.check_operand(operand, location);
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [*ty]);
let trait_ref = ty::TraitRef::from_lang_item(tcx, LangItem::Sized, span, [*ty]);
self.prove_trait_ref(
trait_ref,
@ -1932,9 +1938,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
CastKind::Pointer(PointerCast::Unsize) => {
let &ty = ty;
let trait_ref = tcx
.at(span)
.mk_trait_ref(LangItem::CoerceUnsized, [op.ty(body, tcx), ty]);
let trait_ref = ty::TraitRef::from_lang_item(
tcx,
LangItem::CoerceUnsized,
span,
[op.ty(body, tcx), ty],
);
self.prove_trait_ref(
trait_ref,