Move more early buffered lints to dyn lint diagnostics (2/N)
This commit is contained in:
parent
2e816736ef
commit
31c0d96cb6
14 changed files with 50 additions and 71 deletions
|
|
@ -216,6 +216,10 @@ ast_passes_match_arm_with_no_body =
|
|||
.suggestion = add a body after the pattern
|
||||
|
||||
ast_passes_missing_unsafe_on_extern = extern blocks must be unsafe
|
||||
.suggestion = needs `unsafe` before the extern keyword
|
||||
|
||||
ast_passes_missing_unsafe_on_extern_lint = extern blocks should be unsafe
|
||||
.suggestion = needs `unsafe` before the extern keyword
|
||||
|
||||
ast_passes_module_nonascii = trying to load file for module `{$name}` with non-ascii identifier name
|
||||
.help = consider using the `#[path]` attribute to specify filesystem path
|
||||
|
|
|
|||
|
|
@ -1131,7 +1131,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
MISSING_UNSAFE_ON_EXTERN,
|
||||
item.id,
|
||||
item.span,
|
||||
BuiltinLintDiag::MissingUnsafeOnExtern {
|
||||
errors::MissingUnsafeOnExternLint {
|
||||
suggestion: item.span.shrink_to_lo(),
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -523,6 +523,13 @@ pub(crate) struct MissingUnsafeOnExtern {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(ast_passes_missing_unsafe_on_extern_lint)]
|
||||
pub(crate) struct MissingUnsafeOnExternLint {
|
||||
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(ast_passes_fieldless_union)]
|
||||
pub(crate) struct FieldlessUnion {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ expand_macro_body_stability =
|
|||
.label = invalid body stability attribute
|
||||
.label2 = body stability attribute affects this macro
|
||||
|
||||
expand_macro_call_unused_doc_comment = unused doc comment
|
||||
.label = rustdoc does not generate documentation for macro invocations
|
||||
.help = to document an item produced by a macro, the macro must produce the documentation as part of its expansion
|
||||
|
||||
expand_macro_const_stability =
|
||||
macros cannot have const stability attributes
|
||||
.label = invalid const stability attribute
|
||||
|
|
|
|||
|
|
@ -537,3 +537,11 @@ pub(crate) struct MacroArgsBadDelimSugg {
|
|||
#[suggestion_part(code = ")")]
|
||||
pub close: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_macro_call_unused_doc_comment)]
|
||||
#[help]
|
||||
pub(crate) struct MacroCallUnusedDocComment {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2183,7 +2183,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
UNUSED_DOC_COMMENTS,
|
||||
current_span,
|
||||
self.cx.current_expansion.lint_node_id,
|
||||
BuiltinLintDiag::UnusedDocComment(attr.span),
|
||||
crate::errors::MacroCallUnusedDocComment { span: attr.span },
|
||||
);
|
||||
} else if rustc_attr_parsing::is_builtin_attr(attr)
|
||||
&& !AttributeParser::<Early>::is_parsed_attribute(&attr.path())
|
||||
|
|
|
|||
|
|
@ -453,9 +453,6 @@ lint_int_to_ptr_transmutes = transmuting an integer to a pointer creates a point
|
|||
.suggestion_with_exposed_provenance = use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance
|
||||
.suggestion_without_provenance_mut = if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
|
||||
|
||||
lint_legacy_derive_helpers = derive helper attribute is used before it is introduced
|
||||
.label = the attribute is introduced here
|
||||
|
||||
lint_lintpass_by_hand = implementing `LintPass` by hand
|
||||
.help = try using `declare_lint_pass!` or `impl_lint_pass!` instead
|
||||
|
||||
|
|
@ -524,9 +521,6 @@ lint_mismatched_lifetime_syntaxes_suggestion_mixed =
|
|||
lint_mismatched_lifetime_syntaxes_suggestion_mixed_only_paths =
|
||||
use `'_` for type paths
|
||||
|
||||
lint_missing_unsafe_on_extern = extern blocks should be unsafe
|
||||
.suggestion = needs `unsafe` before the extern keyword
|
||||
|
||||
lint_mixed_script_confusables =
|
||||
the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables
|
||||
.includes_note = the usage includes {$includes}
|
||||
|
|
@ -962,14 +956,6 @@ lint_unused_def = unused {$pre}`{$def}`{$post} that must be used
|
|||
lint_unused_delim = unnecessary {$delim} around {$item}
|
||||
.suggestion = remove these {$delim}
|
||||
|
||||
lint_unused_doc_comment = unused doc comment
|
||||
.label = rustdoc does not generate documentation for macro invocations
|
||||
.help = to document an item produced by a macro, the macro must produce the documentation as part of its expansion
|
||||
|
||||
lint_unused_extern_crate = unused extern crate
|
||||
.label = unused
|
||||
.suggestion = remove the unused `extern crate`
|
||||
|
||||
lint_unused_import_braces = braces around {$node} is unnecessary
|
||||
|
||||
lint_unused_imports = {$num_snippets ->
|
||||
|
|
|
|||
|
|
@ -135,9 +135,6 @@ pub fn decorate_builtin_lint(
|
|||
stability::Deprecated { sub, kind: "macro".to_owned(), path, note, since_kind }
|
||||
.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::UnusedDocComment(attr_span) => {
|
||||
lints::UnusedDocComment { span: attr_span }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => {
|
||||
let sub = lints::PatternsInFnsWithoutBodySub { ident, span: remove_span };
|
||||
if is_foreign {
|
||||
|
|
@ -147,9 +144,6 @@ pub fn decorate_builtin_lint(
|
|||
}
|
||||
.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
|
||||
lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::OrPatternsBackCompat(suggestion_span, suggestion) => {
|
||||
lints::OrPatternsBackCompat { span: suggestion_span, suggestion }.decorate_lint(diag);
|
||||
}
|
||||
|
|
@ -210,9 +204,6 @@ pub fn decorate_builtin_lint(
|
|||
};
|
||||
lints::DeprecatedWhereClauseLocation { suggestion }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::MissingUnsafeOnExtern { suggestion } => {
|
||||
lints::MissingUnsafeOnExtern { suggestion }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::SingleUseLifetime {
|
||||
param_span,
|
||||
use_span: Some((use_span, elide)),
|
||||
|
|
@ -242,7 +233,6 @@ pub fn decorate_builtin_lint(
|
|||
.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
|
||||
debug!(?deletion_span);
|
||||
lints::UnusedLifetime { deletion_span, ident }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::NamedArgumentUsedPositionally {
|
||||
|
|
@ -283,9 +273,6 @@ pub fn decorate_builtin_lint(
|
|||
BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => {
|
||||
lints::ByteSliceInPackedStructWithDerive { ty }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::UnusedExternCrate { span, removal_span } => {
|
||||
lints::UnusedExternCrate { span, removal_span }.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 " };
|
||||
|
|
|
|||
|
|
@ -2749,14 +2749,6 @@ pub(crate) enum RedundantImportSub {
|
|||
DefinedPrelude(#[primary_span] Span),
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unused_doc_comment)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedDocComment {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
pub(crate) enum PatternsInFnsWithoutBody {
|
||||
#[diag(lint_pattern_in_foreign)]
|
||||
|
|
@ -2780,13 +2772,6 @@ pub(crate) struct PatternsInFnsWithoutBodySub {
|
|||
pub ident: Ident,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_legacy_derive_helpers)]
|
||||
pub(crate) struct LegacyDeriveHelpers {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_or_patterns_back_compat)]
|
||||
pub(crate) struct OrPatternsBackCompat {
|
||||
|
|
@ -2878,13 +2863,6 @@ pub(crate) enum DeprecatedWhereClauseLocationSugg {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_missing_unsafe_on_extern)]
|
||||
pub(crate) struct MissingUnsafeOnExtern {
|
||||
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_single_use_lifetime)]
|
||||
pub(crate) struct SingleUseLifetime {
|
||||
|
|
@ -2940,15 +2918,6 @@ pub(crate) struct ByteSliceInPackedStructWithDerive {
|
|||
pub ty: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unused_extern_crate)]
|
||||
pub(crate) struct UnusedExternCrate {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
|
||||
pub removal_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_extern_crate_not_idiomatic)]
|
||||
pub(crate) struct ExternCrateNotIdiomatic {
|
||||
|
|
|
|||
|
|
@ -640,7 +640,6 @@ pub enum BuiltinLintDiag {
|
|||
path: String,
|
||||
since_kind: DeprecatedSinceKind,
|
||||
},
|
||||
UnusedDocComment(Span),
|
||||
UnusedBuiltinAttribute {
|
||||
attr_name: Symbol,
|
||||
macro_name: String,
|
||||
|
|
@ -652,7 +651,6 @@ pub enum BuiltinLintDiag {
|
|||
ident: Ident,
|
||||
is_foreign: bool,
|
||||
},
|
||||
LegacyDeriveHelpers(Span),
|
||||
OrPatternsBackCompat(Span, String),
|
||||
ReservedPrefix(Span, String),
|
||||
/// `'r#` in edition < 2021.
|
||||
|
|
@ -668,9 +666,6 @@ pub enum BuiltinLintDiag {
|
|||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||
DeprecatedWhereclauseLocation(Span, Option<(Span, String)>),
|
||||
MissingUnsafeOnExtern {
|
||||
suggestion: Span,
|
||||
},
|
||||
SingleUseLifetime {
|
||||
/// Span of the parameter which declares this lifetime.
|
||||
param_span: Span,
|
||||
|
|
@ -699,10 +694,6 @@ pub enum BuiltinLintDiag {
|
|||
// FIXME: enum of byte/string
|
||||
ty: String,
|
||||
},
|
||||
UnusedExternCrate {
|
||||
span: Span,
|
||||
removal_span: Span,
|
||||
},
|
||||
ExternCrateNotIdiomatic {
|
||||
vis_span: Span,
|
||||
ident_span: Span,
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ resolve_item_was_cfg_out = the item is gated here
|
|||
resolve_label_with_similar_name_reachable =
|
||||
a label with a similar name is reachable
|
||||
|
||||
resolve_legacy_derive_helpers = derive helper attribute is used before it is introduced
|
||||
.label = the attribute is introduced here
|
||||
|
||||
resolve_lending_iterator_report_error =
|
||||
associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
|
||||
.note = you can't create an `Iterator` that borrows each `Item` from itself, but you can instead create a new type that borrows your existing type and implement `Iterator` for that new type
|
||||
|
|
@ -471,6 +474,10 @@ resolve_unreachable_label_suggestion_use_similarly_named =
|
|||
resolve_unreachable_label_with_similar_name_exists =
|
||||
a label with a similar name exists but is unreachable
|
||||
|
||||
resolve_unused_extern_crate = unused extern crate
|
||||
.label = unused
|
||||
.suggestion = remove the unused `extern crate`
|
||||
|
||||
resolve_variable_bound_with_different_mode =
|
||||
variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`
|
||||
.label = bound in different ways
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
|
|||
UNUSED_EXTERN_CRATES,
|
||||
extern_crate.id,
|
||||
span,
|
||||
BuiltinLintDiag::UnusedExternCrate {
|
||||
crate::errors::UnusedExternCrate {
|
||||
span: extern_crate.span,
|
||||
removal_span: extern_crate.span_with_attributes,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1292,3 +1292,19 @@ pub(crate) struct TraitImplMismatch {
|
|||
#[label(resolve_trait_impl_mismatch_label_item)]
|
||||
pub(crate) trait_item_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(resolve_legacy_derive_helpers)]
|
||||
pub(crate) struct LegacyDeriveHelpers {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(resolve_unused_extern_crate)]
|
||||
pub(crate) struct UnusedExternCrate {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
|
||||
pub removal_span: Span,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
LEGACY_DERIVE_HELPERS,
|
||||
node_id,
|
||||
ident.span,
|
||||
BuiltinLintDiag::LegacyDeriveHelpers(binding.span),
|
||||
errors::LegacyDeriveHelpers { span: binding.span },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue