Skip to content

Commit

Permalink
Make inlining carry over unevaluated consts
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Apr 23, 2020
1 parent db18b42 commit 5313e2e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/librustc_mir/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::subst::{Subst, SubstsRef};
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
use rustc_session::config::Sanitizer;
use rustc_target::spec::abi::Abi;

Expand Down Expand Up @@ -123,6 +123,14 @@ impl Inliner<'tcx> {
continue;
};

// Copy only unevaluated constants from the callee_body into the caller_body.
// Although we are only pushing `ConstKind::Unevaluated` consts to uneval_consts,
// here we may not only have `ConstKind::Unevaluated` because we are calling
// `subst_and_normalize_erasing_regions`.
caller_body.uneval_consts.extend(callee_body.uneval_consts.iter().copied().filter(
|&constant| matches!(constant.literal.val, ConstKind::Unevaluated(_, _, _)),
));

let start = caller_body.basic_blocks().len();
debug!("attempting to inline callsite {:?} - body={:?}", callsite, callee_body);
if !self.inline_call(callsite, caller_body, callee_body) {
Expand Down

0 comments on commit 5313e2e

Please sign in to comment.