@@ -217,11 +217,12 @@ impl<'tcx> std::fmt::Debug for ScalarTy<'tcx> {
217217
218218impl < ' tcx > ConstAnalysis < ' tcx > {
219219 pub fn new ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , map : Map ) -> Self {
220+ let param_env = tcx. param_env ( body. source . def_id ( ) ) ;
220221 Self {
221222 map,
222223 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,
225226 }
226227 }
227228
@@ -260,13 +261,11 @@ impl<'tcx> ConstAnalysis<'tcx> {
260261 } ;
261262 match value {
262263 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 ) ,
270269 FlatSet :: Bottom => FlatSet :: Bottom ,
271270 }
272271 }
0 commit comments