Skip to content

Commit 650991d

Browse files
committed
Auto merge of #117363 - saethlin:cross-crate-inline-when-inline, r=tmiasko
Enable cross-crate-inlining when MIR inlining is enabled This would make #117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
2 parents a395214 + e53b18f commit 650991d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_mir_transform/src/cross_crate_inline.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::inline;
2+
use crate::pass_manager as pm;
13
use rustc_attr::InlineAttr;
24
use rustc_hir::def::DefKind;
35
use rustc_hir::def_id::LocalDefId;
@@ -40,8 +42,11 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
4042
return false;
4143
}
4244

43-
// Don't do any inference unless optimizations are enabled.
44-
if matches!(tcx.sess.opts.optimize, OptLevel::No) {
45+
// Don't do any inference if codegen optimizations are disabled and also MIR inlining is not
46+
// enabled. This ensures that we do inference even if someone only passes -Zinline-mir,
47+
// which is less confusing than having to also enable -Copt-level=1.
48+
if matches!(tcx.sess.opts.optimize, OptLevel::No) && !pm::should_run_pass(tcx, &inline::Inline)
49+
{
4550
return false;
4651
}
4752

0 commit comments

Comments
 (0)