@@ -547,10 +547,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
547
547
548
548
if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context {
549
549
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 ] ) ;
554
551
555
552
// To have a `Copy` operand, the type `T` of the
556
553
// value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1273,10 +1270,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1273
1270
1274
1271
self . check_rvalue ( body, rv, location) ;
1275
1272
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] ) ;
1280
1275
self . prove_trait_ref (
1281
1276
trait_ref,
1282
1277
location. to_locations ( ) ,
@@ -1840,6 +1835,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1840
1835
#[ instrument( skip( self , body) , level = "debug" ) ]
1841
1836
fn check_rvalue ( & mut self , body : & Body < ' tcx > , rvalue : & Rvalue < ' tcx > , location : Location ) {
1842
1837
let tcx = self . tcx ( ) ;
1838
+ let span = body. source_info ( location) . span ;
1843
1839
1844
1840
match rvalue {
1845
1841
Rvalue :: Aggregate ( ak, ops) => {
@@ -1863,12 +1859,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1863
1859
}
1864
1860
Operand :: Move ( place) => {
1865
1861
// Make sure that repeated elements implement `Copy`.
1866
- let span = body. source_info ( location) . span ;
1867
1862
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] ) ;
1872
1864
1873
1865
self . prove_trait_ref (
1874
1866
trait_ref,
@@ -1881,10 +1873,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1881
1873
}
1882
1874
1883
1875
& 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] ) ;
1888
1877
1889
1878
self . prove_trait_ref (
1890
1879
trait_ref,
@@ -1896,10 +1885,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1896
1885
Rvalue :: ShallowInitBox ( operand, ty) => {
1897
1886
self . check_operand ( operand, location) ;
1898
1887
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] ) ;
1903
1889
1904
1890
self . prove_trait_ref (
1905
1891
trait_ref,
@@ -1996,11 +1982,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1996
1982
1997
1983
CastKind :: Pointer ( PointerCast :: Unsize ) => {
1998
1984
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] ) ;
2004
1988
2005
1989
self . prove_trait_ref (
2006
1990
trait_ref,
0 commit comments