Skip to content

Commit 5fe5d5d

Browse files
committed
Remove lots of rustc_errors:: qualifiers in lints.rs.
1 parent 505c137 commit 5fe5d5d

File tree

1 file changed

+36
-63
lines changed

1 file changed

+36
-63
lines changed

compiler/rustc_lint/src/lints.rs

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::num::NonZeroU32;
55
use crate::errors::RequestedLevel;
66
use crate::fluent_generated as fluent;
77
use rustc_errors::{
8-
AddToDiagnostic, Applicability, DecorateLint, DiagnosticMessage, DiagnosticStyledString,
9-
SuggestionStyle,
8+
AddToDiagnostic, Applicability, DecorateLint, Diagnostic, DiagnosticBuilder, DiagnosticMessage,
9+
DiagnosticStyledString, SubdiagnosticMessage, SuggestionStyle,
1010
};
1111
use rustc_hir::def_id::DefId;
1212
use rustc_macros::{LintDiagnostic, Subdiagnostic};
@@ -239,7 +239,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
239239
}
240240

241241
impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
242-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
242+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
243243
diag.span_label(self.label, fluent::lint_label);
244244
rustc_session::parse::add_feature_diagnostics(
245245
diag,
@@ -268,20 +268,17 @@ pub struct SuggestChangingAssocTypes<'a, 'b> {
268268
}
269269

270270
impl AddToDiagnostic for SuggestChangingAssocTypes<'_, '_> {
271-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
271+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
272272
where
273-
F: Fn(
274-
&mut rustc_errors::Diagnostic,
275-
rustc_errors::SubdiagnosticMessage,
276-
) -> rustc_errors::SubdiagnosticMessage,
273+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
277274
{
278275
// Access to associates types should use `<T as Bound>::Assoc`, which does not need a
279276
// bound. Let's see if this type does that.
280277

281278
// We use a HIR visitor to walk the type.
282279
use rustc_hir::intravisit::{self, Visitor};
283280
struct WalkAssocTypes<'a> {
284-
err: &'a mut rustc_errors::Diagnostic,
281+
err: &'a mut Diagnostic,
285282
}
286283
impl Visitor<'_> for WalkAssocTypes<'_> {
287284
fn visit_qpath(
@@ -326,12 +323,9 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion {
326323
}
327324

328325
impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
329-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
326+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
330327
where
331-
F: Fn(
332-
&mut rustc_errors::Diagnostic,
333-
rustc_errors::SubdiagnosticMessage,
334-
) -> rustc_errors::SubdiagnosticMessage,
328+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
335329
{
336330
diag.multipart_suggestion(
337331
fluent::lint_suggestion,
@@ -425,7 +419,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
425419
}
426420

427421
impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
428-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
422+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
429423
diag.arg("ty", self.ty);
430424
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
431425
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
@@ -438,7 +432,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
438432
self.sub.add_to_diagnostic(diag);
439433
}
440434

441-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
435+
fn msg(&self) -> DiagnosticMessage {
442436
self.msg.clone()
443437
}
444438
}
@@ -449,12 +443,9 @@ pub struct BuiltinUnpermittedTypeInitSub {
449443
}
450444

451445
impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub {
452-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
446+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
453447
where
454-
F: Fn(
455-
&mut rustc_errors::Diagnostic,
456-
rustc_errors::SubdiagnosticMessage,
457-
) -> rustc_errors::SubdiagnosticMessage,
448+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
458449
{
459450
let mut err = self.err;
460451
loop {
@@ -506,12 +497,9 @@ pub struct BuiltinClashingExternSub<'a> {
506497
}
507498

508499
impl AddToDiagnostic for BuiltinClashingExternSub<'_> {
509-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
500+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
510501
where
511-
F: Fn(
512-
&mut rustc_errors::Diagnostic,
513-
rustc_errors::SubdiagnosticMessage,
514-
) -> rustc_errors::SubdiagnosticMessage,
502+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
515503
{
516504
let mut expected_str = DiagnosticStyledString::new();
517505
expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false);
@@ -779,12 +767,9 @@ pub struct HiddenUnicodeCodepointsDiagLabels {
779767
}
780768

781769
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels {
782-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
770+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
783771
where
784-
F: Fn(
785-
&mut rustc_errors::Diagnostic,
786-
rustc_errors::SubdiagnosticMessage,
787-
) -> rustc_errors::SubdiagnosticMessage,
772+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
788773
{
789774
for (c, span) in self.spans {
790775
diag.span_label(span, format!("{c:?}"));
@@ -799,12 +784,9 @@ pub enum HiddenUnicodeCodepointsDiagSub {
799784

800785
// Used because of multiple multipart_suggestion and note
801786
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub {
802-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
787+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
803788
where
804-
F: Fn(
805-
&mut rustc_errors::Diagnostic,
806-
rustc_errors::SubdiagnosticMessage,
807-
) -> rustc_errors::SubdiagnosticMessage,
789+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
808790
{
809791
match self {
810792
HiddenUnicodeCodepointsDiagSub::Escape { spans } => {
@@ -953,12 +935,9 @@ pub struct NonBindingLetSub {
953935
}
954936

955937
impl AddToDiagnostic for NonBindingLetSub {
956-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
938+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
957939
where
958-
F: Fn(
959-
&mut rustc_errors::Diagnostic,
960-
rustc_errors::SubdiagnosticMessage,
961-
) -> rustc_errors::SubdiagnosticMessage,
940+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
962941
{
963942
diag.span_suggestion_verbose(
964943
self.suggestion,
@@ -1147,7 +1126,7 @@ pub struct NonFmtPanicUnused {
11471126

11481127
// Used because of two suggestions based on one Option<Span>
11491128
impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
1150-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1129+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
11511130
diag.arg("count", self.count);
11521131
diag.note(fluent::lint_note);
11531132
if let Some(span) = self.suggestion {
@@ -1166,7 +1145,7 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
11661145
}
11671146
}
11681147

1169-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1148+
fn msg(&self) -> DiagnosticMessage {
11701149
fluent::lint_non_fmt_panic_unused
11711150
}
11721151
}
@@ -1224,12 +1203,9 @@ pub enum NonSnakeCaseDiagSub {
12241203
}
12251204

12261205
impl AddToDiagnostic for NonSnakeCaseDiagSub {
1227-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
1206+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
12281207
where
1229-
F: Fn(
1230-
&mut rustc_errors::Diagnostic,
1231-
rustc_errors::SubdiagnosticMessage,
1232-
) -> rustc_errors::SubdiagnosticMessage,
1208+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
12331209
{
12341210
match self {
12351211
NonSnakeCaseDiagSub::Label { span } => {
@@ -1342,12 +1318,12 @@ pub struct DropTraitConstraintsDiag<'a> {
13421318

13431319
// Needed for def_path_str
13441320
impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> {
1345-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1321+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
13461322
diag.arg("predicate", self.predicate);
13471323
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
13481324
}
13491325

1350-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1326+
fn msg(&self) -> DiagnosticMessage {
13511327
fluent::lint_drop_trait_constraints
13521328
}
13531329
}
@@ -1359,11 +1335,11 @@ pub struct DropGlue<'a> {
13591335

13601336
// Needed for def_path_str
13611337
impl<'a> DecorateLint<'a, ()> for DropGlue<'_> {
1362-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1338+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
13631339
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
13641340
}
13651341

1366-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1342+
fn msg(&self) -> DiagnosticMessage {
13671343
fluent::lint_drop_glue
13681344
}
13691345
}
@@ -1423,12 +1399,9 @@ pub enum OverflowingBinHexSign {
14231399
}
14241400

14251401
impl AddToDiagnostic for OverflowingBinHexSign {
1426-
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
1402+
fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
14271403
where
1428-
F: Fn(
1429-
&mut rustc_errors::Diagnostic,
1430-
rustc_errors::SubdiagnosticMessage,
1431-
) -> rustc_errors::SubdiagnosticMessage,
1404+
F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
14321405
{
14331406
match self {
14341407
OverflowingBinHexSign::Positive => {
@@ -1633,7 +1606,7 @@ pub struct ImproperCTypes<'a> {
16331606

16341607
// Used because of the complexity of Option<DiagnosticMessage>, DiagnosticMessage, and Option<Span>
16351608
impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
1636-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1609+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
16371610
diag.arg("ty", self.ty);
16381611
diag.arg("desc", self.desc);
16391612
diag.span_label(self.label, fluent::lint_label);
@@ -1646,7 +1619,7 @@ impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
16461619
}
16471620
}
16481621

1649-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1622+
fn msg(&self) -> DiagnosticMessage {
16501623
fluent::lint_improper_ctypes
16511624
}
16521625
}
@@ -1776,7 +1749,7 @@ pub enum UnusedDefSuggestion {
17761749

17771750
// Needed because of def_path_str
17781751
impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
1779-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1752+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
17801753
diag.arg("pre", self.pre);
17811754
diag.arg("post", self.post);
17821755
diag.arg("def", self.cx.tcx.def_path_str(self.def_id));
@@ -1789,7 +1762,7 @@ impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
17891762
}
17901763
}
17911764

1792-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1765+
fn msg(&self) -> DiagnosticMessage {
17931766
fluent::lint_unused_def
17941767
}
17951768
}
@@ -1859,14 +1832,14 @@ pub struct AsyncFnInTraitDiag {
18591832
}
18601833

18611834
impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag {
1862-
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) {
1835+
fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) {
18631836
diag.note(fluent::lint_note);
18641837
if let Some(sugg) = self.sugg {
18651838
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
18661839
}
18671840
}
18681841

1869-
fn msg(&self) -> rustc_errors::DiagnosticMessage {
1842+
fn msg(&self) -> DiagnosticMessage {
18701843
fluent::lint_async_fn_in_trait
18711844
}
18721845
}

0 commit comments

Comments
 (0)