@@ -547,10 +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 = ty:: TraitRef {
551- def_id : tcx. require_lang_item ( LangItem :: Copy , Some ( self . last_span ) ) ,
552- substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
553- } ;
550+ let trait_ref = tcx. at ( self . last_span ) . mk_trait_ref ( LangItem :: Copy , [ place_ty. ty ] ) ;
554551
555552 // To have a `Copy` operand, the type `T` of the
556553 // value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1273,10 +1270,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12731270
12741271 self . check_rvalue ( body, rv, location) ;
12751272 if !self . unsized_feature_enabled ( ) {
1276- let trait_ref = ty:: TraitRef {
1277- def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1278- substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
1279- } ;
1273+ let trait_ref =
1274+ tcx. at ( self . last_span ) . mk_trait_ref ( LangItem :: Sized , [ place_ty] ) ;
12801275 self . prove_trait_ref (
12811276 trait_ref,
12821277 location. to_locations ( ) ,
@@ -1840,6 +1835,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18401835 #[ instrument( skip( self , body) , level = "debug" ) ]
18411836 fn check_rvalue ( & mut self , body : & Body < ' tcx > , rvalue : & Rvalue < ' tcx > , location : Location ) {
18421837 let tcx = self . tcx ( ) ;
1838+ let span = body. source_info ( location) . span ;
18431839
18441840 match rvalue {
18451841 Rvalue :: Aggregate ( ak, ops) => {
@@ -1863,12 +1859,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18631859 }
18641860 Operand :: Move ( place) => {
18651861 // Make sure that repeated elements implement `Copy`.
1866- let span = body. source_info ( location) . span ;
18671862 let ty = place. ty ( body, tcx) . ty ;
1868- let trait_ref = ty:: TraitRef :: new (
1869- tcx. require_lang_item ( LangItem :: Copy , Some ( span) ) ,
1870- tcx. mk_substs_trait ( ty, & [ ] ) ,
1871- ) ;
1863+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Copy , [ ty] ) ;
18721864
18731865 self . prove_trait_ref (
18741866 trait_ref,
@@ -1881,10 +1873,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18811873 }
18821874
18831875 & Rvalue :: NullaryOp ( NullOp :: SizeOf | NullOp :: AlignOf , ty) => {
1884- let trait_ref = ty:: TraitRef {
1885- def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1886- substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
1887- } ;
1876+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Sized , [ ty] ) ;
18881877
18891878 self . prove_trait_ref (
18901879 trait_ref,
@@ -1896,10 +1885,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18961885 Rvalue :: ShallowInitBox ( operand, ty) => {
18971886 self . check_operand ( operand, location) ;
18981887
1899- let trait_ref = ty:: TraitRef {
1900- def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1901- substs : tcx. mk_substs_trait ( * ty, & [ ] ) ,
1902- } ;
1888+ let trait_ref = tcx. at ( span) . mk_trait_ref ( LangItem :: Sized , [ * ty] ) ;
19031889
19041890 self . prove_trait_ref (
19051891 trait_ref,
@@ -1996,11 +1982,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19961982
19971983 CastKind :: Pointer ( PointerCast :: Unsize ) => {
19981984 let & ty = ty;
1999- let trait_ref = ty:: TraitRef {
2000- def_id : tcx
2001- . require_lang_item ( LangItem :: CoerceUnsized , Some ( self . last_span ) ) ,
2002- substs : tcx. mk_substs_trait ( op. ty ( body, tcx) , & [ ty. into ( ) ] ) ,
2003- } ;
1985+ let trait_ref = tcx
1986+ . at ( span)
1987+ . mk_trait_ref ( LangItem :: CoerceUnsized , [ op. ty ( body, tcx) , ty] ) ;
20041988
20051989 self . prove_trait_ref (
20061990 trait_ref,
0 commit comments