@@ -547,11 +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 = 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 , [ ] ) ;
555
551
556
552
// To have a `Copy` operand, the type `T` of the
557
553
// value must be `Copy`. Note that we prove that `T: Copy`,
@@ -1274,11 +1270,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1274
1270
1275
1271
self . check_rvalue ( body, rv, location) ;
1276
1272
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, [ ] ) ;
1282
1275
self . prove_trait_ref (
1283
1276
trait_ref,
1284
1277
location. to_locations ( ) ,
@@ -1842,6 +1835,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1842
1835
#[ instrument( skip( self , body) , level = "debug" ) ]
1843
1836
fn check_rvalue ( & mut self , body : & Body < ' tcx > , rvalue : & Rvalue < ' tcx > , location : Location ) {
1844
1837
let tcx = self . tcx ( ) ;
1838
+ let span = body. source_info ( location) . span ;
1845
1839
1846
1840
match rvalue {
1847
1841
Rvalue :: Aggregate ( ak, ops) => {
@@ -1865,13 +1859,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1865
1859
}
1866
1860
Operand :: Move ( place) => {
1867
1861
// Make sure that repeated elements implement `Copy`.
1868
- let span = body. source_info ( location) . span ;
1869
1862
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, [ ] ) ;
1875
1864
1876
1865
self . prove_trait_ref (
1877
1866
trait_ref,
@@ -1884,11 +1873,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1884
1873
}
1885
1874
1886
1875
& 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, [ ] ) ;
1892
1877
1893
1878
self . prove_trait_ref (
1894
1879
trait_ref,
@@ -1900,11 +1885,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1900
1885
Rvalue :: ShallowInitBox ( operand, ty) => {
1901
1886
self . check_operand ( operand, location) ;
1902
1887
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, [ ] ) ;
1908
1889
1909
1890
self . prove_trait_ref (
1910
1891
trait_ref,
@@ -2001,8 +1982,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2001
1982
2002
1983
CastKind :: Pointer ( PointerCast :: Unsize ) => {
2003
1984
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 ,
2006
1987
op. ty ( body, tcx) ,
2007
1988
[ ty. into ( ) ] ,
2008
1989
) ;
0 commit comments