Skip to content

Commit cb75625

Browse files
Auto merge of #147634 - fmease:mv-var-to-dyn-buf-lints-next, r=<try>
Move even more early buffered lints to dyn lint diagnostics
2 parents f40a70d + 3bce608 commit cb75625

27 files changed

+248
-308
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,22 +2049,6 @@ pub fn elided_lifetime_in_path_suggestion(
20492049
ElidedLifetimeInPathSubdiag { expected, indicate }
20502050
}
20512051

2052-
pub fn report_ambiguity_error<'a, G: EmissionGuarantee>(
2053-
diag: &mut Diag<'a, G>,
2054-
ambiguity: rustc_lint_defs::AmbiguityErrorDiag,
2055-
) {
2056-
diag.span_label(ambiguity.label_span, ambiguity.label_msg);
2057-
diag.note(ambiguity.note_msg);
2058-
diag.span_note(ambiguity.b1_span, ambiguity.b1_note_msg);
2059-
for help_msg in ambiguity.b1_help_msgs {
2060-
diag.help(help_msg);
2061-
}
2062-
diag.span_note(ambiguity.b2_span, ambiguity.b2_note_msg);
2063-
for help_msg in ambiguity.b2_help_msgs {
2064-
diag.help(help_msg);
2065-
}
2066-
}
2067-
20682052
/// Grammatical tool for displaying messages to end users in a nice form.
20692053
///
20702054
/// Returns "an" if the given string starts with a vowel, and "a" otherwise.

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,6 @@ lint_expectation = this lint expectation is unfulfilled
257257
.note = the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
258258
.rationale = {$rationale}
259259
260-
lint_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition
261-
.suggestion = convert it to a `use`
262-
263260
lint_for_loops_over_fallibles =
264261
for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement
265262
.suggestion = consider using `if let` to clear intent
@@ -467,9 +464,6 @@ lint_lintpass_by_hand = implementing `LintPass` by hand
467464
lint_macro_expr_fragment_specifier_2024_migration =
468465
the `expr` fragment specifier will accept more expressions in the 2024 edition
469466
.suggestion = to keep the existing behavior, use the `expr_2021` fragment specifier
470-
lint_macro_is_private = macro `{$ident}` is private
471-
472-
lint_macro_rule_never_used = rule #{$n} of macro `{$name}` is never used
473467
474468
lint_malformed_attribute = malformed lint attribute input
475469
@@ -648,10 +642,6 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass
648642
649643
lint_opaque_hidden_inferred_bound_sugg = add this bound
650644
651-
lint_out_of_scope_macro_calls = cannot find macro `{$path}` in the current scope when looking from {$location}
652-
.label = not found from {$location}
653-
.help = import `macro_rules` with `use` to make it callable above its definition
654-
655645
lint_overflowing_bin_hex = literal out of range for `{$ty}`
656646
.negative_note = the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`
657647
.negative_becomes_note = and the value `-{$lit}` will become `{$actually}{$ty}`
@@ -687,9 +677,6 @@ lint_pattern_in_bodiless = patterns aren't allowed in functions without bodies
687677
lint_pattern_in_foreign = patterns aren't allowed in foreign function declarations
688678
.label = pattern not allowed in foreign function
689679
690-
lint_private_extern_crate_reexport = extern crate `{$ident}` is private and cannot be re-exported
691-
.suggestion = consider making the `extern crate` item publicly accessible
692-
693680
lint_query_instability = using `{$query}` can result in unstable query results
694681
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale
695682
@@ -715,10 +702,6 @@ lint_redundant_import = the item `{$ident}` is imported redundantly
715702
.label_imported_prelude = the item `{$ident}` is already imported by the extern prelude
716703
.label_defined_prelude = the item `{$ident}` is already defined by the extern prelude
717704
718-
lint_redundant_import_visibility = glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough
719-
.note = the most public imported item is `{$max_vis}`
720-
.help = reduce the glob import's visibility or increase visibility of imported items
721-
722705
lint_redundant_semicolons =
723706
unnecessary trailing {$multiple ->
724707
[true] semicolons
@@ -878,9 +861,6 @@ lint_unicode_text_flow = unicode codepoint changing visible direction of text pr
878861
lint_unit_bindings = binding has unit type `()`
879862
.label = this pattern is inferred to be the unit type `()`
880863
881-
lint_unknown_diagnostic_attribute = unknown diagnostic attribute
882-
lint_unknown_diagnostic_attribute_typo_sugg = an attribute with a similar name exists
883-
884864
lint_unknown_gated_lint =
885865
unknown lint: `{$name}`
886866
.note = the `{$name}` lint is unstable
@@ -962,8 +942,6 @@ lint_unused_imports = {$num_snippets ->
962942
lint_unused_lifetime = lifetime parameter `{$ident}` never used
963943
.suggestion = elide the unused lifetime
964944
965-
lint_unused_macro_definition = unused macro definition: `{$name}`
966-
967945
lint_unused_op = unused {$op} that must be used
968946
.label = the {$op} produces a value
969947
.suggestion = use `let _ = ...` to ignore the resulting value

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@ pub fn decorate_builtin_lint(
251251
}
252252
.decorate_lint(diag);
253253
}
254-
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
255-
let suggestion_span = vis_span.between(ident_span);
256-
let code = if vis_span.is_empty() { "use " } else { " use " };
257-
258-
lints::ExternCrateNotIdiomatic { span: suggestion_span, code }.decorate_lint(diag);
259-
}
260-
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
261-
lints::AmbiguousGlobImports { ambiguity }.decorate_lint(diag);
262-
}
263254
BuiltinLintDiag::AmbiguousGlobReexports {
264255
name,
265256
namespace,
@@ -317,33 +308,6 @@ pub fn decorate_builtin_lint(
317308
}
318309
.decorate_lint(diag);
319310
}
320-
BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => {
321-
lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis }
322-
.decorate_lint(diag);
323-
}
324-
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
325-
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
326-
span: typo_span,
327-
typo_name,
328-
});
329-
lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
330-
}
331-
BuiltinLintDiag::PrivateExternCrateReexport { source: ident, extern_crate_span } => {
332-
lints::PrivateExternCrateReexport { ident, sugg: extern_crate_span.shrink_to_lo() }
333-
.decorate_lint(diag);
334-
}
335-
BuiltinLintDiag::MacroIsPrivate(ident) => {
336-
lints::MacroIsPrivate { ident }.decorate_lint(diag);
337-
}
338-
BuiltinLintDiag::UnusedMacroDefinition(name) => {
339-
lints::UnusedMacroDefinition { name }.decorate_lint(diag);
340-
}
341-
BuiltinLintDiag::MacroRuleNeverUsed(n, name) => {
342-
lints::MacroRuleNeverUsed { n: n + 1, name }.decorate_lint(diag);
343-
}
344-
BuiltinLintDiag::UnstableFeature(msg) => {
345-
lints::UnstableFeature { msg }.decorate_lint(diag);
346-
}
347311
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => {
348312
lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag)
349313
}
@@ -358,8 +322,5 @@ pub fn decorate_builtin_lint(
358322
}
359323
.decorate_lint(diag)
360324
}
361-
BuiltinLintDiag::OutOfScopeMacroCalls { span, path, location } => {
362-
lints::OutOfScopeMacroCalls { span, path, location }.decorate_lint(diag)
363-
}
364325
}
365326
}

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_macros::{LintDiagnostic, Subdiagnostic};
1515
use rustc_middle::ty::inhabitedness::InhabitedPredicate;
1616
use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
1717
use rustc_session::Session;
18-
use rustc_session::lint::AmbiguityErrorDiag;
1918
use rustc_span::edition::Edition;
2019
use rustc_span::{Ident, Span, Symbol, sym};
2120

@@ -2575,43 +2574,6 @@ pub(crate) mod unexpected_cfg_value {
25752574
}
25762575
}
25772576

2578-
#[derive(LintDiagnostic)]
2579-
#[diag(lint_private_extern_crate_reexport, code = E0365)]
2580-
pub(crate) struct PrivateExternCrateReexport {
2581-
pub ident: Ident,
2582-
#[suggestion(code = "pub ", style = "verbose", applicability = "maybe-incorrect")]
2583-
pub sugg: Span,
2584-
}
2585-
2586-
#[derive(LintDiagnostic)]
2587-
#[diag(lint_macro_is_private)]
2588-
pub(crate) struct MacroIsPrivate {
2589-
pub ident: Ident,
2590-
}
2591-
2592-
#[derive(LintDiagnostic)]
2593-
#[diag(lint_unused_macro_definition)]
2594-
pub(crate) struct UnusedMacroDefinition {
2595-
pub name: Symbol,
2596-
}
2597-
2598-
#[derive(LintDiagnostic)]
2599-
#[diag(lint_macro_rule_never_used)]
2600-
pub(crate) struct MacroRuleNeverUsed {
2601-
pub n: usize,
2602-
pub name: Symbol,
2603-
}
2604-
2605-
pub(crate) struct UnstableFeature {
2606-
pub msg: DiagMessage,
2607-
}
2608-
2609-
impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
2610-
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
2611-
diag.primary_message(self.msg);
2612-
}
2613-
}
2614-
26152577
#[derive(LintDiagnostic)]
26162578
#[diag(lint_unused_crate_dependency)]
26172579
#[help]
@@ -2631,26 +2593,6 @@ pub(crate) struct IllFormedAttributeInput {
26312593
pub docs: &'static str,
26322594
}
26332595

2634-
#[derive(LintDiagnostic)]
2635-
#[diag(lint_unknown_diagnostic_attribute)]
2636-
pub(crate) struct UnknownDiagnosticAttribute {
2637-
#[subdiagnostic]
2638-
pub typo: Option<UnknownDiagnosticAttributeTypoSugg>,
2639-
}
2640-
2641-
#[derive(Subdiagnostic)]
2642-
#[suggestion(
2643-
lint_unknown_diagnostic_attribute_typo_sugg,
2644-
style = "verbose",
2645-
code = "{typo_name}",
2646-
applicability = "machine-applicable"
2647-
)]
2648-
pub(crate) struct UnknownDiagnosticAttributeTypoSugg {
2649-
#[primary_span]
2650-
pub span: Span,
2651-
pub typo_name: Symbol,
2652-
}
2653-
26542596
#[derive(LintDiagnostic)]
26552597
#[diag(lint_unicode_text_flow)]
26562598
#[note]
@@ -2893,27 +2835,6 @@ pub(crate) struct NamedArgumentUsedPositionally {
28932835
pub named_arg_name: String,
28942836
}
28952837

2896-
#[derive(LintDiagnostic)]
2897-
#[diag(lint_extern_crate_not_idiomatic)]
2898-
pub(crate) struct ExternCrateNotIdiomatic {
2899-
#[suggestion(style = "verbose", code = "{code}", applicability = "machine-applicable")]
2900-
pub span: Span,
2901-
2902-
pub code: &'static str,
2903-
}
2904-
2905-
// FIXME: make this translatable
2906-
pub(crate) struct AmbiguousGlobImports {
2907-
pub ambiguity: AmbiguityErrorDiag,
2908-
}
2909-
2910-
impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for AmbiguousGlobImports {
2911-
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
2912-
diag.primary_message(self.ambiguity.msg.clone());
2913-
rustc_errors::report_ambiguity_error(diag, self.ambiguity);
2914-
}
2915-
}
2916-
29172838
#[derive(LintDiagnostic)]
29182839
#[diag(lint_ambiguous_glob_reexport)]
29192840
pub(crate) struct AmbiguousGlobReexports {
@@ -2959,18 +2880,6 @@ pub(crate) struct AssociatedConstElidedLifetime {
29592880
pub lifetimes_in_scope: MultiSpan,
29602881
}
29612882

2962-
#[derive(LintDiagnostic)]
2963-
#[diag(lint_redundant_import_visibility)]
2964-
pub(crate) struct RedundantImportVisibility {
2965-
#[note]
2966-
pub span: Span,
2967-
#[help]
2968-
pub help: (),
2969-
2970-
pub import_vis: String,
2971-
pub max_vis: String,
2972-
}
2973-
29742883
#[derive(LintDiagnostic)]
29752884
#[diag(lint_unsafe_attr_outside_unsafe)]
29762885
pub(crate) struct UnsafeAttrOutsideUnsafe {
@@ -2992,16 +2901,6 @@ pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
29922901
pub right: Span,
29932902
}
29942903

2995-
#[derive(LintDiagnostic)]
2996-
#[diag(lint_out_of_scope_macro_calls)]
2997-
#[help]
2998-
pub(crate) struct OutOfScopeMacroCalls {
2999-
#[label]
3000-
pub span: Span,
3001-
pub path: String,
3002-
pub location: String,
3003-
}
3004-
30052904
#[derive(LintDiagnostic)]
30062905
#[diag(lint_static_mut_refs_lint)]
30072906
pub(crate) struct RefOfMutStatic<'a> {

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxIndexSet;
66
use rustc_data_structures::stable_hasher::{
77
HashStable, StableCompare, StableHasher, ToStableHashKey,
88
};
9-
use rustc_error_messages::{DiagArgValue, DiagMessage, IntoDiagArg, MultiSpan};
9+
use rustc_error_messages::{DiagArgValue, IntoDiagArg, MultiSpan};
1010
use rustc_hir_id::{HashStableContext, HirId, ItemLocalId};
1111
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1212
use rustc_span::def_id::DefPathHash;
@@ -593,21 +593,6 @@ impl StableCompare for LintId {
593593
}
594594
}
595595

596-
#[derive(Debug)]
597-
pub struct AmbiguityErrorDiag {
598-
pub msg: String,
599-
pub span: Span,
600-
pub label_span: Span,
601-
pub label_msg: String,
602-
pub note_msg: String,
603-
pub b1_span: Span,
604-
pub b1_note_msg: String,
605-
pub b1_help_msgs: Vec<String>,
606-
pub b2_span: Span,
607-
pub b2_note_msg: String,
608-
pub b2_help_msgs: Vec<String>,
609-
}
610-
611596
#[derive(Debug, Clone)]
612597
pub enum DeprecatedSinceKind {
613598
InEffect,
@@ -678,13 +663,6 @@ pub enum BuiltinLintDiag {
678663
/// Indicates if the named argument is used as a width/precision for formatting
679664
is_formatting_arg: bool,
680665
},
681-
ExternCrateNotIdiomatic {
682-
vis_span: Span,
683-
ident_span: Span,
684-
},
685-
AmbiguousGlobImports {
686-
diag: AmbiguityErrorDiag,
687-
},
688666
AmbiguousGlobReexports {
689667
/// The name for which collision(s) have occurred.
690668
name: String,
@@ -718,23 +696,6 @@ pub enum BuiltinLintDiag {
718696
span: Span,
719697
lifetimes_in_scope: MultiSpan,
720698
},
721-
RedundantImportVisibility {
722-
span: Span,
723-
max_vis: String,
724-
import_vis: String,
725-
},
726-
UnknownDiagnosticAttribute {
727-
span: Span,
728-
typo_name: Option<Symbol>,
729-
},
730-
PrivateExternCrateReexport {
731-
source: Ident,
732-
extern_crate_span: Span,
733-
},
734-
MacroIsPrivate(Ident),
735-
UnusedMacroDefinition(Symbol),
736-
MacroRuleNeverUsed(usize, Symbol),
737-
UnstableFeature(DiagMessage),
738699
UnusedCrateDependency {
739700
extern_crate: Symbol,
740701
local_crate: Symbol,
@@ -743,11 +704,6 @@ pub enum BuiltinLintDiag {
743704
suggestions: Vec<String>,
744705
docs: Option<&'static str>,
745706
},
746-
OutOfScopeMacroCalls {
747-
span: Span,
748-
path: String,
749-
location: String,
750-
},
751707
}
752708

753709
pub type RegisteredTools = FxIndexSet<Ident>;

0 commit comments

Comments
 (0)