@@ -8,7 +8,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
8
8
use rustc_middle:: mir:: visit:: * ;
9
9
use rustc_middle:: mir:: * ;
10
10
use rustc_middle:: ty:: subst:: { Subst , SubstsRef } ;
11
- use rustc_middle:: ty:: { self , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
11
+ use rustc_middle:: ty:: { self , ConstKind , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
12
12
use rustc_session:: config:: Sanitizer ;
13
13
use rustc_target:: spec:: abi:: Abi ;
14
14
@@ -123,6 +123,14 @@ impl Inliner<'tcx> {
123
123
continue ;
124
124
} ;
125
125
126
+ // Copy only unevaluated constants from the callee_body into the caller_body.
127
+ // Although we are only pushing `ConstKind::Unevaluated` consts to uneval_consts,
128
+ // here we may not only have `ConstKind::Unevaluated` because we are calling
129
+ // `subst_and_normalize_erasing_regions`.
130
+ caller_body. uneval_consts . extend ( callee_body. uneval_consts . iter ( ) . copied ( ) . filter (
131
+ |& constant| matches ! ( constant. literal. val, ConstKind :: Unevaluated ( _, _, _) ) ,
132
+ ) ) ;
133
+
126
134
let start = caller_body. basic_blocks ( ) . len ( ) ;
127
135
debug ! ( "attempting to inline callsite {:?} - body={:?}" , callsite, callee_body) ;
128
136
if !self . inline_call ( callsite, caller_body, callee_body) {
0 commit comments