Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2035,22 +2035,6 @@ pub fn elided_lifetime_in_path_suggestion(
ElidedLifetimeInPathSubdiag { expected, indicate }
}

pub fn report_ambiguity_error<'a, G: EmissionGuarantee>(
diag: &mut Diag<'a, G>,
ambiguity: rustc_lint_defs::AmbiguityErrorDiag,
) {
diag.span_label(ambiguity.label_span, ambiguity.label_msg);
diag.note(ambiguity.note_msg);
diag.span_note(ambiguity.b1_span, ambiguity.b1_note_msg);
for help_msg in ambiguity.b1_help_msgs {
diag.help(help_msg);
}
diag.span_note(ambiguity.b2_span, ambiguity.b2_note_msg);
for help_msg in ambiguity.b2_help_msgs {
diag.help(help_msg);
}
}

/// Grammatical tool for displaying messages to end users in a nice form.
///
/// Returns "an" if the given string starts with a vowel, and "a" otherwise.
Expand Down
22 changes: 0 additions & 22 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ lint_expectation = this lint expectation is unfulfilled
.note = the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
.rationale = {$rationale}

lint_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition
.suggestion = convert it to a `use`

lint_for_loops_over_fallibles =
for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement
.suggestion = consider using `if let` to clear intent
Expand Down Expand Up @@ -453,9 +450,6 @@ lint_lintpass_by_hand = implementing `LintPass` by hand
lint_macro_expr_fragment_specifier_2024_migration =
the `expr` fragment specifier will accept more expressions in the 2024 edition
.suggestion = to keep the existing behavior, use the `expr_2021` fragment specifier
lint_macro_is_private = macro `{$ident}` is private

lint_macro_rule_never_used = rule #{$n} of macro `{$name}` is never used

lint_malformed_attribute = malformed lint attribute input

Expand Down Expand Up @@ -634,10 +628,6 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass

lint_opaque_hidden_inferred_bound_sugg = add this bound

lint_out_of_scope_macro_calls = cannot find macro `{$path}` in the current scope when looking from {$location}
.label = not found from {$location}
.help = import `macro_rules` with `use` to make it callable above its definition

lint_overflowing_bin_hex = literal out of range for `{$ty}`
.negative_note = the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`
.negative_becomes_note = and the value `-{$lit}` will become `{$actually}{$ty}`
Expand Down Expand Up @@ -673,9 +663,6 @@ lint_pattern_in_bodiless = patterns aren't allowed in functions without bodies
lint_pattern_in_foreign = patterns aren't allowed in foreign function declarations
.label = pattern not allowed in foreign function

lint_private_extern_crate_reexport = extern crate `{$ident}` is private and cannot be re-exported
.suggestion = consider making the `extern crate` item publicly accessible

lint_query_instability = using `{$query}` can result in unstable query results
.note = if you believe this case to be fine, allow this lint and add a comment explaining your rationale

Expand All @@ -701,10 +688,6 @@ lint_redundant_import = the item `{$ident}` is imported redundantly
.label_imported_prelude = the item `{$ident}` is already imported by the extern prelude
.label_defined_prelude = the item `{$ident}` is already defined by the extern prelude

lint_redundant_import_visibility = glob import doesn't reexport anything with visibility `{$import_vis}` because no imported item is public enough
.note = the most public imported item is `{$max_vis}`
.help = reduce the glob import's visibility or increase visibility of imported items

lint_redundant_semicolons =
unnecessary trailing {$multiple ->
[true] semicolons
Expand Down Expand Up @@ -864,9 +847,6 @@ lint_unicode_text_flow = unicode codepoint changing visible direction of text pr
lint_unit_bindings = binding has unit type `()`
.label = this pattern is inferred to be the unit type `()`

lint_unknown_diagnostic_attribute = unknown diagnostic attribute
lint_unknown_diagnostic_attribute_typo_sugg = an attribute with a similar name exists

lint_unknown_gated_lint =
unknown lint: `{$name}`
.note = the `{$name}` lint is unstable
Expand Down Expand Up @@ -948,8 +928,6 @@ lint_unused_imports = {$num_snippets ->
lint_unused_lifetime = lifetime parameter `{$ident}` never used
.suggestion = elide the unused lifetime

lint_unused_macro_definition = unused macro definition: `{$name}`

lint_unused_op = unused {$op} that must be used
.label = the {$op} produces a value
.suggestion = use `let _ = ...` to ignore the resulting value
Expand Down
39 changes: 0 additions & 39 deletions compiler/rustc_lint/src/early/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,6 @@ pub fn decorate_builtin_lint(
}
.decorate_lint(diag);
}
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
let suggestion_span = vis_span.between(ident_span);
let code = if vis_span.is_empty() { "use " } else { " use " };

lints::ExternCrateNotIdiomatic { span: suggestion_span, code }.decorate_lint(diag);
}
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
lints::AmbiguousGlobImports { ambiguity }.decorate_lint(diag);
}
BuiltinLintDiag::AmbiguousGlobReexports {
name,
namespace,
Expand Down Expand Up @@ -317,33 +308,6 @@ pub fn decorate_builtin_lint(
}
.decorate_lint(diag);
}
BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => {
lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis }
.decorate_lint(diag);
}
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
span: typo_span,
typo_name,
});
lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
}
BuiltinLintDiag::PrivateExternCrateReexport { source: ident, extern_crate_span } => {
lints::PrivateExternCrateReexport { ident, sugg: extern_crate_span.shrink_to_lo() }
.decorate_lint(diag);
}
BuiltinLintDiag::MacroIsPrivate(ident) => {
lints::MacroIsPrivate { ident }.decorate_lint(diag);
}
BuiltinLintDiag::UnusedMacroDefinition(name) => {
lints::UnusedMacroDefinition { name }.decorate_lint(diag);
}
BuiltinLintDiag::MacroRuleNeverUsed(n, name) => {
lints::MacroRuleNeverUsed { n: n + 1, name }.decorate_lint(diag);
}
BuiltinLintDiag::UnstableFeature(msg) => {
lints::UnstableFeature { msg }.decorate_lint(diag);
}
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => {
lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag)
}
Expand All @@ -358,8 +322,5 @@ pub fn decorate_builtin_lint(
}
.decorate_lint(diag)
}
BuiltinLintDiag::OutOfScopeMacroCalls { span, path, location } => {
lints::OutOfScopeMacroCalls { span, path, location }.decorate_lint(diag)
}
}
}
101 changes: 0 additions & 101 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use rustc_macros::{LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::inhabitedness::InhabitedPredicate;
use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
use rustc_session::Session;
use rustc_session::lint::AmbiguityErrorDiag;
use rustc_span::edition::Edition;
use rustc_span::{Ident, Span, Symbol, sym};

Expand Down Expand Up @@ -2535,43 +2534,6 @@ pub(crate) mod unexpected_cfg_value {
}
}

#[derive(LintDiagnostic)]
#[diag(lint_private_extern_crate_reexport, code = E0365)]
pub(crate) struct PrivateExternCrateReexport {
pub ident: Ident,
#[suggestion(code = "pub ", style = "verbose", applicability = "maybe-incorrect")]
pub sugg: Span,
}

#[derive(LintDiagnostic)]
#[diag(lint_macro_is_private)]
pub(crate) struct MacroIsPrivate {
pub ident: Ident,
}

#[derive(LintDiagnostic)]
#[diag(lint_unused_macro_definition)]
pub(crate) struct UnusedMacroDefinition {
pub name: Symbol,
}

#[derive(LintDiagnostic)]
#[diag(lint_macro_rule_never_used)]
pub(crate) struct MacroRuleNeverUsed {
pub n: usize,
pub name: Symbol,
}

pub(crate) struct UnstableFeature {
pub msg: DiagMessage,
}

impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
diag.primary_message(self.msg);
}
}

#[derive(LintDiagnostic)]
#[diag(lint_unused_crate_dependency)]
#[help]
Expand All @@ -2591,26 +2553,6 @@ pub(crate) struct IllFormedAttributeInput {
pub docs: &'static str,
}

#[derive(LintDiagnostic)]
#[diag(lint_unknown_diagnostic_attribute)]
pub(crate) struct UnknownDiagnosticAttribute {
#[subdiagnostic]
pub typo: Option<UnknownDiagnosticAttributeTypoSugg>,
}

#[derive(Subdiagnostic)]
#[suggestion(
lint_unknown_diagnostic_attribute_typo_sugg,
style = "verbose",
code = "{typo_name}",
applicability = "machine-applicable"
)]
pub(crate) struct UnknownDiagnosticAttributeTypoSugg {
#[primary_span]
pub span: Span,
pub typo_name: Symbol,
}

#[derive(LintDiagnostic)]
#[diag(lint_unicode_text_flow)]
#[note]
Expand Down Expand Up @@ -2853,27 +2795,6 @@ pub(crate) struct NamedArgumentUsedPositionally {
pub named_arg_name: String,
}

#[derive(LintDiagnostic)]
#[diag(lint_extern_crate_not_idiomatic)]
pub(crate) struct ExternCrateNotIdiomatic {
#[suggestion(style = "verbose", code = "{code}", applicability = "machine-applicable")]
pub span: Span,

pub code: &'static str,
}

// FIXME: make this translatable
pub(crate) struct AmbiguousGlobImports {
pub ambiguity: AmbiguityErrorDiag,
}

impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for AmbiguousGlobImports {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
diag.primary_message(self.ambiguity.msg.clone());
rustc_errors::report_ambiguity_error(diag, self.ambiguity);
}
}

#[derive(LintDiagnostic)]
#[diag(lint_ambiguous_glob_reexport)]
pub(crate) struct AmbiguousGlobReexports {
Expand Down Expand Up @@ -2919,18 +2840,6 @@ pub(crate) struct AssociatedConstElidedLifetime {
pub lifetimes_in_scope: MultiSpan,
}

#[derive(LintDiagnostic)]
#[diag(lint_redundant_import_visibility)]
pub(crate) struct RedundantImportVisibility {
#[note]
pub span: Span,
#[help]
pub help: (),

pub import_vis: String,
pub max_vis: String,
}

#[derive(LintDiagnostic)]
#[diag(lint_unsafe_attr_outside_unsafe)]
pub(crate) struct UnsafeAttrOutsideUnsafe {
Expand All @@ -2952,16 +2861,6 @@ pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
pub right: Span,
}

#[derive(LintDiagnostic)]
#[diag(lint_out_of_scope_macro_calls)]
#[help]
pub(crate) struct OutOfScopeMacroCalls {
#[label]
pub span: Span,
pub path: String,
pub location: String,
}

#[derive(LintDiagnostic)]
#[diag(lint_static_mut_refs_lint)]
pub(crate) struct RefOfMutStatic<'a> {
Expand Down
46 changes: 1 addition & 45 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::stable_hasher::{
HashStable, StableCompare, StableHasher, ToStableHashKey,
};
use rustc_error_messages::{DiagArgValue, DiagMessage, IntoDiagArg, MultiSpan};
use rustc_error_messages::{DiagArgValue, IntoDiagArg, MultiSpan};
use rustc_hir_id::{HashStableContext, HirId, ItemLocalId};
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::def_id::DefPathHash;
Expand Down Expand Up @@ -593,21 +593,6 @@ impl StableCompare for LintId {
}
}

#[derive(Debug)]
pub struct AmbiguityErrorDiag {
pub msg: String,
pub span: Span,
pub label_span: Span,
pub label_msg: String,
pub note_msg: String,
pub b1_span: Span,
pub b1_note_msg: String,
pub b1_help_msgs: Vec<String>,
pub b2_span: Span,
pub b2_note_msg: String,
pub b2_help_msgs: Vec<String>,
}

#[derive(Debug, Clone)]
pub enum DeprecatedSinceKind {
InEffect,
Expand Down Expand Up @@ -678,13 +663,6 @@ pub enum BuiltinLintDiag {
/// Indicates if the named argument is used as a width/precision for formatting
is_formatting_arg: bool,
},
ExternCrateNotIdiomatic {
vis_span: Span,
ident_span: Span,
},
AmbiguousGlobImports {
diag: AmbiguityErrorDiag,
},
AmbiguousGlobReexports {
/// The name for which collision(s) have occurred.
name: String,
Expand Down Expand Up @@ -718,23 +696,6 @@ pub enum BuiltinLintDiag {
span: Span,
lifetimes_in_scope: MultiSpan,
},
RedundantImportVisibility {
span: Span,
max_vis: String,
import_vis: String,
},
UnknownDiagnosticAttribute {
span: Span,
typo_name: Option<Symbol>,
},
PrivateExternCrateReexport {
source: Ident,
extern_crate_span: Span,
},
MacroIsPrivate(Ident),
UnusedMacroDefinition(Symbol),
MacroRuleNeverUsed(usize, Symbol),
UnstableFeature(DiagMessage),
UnusedCrateDependency {
extern_crate: Symbol,
local_crate: Symbol,
Expand All @@ -743,11 +704,6 @@ pub enum BuiltinLintDiag {
suggestions: Vec<String>,
docs: Option<&'static str>,
},
OutOfScopeMacroCalls {
span: Span,
path: String,
location: String,
},
}

pub type RegisteredTools = FxIndexSet<Ident>;
Expand Down
Loading
Loading