Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5313e2e

Browse files
committed
Make inlining carry over unevaluated consts
1 parent db18b42 commit 5313e2e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustc_mir/transform/inline.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
88
use rustc_middle::mir::visit::*;
99
use rustc_middle::mir::*;
1010
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};
1212
use rustc_session::config::Sanitizer;
1313
use 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

Comments
 (0)