@@ -10,6 +10,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
10
10
use rustc_errors:: struct_span_err;
11
11
use rustc_hir as hir;
12
12
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
13
+ use rustc_hir:: lang_items:: { CoerceUnsizedTraitLangItem , CopyTraitLangItem , SizedTraitLangItem } ;
13
14
use rustc_index:: vec:: { Idx , IndexVec } ;
14
15
use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
15
16
use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
@@ -502,7 +503,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
502
503
if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context {
503
504
let tcx = self . tcx ( ) ;
504
505
let trait_ref = ty:: TraitRef {
505
- def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
506
+ def_id : tcx. require_lang_item ( CopyTraitLangItem , None ) ,
506
507
substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
507
508
} ;
508
509
@@ -1468,7 +1469,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1468
1469
self . check_rvalue ( body, rv, location) ;
1469
1470
if !self . tcx ( ) . features ( ) . unsized_locals {
1470
1471
let trait_ref = ty:: TraitRef {
1471
- def_id : tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) ,
1472
+ def_id : tcx. require_lang_item ( SizedTraitLangItem , None ) ,
1472
1473
substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
1473
1474
} ;
1474
1475
self . prove_trait_ref (
@@ -2013,7 +2014,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2013
2014
ty:: Predicate :: Trait (
2014
2015
ty:: Binder :: bind ( ty:: TraitPredicate {
2015
2016
trait_ref : ty:: TraitRef :: new (
2016
- self . tcx ( ) . lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
2017
+ self . tcx ( )
2018
+ . require_lang_item ( CopyTraitLangItem , None ) ,
2017
2019
tcx. mk_substs_trait ( ty, & [ ] ) ,
2018
2020
) ,
2019
2021
} ) ,
@@ -2037,7 +2039,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2037
2039
}
2038
2040
2039
2041
let trait_ref = ty:: TraitRef {
2040
- def_id : tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) ,
2042
+ def_id : tcx. require_lang_item ( SizedTraitLangItem , None ) ,
2041
2043
substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
2042
2044
} ;
2043
2045
@@ -2135,7 +2137,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2135
2137
CastKind :: Pointer ( PointerCast :: Unsize ) => {
2136
2138
let & ty = ty;
2137
2139
let trait_ref = ty:: TraitRef {
2138
- def_id : tcx. lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) ,
2140
+ def_id : tcx. require_lang_item ( CoerceUnsizedTraitLangItem , None ) ,
2139
2141
substs : tcx. mk_substs_trait ( op. ty ( body, tcx) , & [ ty. into ( ) ] ) ,
2140
2142
} ;
2141
2143
0 commit comments