From 73ad5adacca0e50197e707dae9aca00b1bd1ab16 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Tue, 14 Oct 2025 00:50:34 +0000 Subject: [PATCH] Cross-crate inline functions that only call another function. --- compiler/rustc_mir_transform/src/cross_crate_inline.rs | 6 +++--- tests/mir-opt/c_unwind_terminate.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 7fc9fb9cca2d7..e82c7c1ff879a 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -96,9 +96,9 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { let mut checker = CostChecker { tcx, callee_body: mir, calls: 0, statements: 0, landing_pads: 0, resumes: 0 }; checker.visit_body(mir); - checker.calls == 0 - && checker.resumes == 0 - && checker.landing_pads == 0 + checker.calls <= 1 + && checker.resumes <= checker.calls + && checker.landing_pads <= checker.calls && checker.statements <= threshold } diff --git a/tests/mir-opt/c_unwind_terminate.rs b/tests/mir-opt/c_unwind_terminate.rs index 64524e74d28e5..12eeef7f9f93f 100644 --- a/tests/mir-opt/c_unwind_terminate.rs +++ b/tests/mir-opt/c_unwind_terminate.rs @@ -7,6 +7,7 @@ impl Drop for Noise { } } +#[inline(never)] fn panic() { panic!(); }