From 091091b956c10b4bac2e4865c05a321e75f83a30 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 6 Feb 2024 08:47:07 +1100 Subject: [PATCH] Remove useless `TRACK_DIAGNOSTIC` calls. There are two calls to `TRACK_DIAGNOSTIC` in `DiagCtxtInner::emit_diagnostic` for cases where we don't emit anything and the closure does nothing. The only effect these calls have is to add a diagnostic to `ImplicitCtxt::diagnostics`, which then gets added to `QuerySideEffects::diagnostics`, which eventually gets handled by `DepGraphData::emit_side_effects`, which calls `emit_diagnostic` on the diagnostic, and again `emit_diagnostic` doesn't emit anything. It's a big, complicate no-op. This commit removes it. --- compiler/rustc_errors/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index a4112d717d029..ae6045d412570 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1294,20 +1294,16 @@ impl DiagCtxtInner { return None; } Warning if !self.flags.can_emit_warnings => { - if diagnostic.has_future_breakage() { - (*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); - } return None; } Allow | Expect(_) => { - (*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {}); return None; } _ => {} } let mut guaranteed = None; - (*TRACK_DIAGNOSTIC)(diagnostic, &mut |mut diagnostic| { + TRACK_DIAGNOSTIC(diagnostic, &mut |mut diagnostic| { if let Some(code) = diagnostic.code { self.emitted_diagnostic_codes.insert(code); }