Skip to content

Commit 0222366

Browse files
committed
Rename DecorateLint as LintDiagnostic.
To match `derive(LintDiagnostic)`.
1 parent 91b0b86 commit 0222366

File tree

16 files changed

+54
-54
lines changed

16 files changed

+54
-54
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub(super) fn lint<'tcx, 'mir, L>(
168168
lint: &'static rustc_session::lint::Lint,
169169
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
170170
) where
171-
L: for<'a> rustc_errors::DecorateLint<'a, ()>,
171+
L: for<'a> rustc_errors::LintDiagnostic<'a, ()>,
172172
{
173173
let (span, frames) = get_span_and_frames(tcx, machine);
174174

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ pub trait SubdiagMessageOp<G> = Fn(&mut Diag<'_, G>, SubdiagMessage) -> SubdiagM
193193

194194
/// Trait implemented by lint types. This should not be implemented manually. Instead, use
195195
/// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic].
196-
#[rustc_diagnostic_item = "DecorateLint"]
197-
pub trait DecorateLint<'a, G: EmissionGuarantee> {
196+
#[rustc_diagnostic_item = "LintDiagnostic"]
197+
pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
198198
/// Decorate and emit a lint.
199199
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
200200

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extern crate self as rustc_errors;
3737

3838
pub use codes::*;
3939
pub use diagnostic::{
40-
BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner,
41-
DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, StringPart, Subdiag,
40+
BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString,
41+
Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, LintDiagnostic, StringPart, Subdiag,
4242
SubdiagMessageOp, Subdiagnostic,
4343
};
4444
pub use diagnostic_impls::{

compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ lint_deprecated_lint_name =
186186
.help = change it to {$replace}
187187
188188
lint_diag_out_of_impl =
189-
diagnostics should only be created in `Diagnostic`/`Subdiagnostic` impls
189+
diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
190190
191191
lint_drop_glue =
192192
types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree};
4444
use rustc_ast::visit::{FnCtxt, FnKind};
4545
use rustc_ast::{self as ast, *};
4646
use rustc_ast_pretty::pprust::{self, expr_to_string};
47-
use rustc_errors::{Applicability, DecorateLint, MultiSpan};
47+
use rustc_errors::{Applicability, LintDiagnostic, MultiSpan};
4848
use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, GateIssue, Stability};
4949
use rustc_hir as hir;
5050
use rustc_hir::def::{DefKind, Res};
@@ -327,7 +327,7 @@ impl UnsafeCode {
327327
&self,
328328
cx: &EarlyContext<'_>,
329329
span: Span,
330-
decorate: impl for<'a> DecorateLint<'a, ()>,
330+
decorate: impl for<'a> LintDiagnostic<'a, ()>,
331331
) {
332332
// This comes from a macro that has `#[allow_internal_unsafe]`.
333333
if span.allows_unsafe() {

compiler/rustc_lint/src/context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
2121
use rustc_data_structures::fx::FxIndexMap;
2222
use rustc_data_structures::sync;
2323
use rustc_data_structures::unord::UnordMap;
24-
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
24+
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
2525
use rustc_feature::Features;
2626
use rustc_hir as hir;
2727
use rustc_hir::def::Res;
@@ -563,13 +563,13 @@ pub trait LintContext {
563563
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
564564
);
565565

566-
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
566+
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
567567
/// typically generated by `#[derive(LintDiagnostic)]`).
568568
fn emit_span_lint<S: Into<MultiSpan>>(
569569
&self,
570570
lint: &'static Lint,
571571
span: S,
572-
decorator: impl for<'a> DecorateLint<'a, ()>,
572+
decorator: impl for<'a> LintDiagnostic<'a, ()>,
573573
) {
574574
self.opt_span_lint(lint, Some(span), decorator.msg(), |diag| {
575575
decorator.decorate_lint(diag);
@@ -590,9 +590,9 @@ pub trait LintContext {
590590
self.opt_span_lint(lint, Some(span), msg, decorate);
591591
}
592592

593-
/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
593+
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
594594
/// generated by `#[derive(LintDiagnostic)]`).
595-
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) {
595+
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>) {
596596
self.opt_span_lint(lint, None as Option<Span>, decorator.msg(), |diag| {
597597
decorator.decorate_lint(diag);
598598
});

compiler/rustc_lint/src/internal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,14 @@ declare_tool_lint! {
352352
declare_tool_lint! {
353353
/// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with
354354
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or
355-
/// `DecorateLint` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`,
356-
/// `#[derive(DecorateLint)]` expansion.
355+
/// `LintDiagnostic` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`,
356+
/// `#[derive(LintDiagnostic)]` expansion.
357357
///
358358
/// More details on diagnostics implementations can be found
359359
/// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html).
360360
pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL,
361361
Deny,
362-
"prevent creation of diagnostics outside of `Diagnostic`/`Subdiagnostic` impls",
362+
"prevent diagnostic creation outside of `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls",
363363
report_in_external_macro: true
364364
}
365365

@@ -453,7 +453,7 @@ impl LateLintPass<'_> for Diagnostics {
453453
}
454454

455455
// Calls to `#[rustc_lint_diagnostics]`-marked functions should only occur:
456-
// - inside an impl of `Diagnostic`, `Subdiagnostic`, or `DecorateLint`, or
456+
// - inside an impl of `Diagnostic`, `Subdiagnostic`, or `LintDiagnostic`, or
457457
// - inside a parent function that is itself marked with `#[rustc_lint_diagnostics]`.
458458
//
459459
// Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint.
@@ -465,7 +465,7 @@ impl LateLintPass<'_> for Diagnostics {
465465
&& let Impl { of_trait: Some(of_trait), .. } = impl_
466466
&& let Some(def_id) = of_trait.trait_def_id()
467467
&& let Some(name) = cx.tcx.get_diagnostic_name(def_id)
468-
&& matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::DecorateLint)
468+
&& matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::LintDiagnostic)
469469
{
470470
is_inside_appropriate_impl = true;
471471
break;

compiler/rustc_lint/src/levels.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
use rustc_ast as ast;
1717
use rustc_ast_pretty::pprust;
1818
use rustc_data_structures::fx::FxIndexMap;
19-
use rustc_errors::{DecorateLint, Diag, DiagMessage, MultiSpan};
19+
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
2020
use rustc_feature::{Features, GateIssue};
2121
use rustc_hir as hir;
2222
use rustc_hir::intravisit::{self, Visitor};
@@ -1119,7 +1119,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
11191119
&self,
11201120
lint: &'static Lint,
11211121
span: MultiSpan,
1122-
decorate: impl for<'a> DecorateLint<'a, ()>,
1122+
decorate: impl for<'a> LintDiagnostic<'a, ()>,
11231123
) {
11241124
let (level, src) = self.lint_level(lint);
11251125
lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
@@ -1128,7 +1128,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
11281128
}
11291129

11301130
#[track_caller]
1131-
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
1131+
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
11321132
let (level, src) = self.lint_level(lint);
11331133
lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
11341134
decorate.decorate_lint(lint);

compiler/rustc_lint/src/lints.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::num::NonZero;
55
use crate::errors::RequestedLevel;
66
use crate::fluent_generated as fluent;
77
use rustc_errors::{
8-
codes::*, Applicability, DecorateLint, Diag, DiagMessage, DiagStyledString, EmissionGuarantee,
9-
SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
8+
codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee,
9+
LintDiagnostic, SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
1010
};
1111
use rustc_hir::def_id::DefId;
1212
use rustc_macros::{LintDiagnostic, Subdiagnostic};
@@ -136,7 +136,7 @@ pub struct BuiltinMissingDebugImpl<'a> {
136136
}
137137

138138
// Needed for def_path_str
139-
impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> {
139+
impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
140140
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
141141
diag.arg("debug", self.tcx.def_path_str(self.def_id));
142142
}
@@ -241,7 +241,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
241241
pub session: &'a Session,
242242
}
243243

244-
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
244+
impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
245245
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
246246
diag.span_label(self.label, fluent::lint_label);
247247
rustc_session::parse::add_feature_diagnostics(
@@ -423,7 +423,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
423423
pub tcx: TyCtxt<'a>,
424424
}
425425

426-
impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
426+
impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
427427
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
428428
diag.arg("ty", self.ty);
429429
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
@@ -1159,7 +1159,7 @@ pub struct NonFmtPanicUnused {
11591159
}
11601160

11611161
// Used because of two suggestions based on one Option<Span>
1162-
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
1162+
impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
11631163
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
11641164
diag.arg("count", self.count);
11651165
diag.note(fluent::lint_note);
@@ -1397,7 +1397,7 @@ pub struct DropTraitConstraintsDiag<'a> {
13971397
}
13981398

13991399
// Needed for def_path_str
1400-
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
1400+
impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
14011401
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
14021402
diag.arg("predicate", self.predicate);
14031403
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
@@ -1414,7 +1414,7 @@ pub struct DropGlue<'a> {
14141414
}
14151415

14161416
// Needed for def_path_str
1417-
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
1417+
impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
14181418
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
14191419
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
14201420
}
@@ -1689,7 +1689,7 @@ pub struct ImproperCTypes<'a> {
16891689
}
16901690

16911691
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
1692-
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
1692+
impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
16931693
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
16941694
diag.arg("ty", self.ty);
16951695
diag.arg("desc", self.desc);
@@ -1832,7 +1832,7 @@ pub enum UnusedDefSuggestion {
18321832
}
18331833

18341834
// Needed because of def_path_str
1835-
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
1835+
impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
18361836
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
18371837
diag.arg("pre", self.pre);
18381838
diag.arg("post", self.post);
@@ -1915,7 +1915,7 @@ pub struct AsyncFnInTraitDiag {
19151915
pub sugg: Option<Vec<(Span, String)>>,
19161916
}
19171917

1918-
impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
1918+
impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag {
19191919
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
19201920
diag.note(fluent::lint_note);
19211921
if let Some(sugg) = self.sugg {

compiler/rustc_macros/src/diagnostics/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'a> LintDiagnosticDerive<'a> {
153153
});
154154

155155
let mut imp = structure.gen_impl(quote! {
156-
gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self {
156+
gen impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for @Self {
157157
#[track_caller]
158158
fn decorate_lint<'__b>(
159159
self,

0 commit comments

Comments
 (0)