From 58e6bafc87d47473272b013c556ceec93be79ac9 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 24 Jun 2025 23:40:03 +0000 Subject: [PATCH] mbe: Mark expansion errors cold_path --- compiler/rustc_expand/src/lib.rs | 1 + compiler/rustc_expand/src/mbe/macro_rules.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index 64be7649775f3..a8e13b13030d9 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -4,6 +4,7 @@ #![doc(rust_logo)] #![feature(array_windows)] #![feature(associated_type_defaults)] +#![feature(cold_path)] #![feature(if_let_guard)] #![feature(macro_metavar_expr)] #![feature(proc_macro_diagnostic)] diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 783f061ec6c58..584d00653bb87 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -229,6 +229,8 @@ fn expand_macro<'cx>( let tts = match transcribe(psess, &named_matches, rhs, rhs_span, transparency, id) { Ok(tts) => tts, Err(err) => { + // Pessimize error handling for perf + std::hint::cold_path(); let guar = err.emit(); return DummyResult::any(arm_span, guar); }