Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5cecd4a

Browse files
committed
Move more early buffered lints to dyn lint diagnostics (3/N)
1 parent 7284884 commit 5cecd4a

File tree

9 files changed

+39
-55
lines changed

9 files changed

+39
-55
lines changed

‎compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,6 @@ lint_macro_is_private = macro `{$ident}` is private
460460
461461
lint_macro_rule_never_used = rule #{$n} of macro `{$name}` is never used
462462
463-
lint_macro_use_deprecated =
464-
applying the `#[macro_use]` attribute to an `extern crate` item is deprecated
465-
.help = remove it and import macros at use sites with a `use` item instead
466-
467463
lint_malformed_attribute = malformed lint attribute input
468464
469465
lint_map_unit_fn = `Iterator::map` call that discard the iterator's values
@@ -726,9 +722,6 @@ lint_redundant_semicolons_suggestion = remove {$multiple_semicolons ->
726722
*[false] this semicolon
727723
}
728724
729-
lint_reexport_private_dependency =
730-
{$kind} `{$name}` from private dependency '{$krate}' is re-exported
731-
732725
lint_remove_mut_from_pattern = remove `mut` from the parameter
733726
734727
lint_removed_lint = lint `{$name}` has been removed: {$reason}
@@ -966,15 +959,11 @@ lint_unused_imports = {$num_snippets ->
966959
}
967960
.help = if this is a test module, consider adding a `#[cfg(test)]` to the containing module
968961
969-
lint_unused_label = unused label
970-
971962
lint_unused_lifetime = lifetime parameter `{$ident}` never used
972963
.suggestion = elide the unused lifetime
973964
974965
lint_unused_macro_definition = unused macro definition: `{$name}`
975966
976-
lint_unused_macro_use = unused `#[macro_use]` import
977-
978967
lint_unused_op = unused {$op} that must be used
979968
.label = the {$op} produces a value
980969
.suggestion = use `let _ = ...` to ignore the resulting value

‎compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ pub fn decorate_builtin_lint(
308308
}
309309
.decorate_lint(diag);
310310
}
311-
BuiltinLintDiag::ReexportPrivateDependency { name, kind, krate } => {
312-
lints::ReexportPrivateDependency { name, kind, krate }.decorate_lint(diag);
313-
}
314311
BuiltinLintDiag::UnusedQualifications { removal_span } => {
315312
lints::UnusedQualifications { removal_span }.decorate_lint(diag);
316313
}
@@ -350,15 +347,10 @@ pub fn decorate_builtin_lint(
350347
});
351348
lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
352349
}
353-
BuiltinLintDiag::MacroUseDeprecated => {
354-
lints::MacroUseDeprecated.decorate_lint(diag);
355-
}
356-
BuiltinLintDiag::UnusedMacroUse => lints::UnusedMacroUse.decorate_lint(diag),
357350
BuiltinLintDiag::PrivateExternCrateReexport { source: ident, extern_crate_span } => {
358351
lints::PrivateExternCrateReexport { ident, sugg: extern_crate_span.shrink_to_lo() }
359352
.decorate_lint(diag);
360353
}
361-
BuiltinLintDiag::UnusedLabel => lints::UnusedLabel.decorate_lint(diag),
362354
BuiltinLintDiag::MacroIsPrivate(ident) => {
363355
lints::MacroIsPrivate { ident }.decorate_lint(diag);
364356
}

‎compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,15 +2535,6 @@ pub(crate) mod unexpected_cfg_value {
25352535
}
25362536
}
25372537

2538-
#[derive(LintDiagnostic)]
2539-
#[diag(lint_macro_use_deprecated)]
2540-
#[help]
2541-
pub(crate) struct MacroUseDeprecated;
2542-
2543-
#[derive(LintDiagnostic)]
2544-
#[diag(lint_unused_macro_use)]
2545-
pub(crate) struct UnusedMacroUse;
2546-
25472538
#[derive(LintDiagnostic)]
25482539
#[diag(lint_private_extern_crate_reexport, code = E0365)]
25492540
pub(crate) struct PrivateExternCrateReexport {
@@ -2552,10 +2543,6 @@ pub(crate) struct PrivateExternCrateReexport {
25522543
pub sugg: Span,
25532544
}
25542545

2555-
#[derive(LintDiagnostic)]
2556-
#[diag(lint_unused_label)]
2557-
pub(crate) struct UnusedLabel;
2558-
25592546
#[derive(LintDiagnostic)]
25602547
#[diag(lint_macro_is_private)]
25612548
pub(crate) struct MacroIsPrivate {
@@ -2957,14 +2944,6 @@ pub(crate) struct HiddenGlobReexports {
29572944
pub namespace: String,
29582945
}
29592946

2960-
#[derive(LintDiagnostic)]
2961-
#[diag(lint_reexport_private_dependency)]
2962-
pub(crate) struct ReexportPrivateDependency {
2963-
pub name: String,
2964-
pub kind: String,
2965-
pub krate: Symbol,
2966-
}
2967-
29682947
#[derive(LintDiagnostic)]
29692948
#[diag(lint_unnecessary_qualification)]
29702949
pub(crate) struct UnusedQualifications {

‎compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,6 @@ pub enum BuiltinLintDiag {
717717
/// The local binding that shadows the glob reexport.
718718
private_item_span: Span,
719719
},
720-
ReexportPrivateDependency {
721-
name: String,
722-
kind: String,
723-
krate: Symbol,
724-
},
725720
UnusedQualifications {
726721
/// The span of the unnecessarily-qualified path to remove.
727722
removal_span: Span,
@@ -744,13 +739,10 @@ pub enum BuiltinLintDiag {
744739
span: Span,
745740
typo_name: Option<Symbol>,
746741
},
747-
MacroUseDeprecated,
748-
UnusedMacroUse,
749742
PrivateExternCrateReexport {
750743
source: Ident,
751744
extern_crate_span: Span,
752745
},
753-
UnusedLabel,
754746
MacroIsPrivate(Ident),
755747
UnusedMacroDefinition(Symbol),
756748
MacroRuleNeverUsed(usize, Symbol),

‎compiler/rustc_resolve/messages.ftl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ resolve_macro_extern_deprecated =
274274
`#[macro_escape]` is a deprecated synonym for `#[macro_use]`
275275
.help = try an outer attribute: `#[macro_use]`
276276
277+
resolve_macro_use_deprecated =
278+
applying the `#[macro_use]` attribute to an `extern crate` item is deprecated
279+
.help = remove it and import macros at use sites with a `use` item instead
280+
277281
resolve_macro_use_extern_crate_self = `#[macro_use]` is not supported on `extern crate self`
278282
279283
resolve_macro_use_name_already_in_use =
@@ -357,6 +361,9 @@ resolve_reexport_of_crate_public =
357361
resolve_reexport_of_private =
358362
re-export of private `{$ident}`
359363
364+
resolve_reexport_private_dependency =
365+
{$kind} `{$name}` from private dependency '{$krate}' is re-exported
366+
360367
resolve_relative_2018 =
361368
relative paths are not supported in visibilities in 2018 edition or later
362369
.suggestion = try
@@ -478,6 +485,10 @@ resolve_unused_extern_crate = unused extern crate
478485
.label = unused
479486
.suggestion = remove the unused `extern crate`
480487
488+
resolve_unused_label = unused label
489+
490+
resolve_unused_macro_use = unused `#[macro_use]` import
491+
481492
resolve_variable_bound_with_different_mode =
482493
variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`
483494
.label = bound in different ways

‎compiler/rustc_resolve/src/check_unused.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl Resolver<'_, '_> {
406406
MACRO_USE_EXTERN_CRATE,
407407
import.root_id,
408408
import.span,
409-
BuiltinLintDiag::MacroUseDeprecated,
409+
crate::errors::MacroUseDeprecated,
410410
);
411411
}
412412
}
@@ -427,7 +427,7 @@ impl Resolver<'_, '_> {
427427
UNUSED_IMPORTS,
428428
import.root_id,
429429
import.span,
430-
BuiltinLintDiag::UnusedMacroUse,
430+
crate::errors::UnusedMacroUse,
431431
);
432432
}
433433
_ => {}

‎compiler/rustc_resolve/src/errors.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,3 +1296,24 @@ pub(crate) struct UnusedExternCrate {
12961296
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
12971297
pub removal_span: Span,
12981298
}
1299+
1300+
#[derive(LintDiagnostic)]
1301+
#[diag(resolve_reexport_private_dependency)]
1302+
pub(crate) struct ReexportPrivateDependency {
1303+
pub name: Symbol,
1304+
pub kind: &'static str,
1305+
pub krate: Symbol,
1306+
}
1307+
1308+
#[derive(LintDiagnostic)]
1309+
#[diag(resolve_unused_label)]
1310+
pub(crate) struct UnusedLabel;
1311+
1312+
#[derive(LintDiagnostic)]
1313+
#[diag(resolve_unused_macro_use)]
1314+
pub(crate) struct UnusedMacroUse;
1315+
1316+
#[derive(LintDiagnostic)]
1317+
#[diag(resolve_macro_use_deprecated)]
1318+
#[help]
1319+
pub(crate) struct MacroUseDeprecated;

‎compiler/rustc_resolve/src/imports.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
720720
EXPORTED_PRIVATE_DEPENDENCIES,
721721
binding_id,
722722
binding.span,
723-
BuiltinLintDiag::ReexportPrivateDependency {
724-
kind: binding.res().descr().to_string(),
725-
name: key.ident.name.to_string(),
723+
crate::errors::ReexportPrivateDependency {
724+
name: key.ident.name,
725+
kind: binding.res().descr(),
726726
krate: self.tcx.crate_name(reexported_def_id.krate),
727727
},
728728
);

‎compiler/rustc_resolve/src/late.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1;
3030
use rustc_middle::ty::{DelegationFnSig, Visibility};
3131
use rustc_middle::{bug, span_bug};
3232
use rustc_session::config::{CrateType, ResolveDocLinks};
33-
use rustc_session::lint::{self,BuiltinLintDiag};
33+
use rustc_session::lint;
3434
use rustc_session::parse::feature_err;
3535
use rustc_span::source_map::{Spanned, respan};
3636
use rustc_span::{BytePos, Ident, Span, Symbol, SyntaxContext, kw, sym};
@@ -5227,7 +5227,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
52275227
lint::builtin::UNUSED_LABELS,
52285228
*id,
52295229
*span,
5230-
BuiltinLintDiag::UnusedLabel,
5230+
errors::UnusedLabel,
52315231
);
52325232
}
52335233
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /