@@ -8,7 +8,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
88use rustc_middle:: mir:: visit:: * ;
99use rustc_middle:: mir:: * ;
1010use 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 } ;
1212use rustc_session:: config:: Sanitizer ;
1313use rustc_target:: spec:: abi:: Abi ;
1414
@@ -123,6 +123,14 @@ impl Inliner<'tcx> {
123123 continue ;
124124 } ;
125125
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+
126134 let start = caller_body. basic_blocks ( ) . len ( ) ;
127135 debug ! ( "attempting to inline callsite {:?} - body={:?}" , callsite, callee_body) ;
128136 if !self . inline_call ( callsite, caller_body, callee_body) {
0 commit comments