diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 4b1664b8156..b6adee435ba 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -168,7 +168,7 @@ pub(super) fn lint<'tcx, 'mir, L>( lint: &'static rustc_session::lint::Lint, decorator: impl FnOnce(Vec) -> L, ) where - L: for<'a> rustc_errors::DecorateLint<'a, ()>, + L: for<'a> rustc_errors::LintDiagnostic<'a, ()>, { let (span, frames) = get_span_and_frames(tcx, machine); diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index ccaf8c7a235..0c3e7fb75b0 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -193,8 +193,8 @@ pub trait SubdiagMessageOp = Fn(&mut Diag<'_, G>, SubdiagMessage) -> SubdiagM /// Trait implemented by lint types. This should not be implemented manually. Instead, use /// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic]. -#[rustc_diagnostic_item = "DecorateLint"] -pub trait DecorateLint<'a, G: EmissionGuarantee> { +#[rustc_diagnostic_item = "LintDiagnostic"] +pub trait LintDiagnostic<'a, G: EmissionGuarantee> { /// Decorate and emit a lint. fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 99c5bb46d2f..bedb677c1e9 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -37,8 +37,8 @@ extern crate self as rustc_errors; pub use codes::*; pub use diagnostic::{ - BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, - DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, StringPart, Subdiag, + BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString, + Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, LintDiagnostic, StringPart, Subdiag, SubdiagMessageOp, Subdiagnostic, }; pub use diagnostic_impls::{ diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index df1e2b40265..d938a0ccb39 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -186,7 +186,7 @@ lint_deprecated_lint_name = .help = change it to {$replace} lint_diag_out_of_impl = - diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls + diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls lint_drop_glue = types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 5f0af6aee6a..595dc08b081 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -44,7 +44,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::visit::{FnCtxt, FnKind}; use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust::{self, expr_to_string}; -use rustc_errors::{Applicability, DecorateLint, MultiSpan}; +use rustc_errors::{Applicability, LintDiagnostic, MultiSpan}; use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, GateIssue, Stability}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -327,7 +327,7 @@ impl UnsafeCode { &self, cx: &EarlyContext<'_>, span: Span, - decorate: impl for<'a> DecorateLint<'a, ()>, + decorate: impl for<'a> LintDiagnostic<'a, ()>, ) { // This comes from a macro that has `#[allow_internal_unsafe]`. if span.allows_unsafe() { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 89cdde11726..8c0e5b17fd8 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync; use rustc_data_structures::unord::UnordMap; -use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan}; +use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan}; use rustc_feature::Features; use rustc_hir as hir; use rustc_hir::def::Res; @@ -563,13 +563,13 @@ pub trait LintContext { decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ); - /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, + /// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`, /// typically generated by `#[derive(LintDiagnostic)]`). fn emit_span_lint>( &self, lint: &'static Lint, span: S, - decorator: impl for<'a> DecorateLint<'a, ()>, + decorator: impl for<'a> LintDiagnostic<'a, ()>, ) { self.opt_span_lint(lint, Some(span), decorator.msg(), |diag| { decorator.decorate_lint(diag); @@ -590,9 +590,9 @@ pub trait LintContext { self.opt_span_lint(lint, Some(span), msg, decorate); } - /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically + /// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically /// generated by `#[derive(LintDiagnostic)]`). - fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) { + fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>) { self.opt_span_lint(lint, None as Option, decorator.msg(), |diag| { decorator.decorate_lint(diag); }); diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index edbd0bb1923..57fa14acdc1 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -352,14 +352,14 @@ declare_tool_lint! { declare_tool_lint! { /// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with /// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or - /// `DecorateLint` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`, - /// `#[derive(DecorateLint)]` expansion. + /// `LintDiagnostic` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`, + /// `#[derive(LintDiagnostic)]` expansion. /// /// More details on diagnostics implementations can be found /// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html). pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL, Deny, - "prevent creation of diagnostics outside of `Diagnostic`/`Subdiagnostic` impls", + "prevent diagnostic creation outside of `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls", report_in_external_macro: true } @@ -455,7 +455,7 @@ impl LateLintPass<'_> for Diagnostics { } // Calls to `#[rustc_lint_diagnostics]`-marked functions should only occur: - // - inside an impl of `Diagnostic`, `Subdiagnostic`, or `DecorateLint`, or + // - inside an impl of `Diagnostic`, `Subdiagnostic`, or `LintDiagnostic`, or // - inside a parent function that is itself marked with `#[rustc_lint_diagnostics]`. // // Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint. @@ -467,7 +467,7 @@ impl LateLintPass<'_> for Diagnostics { && let Impl { of_trait: Some(of_trait), .. } = impl_ && let Some(def_id) = of_trait.trait_def_id() && let Some(name) = cx.tcx.get_diagnostic_name(def_id) - && matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::DecorateLint) + && matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::LintDiagnostic) { is_inside_appropriate_impl = true; break; diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 2f08cd53b75..e89df1c9840 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -16,7 +16,7 @@ use crate::{ use rustc_ast as ast; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan}; +use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan}; use rustc_feature::{Features, GateIssue}; use rustc_hir as hir; use rustc_hir::intravisit::{self, Visitor}; @@ -1119,7 +1119,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { &self, lint: &'static Lint, span: MultiSpan, - decorate: impl for<'a> DecorateLint<'a, ()>, + decorate: impl for<'a> LintDiagnostic<'a, ()>, ) { let (level, src) = self.lint_level(lint); lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| { @@ -1128,7 +1128,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { } #[track_caller] - pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) { + pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) { let (level, src) = self.lint_level(lint); lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| { decorate.decorate_lint(lint); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1d0b7e45a90..1dac2d89c6b 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -5,8 +5,8 @@ use std::num::NonZero; use crate::errors::RequestedLevel; use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, - SubdiagMessageOp, Subdiagnostic, SuggestionStyle, + codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, + LintDiagnostic, SubdiagMessageOp, Subdiagnostic, SuggestionStyle, }; use rustc_hir::def_id::DefId; use rustc_macros::{LintDiagnostic, Subdiagnostic}; @@ -136,7 +136,7 @@ pub struct BuiltinMissingDebugImpl<'a> { } // Needed for def_path_str -impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> { +impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> { fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { diag.arg("debug", self.tcx.def_path_str(self.def_id)); } @@ -241,7 +241,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> { pub session: &'a Session, } -impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { +impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.span_label(self.label, fluent::lint_label); rustc_session::parse::add_feature_diagnostics( @@ -423,7 +423,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> { pub tcx: TyCtxt<'a>, } -impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> { +impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("ty", self.ty); diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label); @@ -1159,7 +1159,7 @@ pub struct NonFmtPanicUnused { } // Used because of two suggestions based on one Option -impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused { +impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("count", self.count); diag.note(fluent::lint_note); @@ -1397,7 +1397,7 @@ pub struct DropTraitConstraintsDiag<'a> { } // Needed for def_path_str -impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> { +impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("predicate", self.predicate); diag.arg("needs_drop", self.tcx.def_path_str(self.def_id)); @@ -1414,7 +1414,7 @@ pub struct DropGlue<'a> { } // Needed for def_path_str -impl<'a> DecorateLint<'a, ()> for DropGlue<'_> { +impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("needs_drop", self.tcx.def_path_str(self.def_id)); } @@ -1689,7 +1689,7 @@ pub struct ImproperCTypes<'a> { } // Used because of the complexity of Option, DiagMessage, and Option -impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> { +impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("ty", self.ty); diag.arg("desc", self.desc); @@ -1832,7 +1832,7 @@ pub enum UnusedDefSuggestion { } // Needed because of def_path_str -impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> { +impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("pre", self.pre); diag.arg("post", self.post); @@ -1915,7 +1915,7 @@ pub struct AsyncFnInTraitDiag { pub sugg: Option>, } -impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag { +impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.note(fluent::lint_note); if let Some(sugg) = self.sugg { diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index c28e096455f..9d21d88165e 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -153,7 +153,7 @@ impl<'a> LintDiagnosticDerive<'a> { }); let mut imp = structure.gen_impl(quote! { - gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self { + gen impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for @Self { #[track_caller] fn decorate_lint<'__b>( self, diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 0855f6c53fc..b08e5df30ef 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -43,7 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal} #[cfg(parallel_compiler)] use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::unord::UnordSet; -use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, MultiSpan}; +use rustc_errors::{Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, LintDiagnostic, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; @@ -2129,7 +2129,7 @@ impl<'tcx> TyCtxt<'tcx> { T::collect_and_apply(iter, |xs| self.mk_bound_variable_kinds(xs)) } - /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, + /// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`, /// typically generated by `#[derive(LintDiagnostic)]`). #[track_caller] pub fn emit_node_span_lint( @@ -2137,7 +2137,7 @@ impl<'tcx> TyCtxt<'tcx> { lint: &'static Lint, hir_id: HirId, span: impl Into, - decorator: impl for<'a> DecorateLint<'a, ()>, + decorator: impl for<'a> LintDiagnostic<'a, ()>, ) { let msg = decorator.msg(); let (level, src) = self.lint_level_at_node(lint, hir_id); @@ -2163,14 +2163,14 @@ impl<'tcx> TyCtxt<'tcx> { lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate); } - /// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically + /// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically /// generated by `#[derive(LintDiagnostic)]`). #[track_caller] pub fn emit_node_lint( self, lint: &'static Lint, id: HirId, - decorator: impl for<'a> DecorateLint<'a, ()>, + decorator: impl for<'a> LintDiagnostic<'a, ()>, ) { self.node_lint(lint, id, decorator.msg(), |diag| { decorator.decorate_lint(diag); diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 7d08c134057..9297bc51fad 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -1,8 +1,8 @@ use std::borrow::Cow; use rustc_errors::{ - codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic, - EmissionGuarantee, Level, + codes::*, Applicability, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic, + EmissionGuarantee, Level, LintDiagnostic, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails}; @@ -181,7 +181,7 @@ pub(crate) struct UnsafeOpInUnsafeFn { pub suggest_unsafe_block: Option<(Span, Span, Span)>, } -impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn { +impl<'a> LintDiagnostic<'a, ()> for UnsafeOpInUnsafeFn { #[track_caller] fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { let desc = diag.dcx.eagerly_translate_to_string(self.details.label(), [].into_iter()); @@ -215,7 +215,7 @@ pub(crate) enum AssertLintKind { UnconditionalPanic, } -impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint

{ +impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint

{ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { let message = self.assert_kind.diagnostic_message(); self.assert_kind.add_args(&mut |name, value| { @@ -269,7 +269,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> { } // Needed for def_path_str -impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> { +impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> { fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { diag.span_label(self.yield_sp, fluent::_subdiag::label); if let Some(reason) = self.reason { diff --git a/compiler/rustc_pattern_analysis/src/lints.rs b/compiler/rustc_pattern_analysis/src/lints.rs index 30e775733de..16530960656 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -97,7 +97,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>( lint_name: "non_exhaustive_omitted_patterns", }; - use rustc_errors::DecorateLint; + use rustc_errors::LintDiagnostic; let mut err = rcx.tcx.dcx().struct_span_warn(arm.pat.data().unwrap().span, ""); err.primary_message(decorator.msg()); decorator.decorate_lint(&mut err); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 0c8732d3cd0..a8426d78cac 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -183,7 +183,6 @@ symbols! { DebugStruct, Decodable, Decoder, - DecorateLint, Default, Deref, DiagMessage, @@ -242,6 +241,7 @@ symbols! { Layout, Left, LinkedList, + LintDiagnostic, LintPass, LocalKey, Mutex, diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index f9399cb81c8..d443681d5db 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -14,7 +14,7 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - DecorateLint, Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, + Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, LintDiagnostic, SubdiagMessageOp, Subdiagnostic, }; use rustc_macros::{Diagnostic, Subdiagnostic}; @@ -78,9 +78,9 @@ impl Subdiagnostic for TranslatableInAddtoDiag { } } -pub struct UntranslatableInDecorateLint; +pub struct UntranslatableInLintDiagnostic; -impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint { +impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic { fn decorate_lint<'b, >(self, diag: &'b mut Diag<'a, ()>) { diag.note("untranslatable diagnostic"); //~^ ERROR diagnostics should be created using translatable messages @@ -91,9 +91,9 @@ impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint { } } -pub struct TranslatableInDecorateLint; +pub struct TranslatableInLintDiagnostic; -impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint { +impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.note(crate::fluent_generated::no_crate_note); } @@ -105,10 +105,10 @@ impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint { pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) { let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); - //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls let _diag = dcx.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index 01184d7264b..ee5400f6f95 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -22,7 +22,7 @@ error: diagnostics should be created using translatable messages LL | diag.note("untranslatable diagnostic"); | ^^^^ -error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls --> $DIR/diagnostics.rs:107:21 | LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); @@ -34,7 +34,7 @@ note: the lint level is defined here LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls --> $DIR/diagnostics.rs:110:21 | LL | let _diag = dcx.struct_err("untranslatable diagnostic");