Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document TRACK_DIAGNOSTIC calls. #120699

Merged
merged 7 commits into from
Mar 14, 2024
Merged
Prev Previous commit
Next Next commit
Inline and remove Level::get_diagnostic_id.
It has a single call site, and this will enable subsequent refactorings.
  • Loading branch information
nnethercote committed Mar 1, 2024
commit ecd3718bc0b3f823b96d6949ba22f77cfbeff5c1
13 changes: 3 additions & 10 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,17 +1356,17 @@ impl DiagCtxtInner {
fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
assert!(diagnostic.level.can_be_top_or_sub().0);

if let Some(expectation_id) = diagnostic.level.get_expectation_id() {
if let Expect(expect_id) | ForceWarning(Some(expect_id)) = diagnostic.level {
// The `LintExpectationId` can be stable or unstable depending on when it was created.
// Diagnostics created before the definition of `HirId`s are unstable and can not yet
// be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
// a stable one by the `LintLevelsBuilder`.
if let LintExpectationId::Unstable { .. } = expectation_id {
if let LintExpectationId::Unstable { .. } = expect_id {
self.unstable_expect_diagnostics.push(diagnostic);
return None;
}
self.suppressed_expected_diag = true;
self.fulfilled_expectations.insert(expectation_id.normalize());
self.fulfilled_expectations.insert(expect_id.normalize());
}

if diagnostic.has_future_breakage() {
Expand Down Expand Up @@ -1794,13 +1794,6 @@ impl Level {
matches!(*self, FailureNote)
}

pub fn get_expectation_id(&self) -> Option<LintExpectationId> {
match self {
Expect(id) | ForceWarning(Some(id)) => Some(*id),
_ => None,
}
}

// Can this level be used in a top-level diagnostic message and/or a
// subdiagnostic message?
fn can_be_top_or_sub(&self) -> (bool, bool) {
Expand Down