1
Fork 0

Remove LintDiagnostic::msg

* instead simply set the primary message inside the lint decorator functions
* it used to be this way before [#]101986 which introduced `msg` to prevent
  good path delayed bugs (which no longer exist) from firing under certain
  circumstances when lints were suppressed / silenced
* this is no longer necessary for various reasons I presume
* it shaves off complexity and makes further changes easier to implement
This commit is contained in:
León Orell Valerian Liehr 2024-05-22 16:46:05 +02:00
parent 366ef95407
commit 06bc4fc671
No known key found for this signature in database
GPG key ID: D17A07215F68E713
44 changed files with 430 additions and 488 deletions

View file

@ -1,4 +1,4 @@
use rustc_errors::{codes::*, Diag, DiagMessage, LintDiagnostic};
use rustc_errors::{codes::*, Diag, LintDiagnostic};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::mir::AssertKind;
use rustc_middle::ty::TyCtxt;
@ -50,18 +50,15 @@ pub(crate) enum AssertLintKind {
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
let message = self.assert_kind.diagnostic_message();
diag.primary_message(match self.lint_kind {
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
});
let label = self.assert_kind.diagnostic_message();
self.assert_kind.add_args(&mut |name, value| {
diag.arg(name, value);
});
diag.span_label(self.span, message);
}
fn msg(&self) -> DiagMessage {
match self.lint_kind {
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
}
diag.span_label(self.span, label);
}
}
@ -104,6 +101,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> {
// Needed for def_path_str
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
diag.primary_message(fluent::mir_transform_must_not_suspend);
diag.span_label(self.yield_sp, fluent::_subdiag::label);
if let Some(reason) = self.reason {
diag.subdiagnostic(diag.dcx, reason);
@ -113,10 +111,6 @@ impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
diag.arg("def_path", self.tcx.def_path_str(self.def_id));
diag.arg("post", self.post);
}
fn msg(&self) -> rustc_errors::DiagMessage {
fluent::mir_transform_must_not_suspend
}
}
#[derive(Subdiagnostic)]