@@ -6,7 +6,7 @@ use rustc_middle::mir::{
6
6
BinOp , Body , Constant , ConstantKind , LocalDecls , Operand , Place , ProjectionElem , Rvalue ,
7
7
SourceInfo , Statement , StatementKind , Terminator , TerminatorKind , UnOp ,
8
8
} ;
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 } ;
10
10
use rustc_span:: symbol:: { sym, Symbol } ;
11
11
12
12
pub struct InstCombine ;
@@ -231,7 +231,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
231
231
// Check this is a foldable intrinsic before we query the layout of our generic parameter
232
232
let Some ( assert_panics) = intrinsic_assert_panics ( intrinsic_name) else { return ; } ;
233
233
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) ) {
235
235
// If we know the assert panics, indicate to later opts that the call diverges
236
236
* target = None ;
237
237
} else {
@@ -243,18 +243,25 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
243
243
244
244
fn intrinsic_assert_panics < ' tcx > (
245
245
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 ( ) ;
248
252
layout. abi . is_uninhabited ( )
249
253
}
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)
252
259
}
253
260
fn mem_uninitialized_valid_predicate < ' tcx > (
254
261
tcx : TyCtxt < ' tcx > ,
255
- layout : TyAndLayout < ' tcx > ,
262
+ param_env_and_layout : ParamEnvAnd < ' tcx , TyAndLayout < ' tcx > > ,
256
263
) -> bool {
257
- !tcx. permits_uninit_init ( layout )
264
+ !tcx. permits_uninit_init ( param_env_and_layout )
258
265
}
259
266
260
267
match intrinsic_name {
0 commit comments