Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Opt
let level = match item.map(|i| &i.kind) {
// These were a warning before #92959 and need to continue being that to avoid breaking
// stable user code (#94508).
Some(ast::ItemKind::MacCall(_)) => Level::Warning,
Some(ast::ItemKind::MacCall(_)) => Level::Warning(None),
_ => Level::Error,
};
let mut err = Diag::new(dcx, level, msg);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ fn report_inline_asm(
};
let level = match level {
llvm::DiagnosticLevel::Error => Level::Error,
llvm::DiagnosticLevel::Warning => Level::Warning,
llvm::DiagnosticLevel::Warning => Level::Warning(None),
llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note,
};
let msg = msg.trim_prefix("error: ").to_string();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ impl SharedEmitterMain {
sess.dcx().abort_if_errors();
}
Ok(SharedEmitterMessage::InlineAsmError(inner)) => {
assert_matches!(inner.level, Level::Error | Level::Warning | Level::Note);
assert_matches!(inner.level, Level::Error | Level::Warning(None) | Level::Note);
let mut err = Diag::new(sess.dcx(), inner.level, inner.msg);
if !inner.span.is_dummy() {
err.span(inner.span.span());
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ fn annotation_level_for_level(level: Level) -> annotate_snippets::level::Level<'
annotate_snippets::Level::ERROR.with_name("error: internal compiler error")
}
Level::Fatal | Level::Error => annotate_snippets::level::ERROR,
Level::ForceWarning | Level::Warning => annotate_snippets::Level::WARNING,
Level::Warning(_) => annotate_snippets::Level::WARNING,
Level::Note => annotate_snippets::Level::NOTE,
Level::Help => annotate_snippets::Level::HELP,
Level::FailureNote => annotate_snippets::Level::NOTE.no_name(),
Level::Allow => panic!("Should not call with Allow"),
Level::Expect => panic!("Should not call with Expect"),
}
}

Expand Down
45 changes: 12 additions & 33 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_ast::attr::version::RustcVersion;
use rustc_data_structures::stable_hash::StableHasher;
use rustc_error_messages::{DiagArgMap, DiagArgName, IntoDiagArg};
use rustc_hashes::Hash128;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_lint_defs::Applicability;
use rustc_macros::{Decodable, Encodable};
use rustc_span::{Span, Spanned, Symbol};
use tracing::debug;
Expand Down Expand Up @@ -190,7 +190,6 @@ pub struct DiagInner {

pub messages: Vec<(DiagMessage, Style)>,
pub code: Option<ErrCode>,
pub lint_id: Option<LintExpectationId>,
pub span: MultiSpan,
pub children: Vec<Subdiag>,
pub suggestions: Suggestions,
Expand All @@ -212,7 +211,6 @@ impl DiagInner {
pub fn new_with_messages(level: Level, messages: Vec<(DiagMessage, Style)>) -> Self {
DiagInner {
level,
lint_id: None,
messages,
code: None,
span: MultiSpan::new(),
Expand All @@ -234,13 +232,7 @@ impl DiagInner {
match self.level {
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => true,

Level::ForceWarning
| Level::Warning
| Level::Note
| Level::Help
| Level::FailureNote
| Level::Allow
| Level::Expect => false,
Level::Warning(_) | Level::Note | Level::Help | Level::FailureNote => false,
}
}

Expand All @@ -254,16 +246,6 @@ impl DiagInner {
self.is_lint.as_ref().and_then(|is| is.rust_version)
}

pub(crate) fn is_force_warn(&self) -> bool {
match self.level {
Level::ForceWarning => {
assert!(self.is_lint.is_some());
true
}
_ => false,
}
}

pub(crate) fn sub(
&mut self,
level: Sublevel,
Expand Down Expand Up @@ -307,7 +289,6 @@ impl DiagInner {
level,
messages,
code,
lint_id: _, // ignore
span,
children,
suggestions,
Expand All @@ -317,8 +298,16 @@ impl DiagInner {
emitted_at: _, // ignore
} = self;

let hashed_parts =
(level, messages, code, span, children, suggestions, args.as_slice(), is_lint);
let hashed_parts = (
std::mem::discriminant(level), // ignore the field within `Warning`
messages,
code,
span,
children,
suggestions,
args.as_slice(),
is_lint,
);

let mut hasher = StableHasher::new();
hashed_parts.hash(&mut hasher);
Expand Down Expand Up @@ -1099,16 +1088,6 @@ impl<'a> Diag<'a> {
self
} }

with_fn! { with_lint_id,
/// Add an argument.
pub fn lint_id(
&mut self,
id: LintExpectationId,
) -> &mut Self {
self.lint_id = Some(id);
self
} }

with_fn! { with_primary_message,
/// Add a primary message.
pub fn primary_message(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
Expand Down
16 changes: 2 additions & 14 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,8 @@ impl Emitter for JsonEmitter {
fn emit_future_breakage_report(&mut self, diags: Vec<crate::DiagInner>) {
let data: Vec<FutureBreakageItem<'_>> = diags
.into_iter()
.map(|mut diag| {
// Allowed or expected lints don't normally (by definition) emit a lint
// but future incompat lints are special and are emitted anyway.
//
// So to avoid ICEs and confused users we "upgrade" the lint level for
// those `FutureBreakageItem` to warn.
if matches!(diag.level, crate::Level::Allow | crate::Level::Expect) {
diag.level = crate::Level::Warning;
}
FutureBreakageItem {
diagnostic: EmitTyped::Diagnostic(Diagnostic::from_errors_diagnostic(
diag, self,
)),
}
.map(|diag| FutureBreakageItem {
diagnostic: EmitTyped::Diagnostic(Diagnostic::from_errors_diagnostic(diag, self)),
})
.collect();
let report = FutureIncompatReport { future_incompat_report: data };
Expand Down
Loading
Loading