Auto merge of #117363 - saethlin:cross-crate-inline-when-inline, r=tmiasko

Enable cross-crate-inlining when MIR inlining is enabled

This would make https://github.com/rust-lang/rust/issues/117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
This commit is contained in:
bors 2023-10-31 00:51:25 +00:00
commit 650991d62c

View File

@ -1,3 +1,5 @@
use crate::inline;
use crate::pass_manager as pm;
use rustc_attr::InlineAttr; use rustc_attr::InlineAttr;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
@ -40,8 +42,11 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
return false; return false;
} }
// Don't do any inference unless optimizations are enabled. // Don't do any inference if codegen optimizations are disabled and also MIR inlining is not
if matches!(tcx.sess.opts.optimize, OptLevel::No) { // enabled. This ensures that we do inference even if someone only passes -Zinline-mir,
// which is less confusing than having to also enable -Copt-level=1.
if matches!(tcx.sess.opts.optimize, OptLevel::No) && !pm::should_run_pass(tcx, &inline::Inline)
{
return false; return false;
} }