Skip to content

Commit bbbae48

Browse files
committed
Remove is_lint field from Level::Error.
Because it's redundant w.r.t. `Diagnostic::is_lint`, which is present for every diagnostic level. `struct_lint_level_impl` was the only place that set the `Error` field to `true`, and it's also the only place that calls `Diagnostic::is_lint()` to set the `is_lint` field.
1 parent 8e6bca6 commit bbbae48

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

compiler/rustc_builtin_macros/src/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
395395
// These were a warning before #92959 and need to continue being that to avoid breaking
396396
// stable user code (#94508).
397397
Some(ast::ItemKind::MacCall(_)) => Level::Warning(None),
398-
_ => Level::Error { lint: false },
398+
_ => Level::Error,
399399
};
400400
let mut err = DiagnosticBuilder::<()>::new(dcx, level, msg);
401401
err.span(attr_sp);

compiler/rustc_codegen_llvm/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ fn report_inline_asm(
416416
cookie = 0;
417417
}
418418
let level = match level {
419-
llvm::DiagnosticLevel::Error => Level::Error { lint: false },
419+
llvm::DiagnosticLevel::Error => Level::Error,
420420
llvm::DiagnosticLevel::Warning => Level::Warning(None),
421421
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
422422
};

compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ impl SharedEmitterMain {
18481848
}
18491849
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => {
18501850
let err_level = match level {
1851-
Level::Error { lint: false } => Level::Error { lint: false },
1851+
Level::Error => Level::Error,
18521852
Level::Warning(_) => Level::Warning(None),
18531853
Level::Note => Level::Note,
18541854
_ => bug!("Invalid inline asm diagnostic level"),

compiler/rustc_errors/src/lib.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl DiagCtxt {
673673
let key = (span.with_parent(None), key);
674674

675675
if diag.is_error() {
676-
if matches!(diag.level, Error { lint: true }) {
676+
if diag.level == Error && diag.is_lint {
677677
inner.lint_err_count += 1;
678678
} else {
679679
inner.err_count += 1;
@@ -697,7 +697,7 @@ impl DiagCtxt {
697697
let key = (span.with_parent(None), key);
698698
let diag = inner.stashed_diagnostics.remove(&key)?;
699699
if diag.is_error() {
700-
if matches!(diag.level, Error { lint: true }) {
700+
if diag.level == Error && diag.is_lint {
701701
inner.lint_err_count -= 1;
702702
} else {
703703
inner.err_count -= 1;
@@ -812,7 +812,7 @@ impl DiagCtxt {
812812
#[rustc_lint_diagnostics]
813813
#[track_caller]
814814
pub fn struct_err(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_> {
815-
DiagnosticBuilder::new(self, Error { lint: false }, msg)
815+
DiagnosticBuilder::new(self, Error, msg)
816816
}
817817

818818
/// Construct a builder at the `Error` level with the `msg` and the `code`.
@@ -1212,7 +1212,7 @@ impl DiagCtxt {
12121212

12131213
#[track_caller]
12141214
pub fn create_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> DiagnosticBuilder<'a> {
1215-
err.into_diagnostic(self, Error { lint: false })
1215+
err.into_diagnostic(self, Error)
12161216
}
12171217

12181218
#[track_caller]
@@ -1367,7 +1367,7 @@ impl DiagCtxtInner {
13671367
for diag in diags {
13681368
// Decrement the count tracking the stash; emitting will increment it.
13691369
if diag.is_error() {
1370-
if matches!(diag.level, Error { lint: true }) {
1370+
if diag.level == Error && diag.is_lint {
13711371
self.lint_err_count -= 1;
13721372
} else {
13731373
self.err_count -= 1;
@@ -1499,7 +1499,7 @@ impl DiagCtxtInner {
14991499
}
15001500
}
15011501
if diagnostic.is_error() {
1502-
if matches!(diagnostic.level, Error { lint: true }) {
1502+
if diagnostic.level == Error && diagnostic.is_lint {
15031503
self.bump_lint_err_count();
15041504
} else {
15051505
self.bump_err_count();
@@ -1695,11 +1695,7 @@ pub enum Level {
16951695
/// most common case.
16961696
///
16971697
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
1698-
Error {
1699-
/// If this error comes from a lint, don't abort compilation even when abort_if_errors() is
1700-
/// called.
1701-
lint: bool,
1702-
},
1698+
Error,
17031699

17041700
/// A warning about the code being compiled. Does not prevent compilation from finishing.
17051701
///

compiler/rustc_expand/src/proc_macro_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl ToInternal<SmallVec<[tokenstream::TokenTree; 2]>>
379379
impl ToInternal<rustc_errors::Level> for Level {
380380
fn to_internal(self) -> rustc_errors::Level {
381381
match self {
382-
Level::Error => rustc_errors::Level::Error { lint: false },
382+
Level::Error => rustc_errors::Level::Error,
383383
Level::Warning => rustc_errors::Level::Warning(None),
384384
Level::Note => rustc_errors::Level::Note,
385385
Level::Help => rustc_errors::Level::Help,

compiler/rustc_middle/src/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub fn struct_lint_level(
314314
}
315315
Level::ForceWarn(Some(expect_id)) => rustc_errors::Level::Warning(Some(expect_id)),
316316
Level::Warn | Level::ForceWarn(None) => rustc_errors::Level::Warning(None),
317-
Level::Deny | Level::Forbid => rustc_errors::Level::Error { lint: true },
317+
Level::Deny | Level::Forbid => rustc_errors::Level::Error,
318318
};
319319
let mut err = DiagnosticBuilder::new(sess.dcx(), err_level, "");
320320
if let Some(span) = span {

src/tools/miri/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ pub fn report_msg<'tcx>(
454454
let span = stacktrace.first().map_or(DUMMY_SP, |fi| fi.span);
455455
let sess = machine.tcx.sess;
456456
let level = match diag_level {
457-
DiagLevel::Error => Level::Error { lint: false },
457+
DiagLevel::Error => Level::Error,
458458
DiagLevel::Warning => Level::Warning(None),
459459
DiagLevel::Note => Level::Note,
460460
};

0 commit comments

Comments
 (0)