Skip to content

Commit

Permalink
Remove useless TRACK_DIAGNOSTIC calls.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nnethercote committed Feb 7, 2024
1 parent 0d53135 commit 091091b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 091091b

Please sign in to comment.