@@ -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 , Some ( self . last_span ) ) ,
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 , Some ( self . last_span ) ) ,
1472
1473
substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
1473
1474
} ;
1474
1475
self . prove_trait_ref (
@@ -2013,7 +2014,10 @@ 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 ( ) . require_lang_item (
2018
+ CopyTraitLangItem ,
2019
+ Some ( self . last_span ) ,
2020
+ ) ,
2017
2021
tcx. mk_substs_trait ( ty, & [ ] ) ,
2018
2022
) ,
2019
2023
} ) ,
@@ -2037,7 +2041,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2037
2041
}
2038
2042
2039
2043
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 ) ) ,
2041
2045
substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
2042
2046
} ;
2043
2047
@@ -2135,7 +2139,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2135
2139
CastKind :: Pointer ( PointerCast :: Unsize ) => {
2136
2140
let & ty = ty;
2137
2141
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
+ ) ,
2139
2146
substs : tcx. mk_substs_trait ( op. ty ( body, tcx) , & [ ty. into ( ) ] ) ,
2140
2147
} ;
2141
2148
0 commit comments