Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 19dacee

Browse files
committedMay 10, 2024
Auto merge of #124982 - compiler-errors:uplift-trait-ref, r=lcnr
Uplift `TraitRef` into `rustc_type_ir` Emotional rollercoaster r? lcnr
2 parents 6e1d947 + b55d8a3 commit 19dacee

File tree

55 files changed

+492
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+492
-313
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_middle::mir::{
2222
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
2323
TerminatorKind, VarBindingForm,
2424
};
25+
use rustc_middle::ty::print::PrintTraitRefExt as _;
2526
use rustc_middle::ty::{
2627
self, suggest_constraining_type_params, PredicateKind, ToPredicate, Ty, TyCtxt,
2728
TypeSuperVisitable, TypeVisitor,

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,11 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
532532

533533
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
534534
let tcx = self.tcx();
535-
let trait_ref =
536-
ty::TraitRef::from_lang_item(tcx, LangItem::Copy, self.last_span, [place_ty.ty]);
535+
let trait_ref = ty::TraitRef::new(
536+
tcx,
537+
tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
538+
[place_ty.ty],
539+
);
537540

538541
// To have a `Copy` operand, the type `T` of the
539542
// value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1273,10 +1276,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12731276

12741277
self.check_rvalue(body, rv, location);
12751278
if !self.unsized_feature_enabled() {
1276-
let trait_ref = ty::TraitRef::from_lang_item(
1279+
let trait_ref = ty::TraitRef::new(
12771280
tcx,
1278-
LangItem::Sized,
1279-
self.last_span,
1281+
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
12801282
[place_ty],
12811283
);
12821284
self.prove_trait_ref(
@@ -1925,8 +1927,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19251927
Operand::Move(place) => {
19261928
// Make sure that repeated elements implement `Copy`.
19271929
let ty = place.ty(body, tcx).ty;
1928-
let trait_ref =
1929-
ty::TraitRef::from_lang_item(tcx, LangItem::Copy, span, [ty]);
1930+
let trait_ref = ty::TraitRef::new(
1931+
tcx,
1932+
tcx.require_lang_item(LangItem::Copy, Some(span)),
1933+
[ty],
1934+
);
19301935

19311936
self.prove_trait_ref(
19321937
trait_ref,
@@ -1939,7 +1944,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19391944
}
19401945

19411946
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
1942-
let trait_ref = ty::TraitRef::from_lang_item(tcx, LangItem::Sized, span, [ty]);
1947+
let trait_ref = ty::TraitRef::new(
1948+
tcx,
1949+
tcx.require_lang_item(LangItem::Sized, Some(span)),
1950+
[ty],
1951+
);
19431952

19441953
self.prove_trait_ref(
19451954
trait_ref,
@@ -1952,7 +1961,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19521961
Rvalue::ShallowInitBox(operand, ty) => {
19531962
self.check_operand(operand, location);
19541963

1955-
let trait_ref = ty::TraitRef::from_lang_item(tcx, LangItem::Sized, span, [*ty]);
1964+
let trait_ref = ty::TraitRef::new(
1965+
tcx,
1966+
tcx.require_lang_item(LangItem::Sized, Some(span)),
1967+
[*ty],
1968+
);
19561969

19571970
self.prove_trait_ref(
19581971
trait_ref,
@@ -2050,10 +2063,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20502063

20512064
CastKind::PointerCoercion(PointerCoercion::Unsize) => {
20522065
let &ty = ty;
2053-
let trait_ref = ty::TraitRef::from_lang_item(
2066+
let trait_ref = ty::TraitRef::new(
20542067
tcx,
2055-
LangItem::CoerceUnsized,
2056-
span,
2068+
tcx.require_lang_item(LangItem::CoerceUnsized, Some(span)),
20572069
[op.ty(body, tcx), ty],
20582070
);
20592071

0 commit comments

Comments
 (0)
Please sign in to comment.