@@ -217,11 +217,12 @@ impl<'tcx> std::fmt::Debug for ScalarTy<'tcx> {
217
217
218
218
impl < ' tcx > ConstAnalysis < ' tcx > {
219
219
pub fn new ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , map : Map ) -> Self {
220
+ let param_env = tcx. param_env ( body. source . def_id ( ) ) ;
220
221
Self {
221
222
map,
222
223
tcx,
223
- ecx : InterpCx :: new ( tcx, DUMMY_SP , ty :: ParamEnv :: empty ( ) , DummyMachine ) ,
224
- param_env : tcx . param_env ( body . source . def_id ( ) ) ,
224
+ ecx : InterpCx :: new ( tcx, DUMMY_SP , param_env , DummyMachine ) ,
225
+ param_env : param_env,
225
226
}
226
227
}
227
228
@@ -260,13 +261,11 @@ impl<'tcx> ConstAnalysis<'tcx> {
260
261
} ;
261
262
match value {
262
263
FlatSet :: Top => FlatSet :: Top ,
263
- FlatSet :: Elem ( ScalarTy ( scalar, ty) ) => {
264
- let layout = self
265
- . tcx
266
- . layout_of ( ty:: ParamEnv :: empty ( ) . and ( ty) )
267
- . expect ( "this should not happen" ) ; // FIXME
268
- FlatSet :: Elem ( ImmTy :: from_scalar ( scalar, layout) )
269
- }
264
+ FlatSet :: Elem ( ScalarTy ( scalar, ty) ) => self
265
+ . tcx
266
+ . layout_of ( self . param_env . and ( ty) )
267
+ . map ( |layout| FlatSet :: Elem ( ImmTy :: from_scalar ( scalar, layout) ) )
268
+ . unwrap_or ( FlatSet :: Top ) ,
270
269
FlatSet :: Bottom => FlatSet :: Bottom ,
271
270
}
272
271
}
0 commit comments