@@ -6,7 +6,7 @@ use rustc_middle::mir::{
66 BinOp , Body , Constant , ConstantKind , LocalDecls , Operand , Place , ProjectionElem , Rvalue ,
77 SourceInfo , Statement , StatementKind , Terminator , TerminatorKind , UnOp ,
88} ;
9- use rustc_middle:: ty:: { self , layout:: TyAndLayout , ParamEnv , SubstsRef , Ty , TyCtxt } ;
9+ use rustc_middle:: ty:: { self , layout:: TyAndLayout , ParamEnv , ParamEnvAnd , SubstsRef , Ty , TyCtxt } ;
1010use rustc_span:: symbol:: { sym, Symbol } ;
1111
1212pub struct InstCombine ;
@@ -231,7 +231,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
231231 // Check this is a foldable intrinsic before we query the layout of our generic parameter
232232 let Some ( assert_panics) = intrinsic_assert_panics ( intrinsic_name) else { return ; } ;
233233 let Ok ( layout) = self . tcx . layout_of ( self . param_env . and ( ty) ) else { return ; } ;
234- if assert_panics ( self . tcx , layout) {
234+ if assert_panics ( self . tcx , self . param_env . and ( layout) ) {
235235 // If we know the assert panics, indicate to later opts that the call diverges
236236 * target = None ;
237237 } else {
@@ -243,18 +243,25 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
243243
244244fn intrinsic_assert_panics < ' tcx > (
245245 intrinsic_name : Symbol ,
246- ) -> Option < fn ( TyCtxt < ' tcx > , TyAndLayout < ' tcx > ) -> bool > {
247- fn inhabited_predicate < ' tcx > ( _tcx : TyCtxt < ' tcx > , layout : TyAndLayout < ' tcx > ) -> bool {
246+ ) -> Option < fn ( TyCtxt < ' tcx > , ParamEnvAnd < ' tcx , TyAndLayout < ' tcx > > ) -> bool > {
247+ fn inhabited_predicate < ' tcx > (
248+ _tcx : TyCtxt < ' tcx > ,
249+ param_env_and_layout : ParamEnvAnd < ' tcx , TyAndLayout < ' tcx > > ,
250+ ) -> bool {
251+ let ( _param_env, layout) = param_env_and_layout. into_parts ( ) ;
248252 layout. abi . is_uninhabited ( )
249253 }
250- fn zero_valid_predicate < ' tcx > ( tcx : TyCtxt < ' tcx > , layout : TyAndLayout < ' tcx > ) -> bool {
251- !tcx. permits_zero_init ( layout)
254+ fn zero_valid_predicate < ' tcx > (
255+ tcx : TyCtxt < ' tcx > ,
256+ param_env_and_layout : ParamEnvAnd < ' tcx , TyAndLayout < ' tcx > > ,
257+ ) -> bool {
258+ !tcx. permits_zero_init ( param_env_and_layout)
252259 }
253260 fn mem_uninitialized_valid_predicate < ' tcx > (
254261 tcx : TyCtxt < ' tcx > ,
255- layout : TyAndLayout < ' tcx > ,
262+ param_env_and_layout : ParamEnvAnd < ' tcx , TyAndLayout < ' tcx > > ,
256263 ) -> bool {
257- !tcx. permits_uninit_init ( layout )
264+ !tcx. permits_uninit_init ( param_env_and_layout )
258265 }
259266
260267 match intrinsic_name {
0 commit comments