Skip to content

Commit e9f0d9b

Browse files
committed
Rename DecorateLint as LintDiagnostic.
To match `derive(LintDiagnostic)`.
1 parent 541d7cc commit e9f0d9b

File tree

16 files changed

+54
-54
lines changed

16 files changed

+54
-54
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/error.rs

+1-1
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

Diff for: compiler/rustc_errors/src/diagnostic.rs

+2-2
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

Diff for: compiler/rustc_errors/src/lib.rs

+2-2
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::{

Diff for: compiler/rustc_lint/messages.ftl

+1-1
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

Diff for: compiler/rustc_lint/src/builtin.rs

+2-2
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() {

Diff for: compiler/rustc_lint/src/context.rs

+5-5
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
});

Diff for: compiler/rustc_lint/src/internal.rs

+5-5
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

@@ -455,7 +455,7 @@ impl LateLintPass<'_> for Diagnostics {
455455
}
456456

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

Diff for: compiler/rustc_lint/src/levels.rs

+3-3
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);

Diff for: compiler/rustc_lint/src/lints.rs

+11-11
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 {

Diff for: compiler/rustc_macros/src/diagnostics/diagnostic.rs

+1-1
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,

Diff for: compiler/rustc_middle/src/ty/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal}
4343
#[cfg(parallel_compiler)]
4444
use rustc_data_structures::sync::{DynSend, DynSync};
4545
use rustc_data_structures::unord::UnordSet;
46-
use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, MultiSpan};
46+
use rustc_errors::{Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, LintDiagnostic, MultiSpan};
4747
use rustc_hir as hir;
4848
use rustc_hir::def::DefKind;
4949
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
@@ -2129,15 +2129,15 @@ impl<'tcx> TyCtxt<'tcx> {
21292129
T::collect_and_apply(iter, |xs| self.mk_bound_variable_kinds(xs))
21302130
}
21312131

2132-
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
2132+
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
21332133
/// typically generated by `#[derive(LintDiagnostic)]`).
21342134
#[track_caller]
21352135
pub fn emit_node_span_lint(
21362136
self,
21372137
lint: &'static Lint,
21382138
hir_id: HirId,
21392139
span: impl Into<MultiSpan>,
2140-
decorator: impl for<'a> DecorateLint<'a, ()>,
2140+
decorator: impl for<'a> LintDiagnostic<'a, ()>,
21412141
) {
21422142
let msg = decorator.msg();
21432143
let (level, src) = self.lint_level_at_node(lint, hir_id);
@@ -2163,14 +2163,14 @@ impl<'tcx> TyCtxt<'tcx> {
21632163
lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
21642164
}
21652165

2166-
/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
2166+
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
21672167
/// generated by `#[derive(LintDiagnostic)]`).
21682168
#[track_caller]
21692169
pub fn emit_node_lint(
21702170
self,
21712171
lint: &'static Lint,
21722172
id: HirId,
2173-
decorator: impl for<'a> DecorateLint<'a, ()>,
2173+
decorator: impl for<'a> LintDiagnostic<'a, ()>,
21742174
) {
21752175
self.node_lint(lint, id, decorator.msg(), |diag| {
21762176
decorator.decorate_lint(diag);

Diff for: compiler/rustc_mir_transform/src/errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::borrow::Cow;
22

33
use rustc_errors::{
4-
codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic,
5-
EmissionGuarantee, Level,
4+
codes::*, Applicability, Diag, DiagArgValue, DiagCtxt, DiagMessage, Diagnostic,
5+
EmissionGuarantee, Level, LintDiagnostic,
66
};
77
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
88
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
@@ -181,7 +181,7 @@ pub(crate) struct UnsafeOpInUnsafeFn {
181181
pub suggest_unsafe_block: Option<(Span, Span, Span)>,
182182
}
183183

184-
impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn {
184+
impl<'a> LintDiagnostic<'a, ()> for UnsafeOpInUnsafeFn {
185185
#[track_caller]
186186
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
187187
let desc = diag.dcx.eagerly_translate_to_string(self.details.label(), [].into_iter());
@@ -215,7 +215,7 @@ pub(crate) enum AssertLintKind {
215215
UnconditionalPanic,
216216
}
217217

218-
impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint<P> {
218+
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
219219
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
220220
let message = self.assert_kind.diagnostic_message();
221221
self.assert_kind.add_args(&mut |name, value| {
@@ -269,7 +269,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> {
269269
}
270270

271271
// Needed for def_path_str
272-
impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> {
272+
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
273273
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
274274
diag.span_label(self.yield_sp, fluent::_subdiag::label);
275275
if let Some(reason) = self.reason {

Diff for: compiler/rustc_pattern_analysis/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>(
9797
lint_name: "non_exhaustive_omitted_patterns",
9898
};
9999

100-
use rustc_errors::DecorateLint;
100+
use rustc_errors::LintDiagnostic;
101101
let mut err = rcx.tcx.dcx().struct_span_warn(arm.pat.data().unwrap().span, "");
102102
err.primary_message(decorator.msg());
103103
decorator.decorate_lint(&mut err);

Diff for: compiler/rustc_span/src/symbol.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ symbols! {
183183
DebugStruct,
184184
Decodable,
185185
Decoder,
186-
DecorateLint,
187186
Default,
188187
Deref,
189188
DiagMessage,
@@ -242,6 +241,7 @@ symbols! {
242241
Layout,
243242
Left,
244243
LinkedList,
244+
LintDiagnostic,
245245
LintPass,
246246
LocalKey,
247247
Mutex,

0 commit comments

Comments
 (0)