From 00f4daa27673a07bf9ad20f4707d97bc1079450f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 17 Mar 2024 22:26:39 -0400 Subject: Codegen const panic messages as function calls This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary. --- tests/codegen-units/item-collection/implicit-panic-call.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/codegen-units') diff --git a/tests/codegen-units/item-collection/implicit-panic-call.rs b/tests/codegen-units/item-collection/implicit-panic-call.rs index 2e0d742307a..b348b4acc24 100644 --- a/tests/codegen-units/item-collection/implicit-panic-call.rs +++ b/tests/codegen-units/item-collection/implicit-panic-call.rs @@ -16,10 +16,17 @@ struct Location<'a> { _col: u32, } -#[lang = "panic"] +#[lang = "panic_const_div_by_zero"] #[inline] #[track_caller] -fn panic(_: &'static str) -> ! { +fn panic_div_zero() -> ! { + loop {} +} + +#[lang = "panic_const_div_overflow"] +#[inline] +#[track_caller] +fn panic_div_overflow() -> ! { loop {} } @@ -55,4 +62,5 @@ pub fn foo() { //~ MONO_ITEM fn foo //~ MONO_ITEM fn ::div -//~ MONO_ITEM fn panic +//~ MONO_ITEM fn panic_div_zero +//~ MONO_ITEM fn panic_div_overflow -- cgit 1.4.1-3-g733a5