From e53b18f033b114829d7e47b0aac7c8477b59d5e0 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 29 Oct 2023 13:20:51 -0400 Subject: [PATCH] Enable cross-crate-inlining when MIR inlining is enabled --- compiler/rustc_mir_transform/src/cross_crate_inline.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 24d081f2ac9a9..4d0e261ed1fd7 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -1,3 +1,5 @@ +use crate::inline; +use crate::pass_manager as pm; use rustc_attr::InlineAttr; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; @@ -40,8 +42,11 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { return false; } - // Don't do any inference unless optimizations are enabled. - if matches!(tcx.sess.opts.optimize, OptLevel::No) { + // Don't do any inference if codegen optimizations are disabled and also MIR inlining is not + // 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; }