@@ -10,6 +10,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010use  rustc_errors:: struct_span_err; 
1111use  rustc_hir as  hir; 
1212use  rustc_hir:: def_id:: { DefId ,  LocalDefId } ; 
13+ use  rustc_hir:: lang_items:: { CoerceUnsizedTraitLangItem ,  CopyTraitLangItem ,  SizedTraitLangItem } ; 
1314use  rustc_index:: vec:: { Idx ,  IndexVec } ; 
1415use  rustc_infer:: infer:: canonical:: QueryRegionConstraints ; 
1516use  rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ; 
@@ -502,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
502503        if  let  PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy )  = context { 
503504            let  tcx = self . tcx ( ) ; 
504505            let  trait_ref = ty:: TraitRef  { 
505-                 def_id :  tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) , 
506+                 def_id :  tcx. require_lang_item ( CopyTraitLangItem ,   Some ( self . last_span ) ) , 
506507                substs :  tcx. mk_substs_trait ( place_ty. ty ,  & [ ] ) , 
507508            } ; 
508509
@@ -1468,7 +1469,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14681469                self . check_rvalue ( body,  rv,  location) ; 
14691470                if  !self . tcx ( ) . features ( ) . unsized_locals  { 
14701471                    let  trait_ref = ty:: TraitRef  { 
1471-                         def_id :  tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) , 
1472+                         def_id :  tcx. require_lang_item ( SizedTraitLangItem ,   Some ( self . last_span ) ) , 
14721473                        substs :  tcx. mk_substs_trait ( place_ty,  & [ ] ) , 
14731474                    } ; 
14741475                    self . prove_trait_ref ( 
@@ -2013,7 +2014,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20132014                                    ty:: Predicate :: Trait ( 
20142015                                        ty:: Binder :: bind ( ty:: TraitPredicate  { 
20152016                                            trait_ref :  ty:: TraitRef :: new ( 
2016-                                                 self . tcx ( ) . lang_items ( ) . copy_trait ( ) . unwrap ( ) , 
2017+                                                 self . tcx ( ) . require_lang_item ( 
2018+                                                     CopyTraitLangItem , 
2019+                                                     Some ( self . last_span ) , 
2020+                                                 ) , 
20172021                                                tcx. mk_substs_trait ( ty,  & [ ] ) , 
20182022                                            ) , 
20192023                                        } ) , 
@@ -2037,7 +2041,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20372041                } 
20382042
20392043                let  trait_ref = ty:: TraitRef  { 
2040-                     def_id :  tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) , 
2044+                     def_id :  tcx. require_lang_item ( SizedTraitLangItem ,   Some ( self . last_span ) ) , 
20412045                    substs :  tcx. mk_substs_trait ( ty,  & [ ] ) , 
20422046                } ; 
20432047
@@ -2135,7 +2139,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21352139                    CastKind :: Pointer ( PointerCast :: Unsize )  => { 
21362140                        let  & ty = ty; 
21372141                        let  trait_ref = ty:: TraitRef  { 
2138-                             def_id :  tcx. lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) , 
2142+                             def_id :  tcx. require_lang_item ( 
2143+                                 CoerceUnsizedTraitLangItem , 
2144+                                 Some ( self . last_span ) , 
2145+                             ) , 
21392146                            substs :  tcx. mk_substs_trait ( op. ty ( body,  tcx) ,  & [ ty. into ( ) ] ) , 
21402147                        } ; 
21412148
0 commit comments