@@ -547,11 +547,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
547547
548548 if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context {
549549 let tcx = self . tcx ( ) ;
550- let trait_ref = tcx. mk_trait_ref (
551- tcx. require_lang_item ( LangItem :: Copy , Some ( self . last_span ) ) ,
552- place_ty. ty ,
553- [ ] ,
554- ) ;
550+ let trait_ref = tcx. at ( self . last_span ) . mk_trait_ref ( LangItem :: Copy , place_ty. ty , [ ] ) ;
555551
556552 // To have a `Copy` operand, the type `T` of the
557553 // value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1274,11 +1270,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12741270
12751271 self . check_rvalue ( body, rv, location) ;
12761272 if !self . unsized_feature_enabled ( ) {
1277- let trait_ref = tcx. mk_trait_ref (
1278- tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1279- place_ty,
1280- [ ] ,
1281- ) ;
1273+ let trait_ref =
1274+ tcx. at ( self . last_span ) . mk_trait_ref ( LangItem :: Sized , place_ty, [ ] ) ;
12821275 self . prove_trait_ref (
12831276 trait_ref,
12841277 location. to_locations ( ) ,
@@ -1842,6 +1835,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18421835 #[ instrument( skip( self , body) , level = "debug" ) ]
18431836 fn check_rvalue ( & mut self , body : & Body < ' tcx > , rvalue : & Rvalue < ' tcx > , location : Location ) {
18441837 let tcx = self . tcx ( ) ;
1838+ let span = body. source_info ( location) . span ;
18451839
18461840 match rvalue {
18471841 Rvalue :: Aggregate ( ak, ops) => {
@@ -1865,13 +1859,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18651859 }
18661860 Operand :: Move ( place) => {
18671861 // Make sure that repeated elements implement `Copy`.
1868- let span = body. source_info ( location) . span ;
18691862 let ty = place. ty ( body, tcx) . ty ;
1870- let trait_ref = tcx. mk_trait_ref (
1871- tcx. require_lang_item ( LangItem :: Copy , Some ( span) ) ,
1872- ty,
1873- [ ] ,
1874- ) ;
1863+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Copy , ty, [ ] ) ;
18751864
18761865 self . prove_trait_ref (
18771866 trait_ref,
@@ -1884,11 +1873,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18841873 }
18851874
18861875 & Rvalue :: NullaryOp ( NullOp :: SizeOf | NullOp :: AlignOf , ty) => {
1887- let trait_ref = tcx. mk_trait_ref (
1888- tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1889- ty,
1890- [ ] ,
1891- ) ;
1876+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Sized , ty, [ ] ) ;
18921877
18931878 self . prove_trait_ref (
18941879 trait_ref,
@@ -1900,11 +1885,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19001885 Rvalue :: ShallowInitBox ( operand, ty) => {
19011886 self . check_operand ( operand, location) ;
19021887
1903- let trait_ref = tcx. mk_trait_ref (
1904- tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1905- * ty,
1906- [ ] ,
1907- ) ;
1888+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Sized , * ty, [ ] ) ;
19081889
19091890 self . prove_trait_ref (
19101891 trait_ref,
@@ -2001,8 +1982,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20011982
20021983 CastKind :: Pointer ( PointerCast :: Unsize ) => {
20031984 let & ty = ty;
2004- let trait_ref = tcx. mk_trait_ref (
2005- tcx . require_lang_item ( LangItem :: CoerceUnsized , Some ( self . last_span ) ) ,
1985+ let trait_ref = tcx. at ( span ) . mk_trait_ref (
1986+ LangItem :: CoerceUnsized ,
20061987 op. ty ( body, tcx) ,
20071988 [ ty. into ( ) ] ,
20081989 ) ;
0 commit comments