Skip to content

Commit

Permalink
Remove unnecessary setting of suppressed_expected_diag.
Browse files Browse the repository at this point in the history
It's currently set in three places. Two of them seem to be unnecessary,
and the one in `emit_diagnostic` can be changed to only trigger for
`Expect` level diagnostics.

After this change the name `suppressed_expected_diag` actually matches
the code's behaviour, which is nice.
  • Loading branch information
nnethercote committed Jan 31, 2024
1 parent 8b25343 commit 6a48407
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,6 @@ impl DiagCtxt {
inner.check_unstable_expect_diagnostics = true;

if !diags.is_empty() {
inner.suppressed_expected_diag = true;
for mut diag in diags.into_iter() {
diag.update_unstable_expectation_id(unstable_to_stable);

Expand Down Expand Up @@ -1291,15 +1290,10 @@ impl DiagCtxtInner {
}

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're Level::Allow,
// but they still need to be constructed and stashed below,
// so they'll trigger the good-path bug check.
self.suppressed_expected_diag = true;
self.future_breakage_diagnostics.push(diagnostic.clone());
}

if let Some(expectation_id) = diagnostic.level.get_expectation_id() {
self.suppressed_expected_diag = true;
self.fulfilled_expectations.insert(expectation_id.normalize());
}

Expand All @@ -1310,7 +1304,13 @@ impl DiagCtxtInner {
return None;
}

if matches!(diagnostic.level, Expect(_) | Allow) {
if matches!(diagnostic.level, Expect(_)) {
self.suppressed_expected_diag = true;
(*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {});
return None;
}

if matches!(diagnostic.level, Allow) {
(*TRACK_DIAGNOSTIC)(diagnostic, &mut |_| {});
return None;
}
Expand Down

0 comments on commit 6a48407

Please sign in to comment.