@@ -9,7 +9,7 @@ use rustc::mir::interpret::{
9
9
} ;
10
10
use rustc:: ty:: layout:: { self , Align , HasDataLayout , LayoutOf , Size , TyLayout } ;
11
11
use rustc:: ty:: query:: TyCtxtAt ;
12
- use rustc:: ty:: subst:: SubstsRef ;
12
+ use rustc:: ty:: subst:: { Subst , SubstsRef } ;
13
13
use rustc:: ty:: { self , Instance , Ty , TyCtxt , TypeFoldable } ;
14
14
use rustc_data_structures:: fx:: FxHashMap ;
15
15
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
@@ -25,6 +25,7 @@ use super::{
25
25
} ;
26
26
use rustc:: infer:: canonical:: OriginalQueryValues ;
27
27
use rustc:: infer:: InferCtxt ;
28
+ use rustc:: traits:: ObligationCause ;
28
29
29
30
pub struct InterpCx < ' infcx , ' mir , ' tcx , M : Machine < ' mir , ' tcx > > {
30
31
/// Stores the `Machine` instance.
@@ -345,26 +346,18 @@ impl<'infcx, 'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'infcx, 'mir, 'tcx, M>
345
346
& self ,
346
347
value : T ,
347
348
) -> T {
348
- let mut param_env = self . param_env ;
349
- param_env. caller_bounds =
350
- self . tcx . mk_predicates ( param_env. caller_bounds . iter ( ) . filter ( |predicate| {
351
- match * predicate {
352
- ty:: Predicate :: Trait ( ..)
353
- | ty:: Predicate :: Subtype ( ..)
354
- | ty:: Predicate :: Projection ( ..)
355
- | ty:: Predicate :: WellFormed ( ..)
356
- | ty:: Predicate :: ObjectSafe ( ..)
357
- | ty:: Predicate :: ClosureKind ( ..)
358
- | ty:: Predicate :: ConstEvaluatable ( ..) => true ,
359
- ty:: Predicate :: TypeOutlives ( ..) | ty:: Predicate :: RegionOutlives ( ..) => false ,
360
- }
361
- } ) ) ;
362
-
363
- self . tcx . subst_and_normalize_erasing_regions (
364
- self . frame ( ) . instance . substs ,
365
- param_env,
366
- & value,
367
- )
349
+ let substituted = value. subst ( * self . tcx , self . frame ( ) . instance . substs ) ;
350
+ let erased_value = self . tcx . erase_regions ( & substituted) ;
351
+
352
+ // TODO handle normalization failure and obligations
353
+ let normalized_value = self
354
+ . infcx
355
+ . at ( & ObligationCause :: dummy ( ) , self . param_env )
356
+ . normalize ( & erased_value)
357
+ . unwrap ( )
358
+ . value ;
359
+ let normalized_value = self . infcx . resolve_vars_if_possible ( & normalized_value) ;
360
+ self . tcx . erase_regions ( & normalized_value)
368
361
}
369
362
370
363
/// The `substs` are assumed to already be in our interpreter "universe" (param_env).
0 commit comments