Move more early buffered lints to dyn lint diagnostics (1/N)
This commit is contained in:
parent
a015919e54
commit
2e816736ef
20 changed files with 150 additions and 192 deletions
|
|
@ -64,6 +64,11 @@ builtin_macros_autodiff_ty_activity = {$act} can not be used for this type
|
|||
builtin_macros_autodiff_unknown_activity = did not recognize Activity: `{$act}`
|
||||
|
||||
builtin_macros_autodiff_width = autodiff width must fit u32, but is {$width}
|
||||
|
||||
builtin_macros_avoid_att_syntax = avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
|
||||
|
||||
builtin_macros_avoid_intel_syntax = avoid using `.intel_syntax`, Intel syntax is the default
|
||||
|
||||
builtin_macros_bad_derive_target = `derive` may only be applied to `struct`s, `enum`s and `union`s
|
||||
.label = not applicable here
|
||||
.label2 = not a `struct`, `enum` or `union`
|
||||
|
|
@ -138,6 +143,8 @@ builtin_macros_derive_path_args_list = traits in `#[derive(...)]` don't accept a
|
|||
builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept values
|
||||
.suggestion = remove the value
|
||||
|
||||
builtin_macros_duplicate_macro_attribute = duplicated attribute
|
||||
|
||||
builtin_macros_env_not_defined = environment variable `{$var}` not defined at compile time
|
||||
.cargo = Cargo sets build script variables at run time. Use `std::env::var({$var_expr})` instead
|
||||
.custom = use `std::env::var({$var_expr})` to read the variable at run time
|
||||
|
|
@ -231,6 +238,8 @@ builtin_macros_derive_from_wrong_field_count = `#[derive(From)]` used on a struc
|
|||
|
||||
builtin_macros_derive_from_usage_note = `#[derive(From)]` can only be used on structs with exactly one field
|
||||
|
||||
builtin_macros_incomplete_include = include macro expected single expression in source
|
||||
|
||||
builtin_macros_multiple_default_attrs = multiple `#[default]` attributes
|
||||
.note = only one `#[default]` attribute is needed
|
||||
.label = `#[default]` used here
|
||||
|
|
@ -294,3 +303,5 @@ builtin_macros_unexpected_lit = expected path to a trait, found literal
|
|||
.label = not a trait
|
||||
.str_lit = try using `#[derive({$sym})]`
|
||||
.other = for example, write `#[derive(Debug)]` for `Debug`
|
||||
|
||||
builtin_macros_unnameable_test_items = cannot test inner items
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use lint::BuiltinLintDiag;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{AsmMacro, token};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
|
|
@ -352,7 +351,7 @@ fn expand_preparsed_asm(
|
|||
lint::builtin::BAD_ASM_STYLE,
|
||||
find_span(".intel_syntax"),
|
||||
ecx.current_expansion.lint_node_id,
|
||||
BuiltinLintDiag::AvoidUsingIntelSyntax,
|
||||
errors::AvoidIntelSyntax,
|
||||
);
|
||||
}
|
||||
if template_str.contains(".att_syntax") {
|
||||
|
|
@ -360,7 +359,7 @@ fn expand_preparsed_asm(
|
|||
lint::builtin::BAD_ASM_STYLE,
|
||||
find_span(".att_syntax"),
|
||||
ecx.current_expansion.lint_node_id,
|
||||
BuiltinLintDiag::AvoidUsingAttSyntax,
|
||||
errors::AvoidAttSyntax,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,29 @@ use rustc_errors::{
|
|||
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_span::{Ident, Span, Symbol};
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(builtin_macros_avoid_intel_syntax)]
|
||||
pub(crate) struct AvoidIntelSyntax;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(builtin_macros_avoid_att_syntax)]
|
||||
pub(crate) struct AvoidAttSyntax;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(builtin_macros_incomplete_include)]
|
||||
pub(crate) struct IncompleteInclude;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(builtin_macros_unnameable_test_items)]
|
||||
pub(crate) struct UnnameableTestItems;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(builtin_macros_duplicate_macro_attribute)]
|
||||
pub(crate) struct DuplicateMacroAttribute;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_requires_cfg_pattern)]
|
||||
pub(crate) struct RequiresCfgPattern {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use rustc_expand::base::{
|
|||
DummyResult, ExpandResult, ExtCtxt, MacEager, MacResult, MacroExpanderResult, resolve_path,
|
||||
};
|
||||
use rustc_expand::module::DirOwnership;
|
||||
use rustc_lint_defs::BuiltinLintDiag;
|
||||
use rustc_parse::lexer::StripTokens;
|
||||
use rustc_parse::parser::ForceCollect;
|
||||
use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, utf8_error};
|
||||
|
|
@ -159,7 +158,7 @@ pub(crate) fn expand_include<'cx>(
|
|||
INCOMPLETE_INCLUDE,
|
||||
p.token.span,
|
||||
self.node_id,
|
||||
BuiltinLintDiag::IncompleteInclude,
|
||||
errors::IncompleteInclude,
|
||||
);
|
||||
}
|
||||
Some(expr)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ use rustc_errors::DiagCtxtHandle;
|
|||
use rustc_expand::base::{ExtCtxt, ResolverExpand};
|
||||
use rustc_expand::expand::{AstFragment, ExpansionConfig};
|
||||
use rustc_feature::Features;
|
||||
use rustc_lint_defs::BuiltinLintDiag;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::builtin::UNNAMEABLE_TEST_ITEMS;
|
||||
use rustc_span::hygiene::{AstPass, SyntaxContext, Transparency};
|
||||
|
|
@ -165,7 +164,7 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
|
|||
UNNAMEABLE_TEST_ITEMS,
|
||||
attr.span,
|
||||
i.id,
|
||||
BuiltinLintDiag::UnnameableTestItems,
|
||||
errors::UnnameableTestItems,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
|
|||
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt};
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_feature::AttributeTemplate;
|
||||
use rustc_lint_defs::BuiltinLintDiag;
|
||||
use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES;
|
||||
use rustc_parse::{exp, parser};
|
||||
use rustc_session::errors::report_lit_error;
|
||||
|
|
@ -49,7 +48,7 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
|
|||
DUPLICATE_MACRO_ATTRIBUTES,
|
||||
attr.span,
|
||||
ecx.current_expansion.lint_node_id,
|
||||
BuiltinLintDiag::DuplicateMacroAttribute,
|
||||
errors::DuplicateMacroAttribute,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ expand_attributes_on_expressions_experimental =
|
|||
.help_outer_doc = `///` is used for outer documentation comments; for a plain comment, use `//`
|
||||
.help_inner_doc = `//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`
|
||||
|
||||
expand_cfg_attr_no_attributes = `#[cfg_attr]` does not expand to any attributes
|
||||
|
||||
expand_collapse_debuginfo_illegal =
|
||||
illegal value for attribute #[collapse_debuginfo(no|external|yes)]
|
||||
|
||||
|
|
@ -89,6 +91,13 @@ expand_malformed_feature_attribute =
|
|||
malformed `feature` attribute input
|
||||
.expected = expected just one word
|
||||
|
||||
expand_metavar_still_repeating = variable `{$ident}` is still repeating at this depth
|
||||
.label = expected repetition
|
||||
|
||||
expand_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
|
||||
.binder_label = expected repetition
|
||||
.occurrence_label = conflicting repetition
|
||||
|
||||
expand_meta_var_dif_seq_matchers = {$msg}
|
||||
|
||||
expand_missing_fragment_specifier = missing fragment specifier
|
||||
|
|
@ -176,11 +185,10 @@ expand_resolve_relative_path =
|
|||
|
||||
expand_trace_macro = trace_macro
|
||||
|
||||
expand_unknown_macro_variable = unknown macro variable `{$name}`
|
||||
|
||||
expand_unsupported_key_value =
|
||||
key-value macro attributes are not supported
|
||||
|
||||
expand_var_still_repeating =
|
||||
variable `{$ident}` is still repeating at this depth
|
||||
|
||||
expand_wrong_fragment_kind =
|
||||
non-{$kind} macro in {$kind} position: {$name}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use rustc_feature::{
|
|||
ACCEPTED_LANG_FEATURES, AttributeSafety, EnabledLangFeature, EnabledLibFeature, Features,
|
||||
REMOVED_LANG_FEATURES, UNSTABLE_LANG_FEATURES,
|
||||
};
|
||||
use rustc_lint_defs::BuiltinLintDiag;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::{STDLIB_STABLE_CRATES, Span, Symbol, sym};
|
||||
|
|
@ -315,7 +314,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
rustc_lint_defs::builtin::UNUSED_ATTRIBUTES,
|
||||
cfg_attr.span,
|
||||
ast::CRATE_NODE_ID,
|
||||
BuiltinLintDiag::CfgAttrNoAttributes,
|
||||
crate::errors::CfgAttrNoAttributes,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ use std::borrow::Cow;
|
|||
use rustc_ast::ast;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_hir::limit::Limit;
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_cfg_attr_no_attributes)]
|
||||
pub(crate) struct CfgAttrNoAttributes;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_expr_repeat_no_syntax_vars)]
|
||||
pub(crate) struct NoSyntaxVarsExprRepeat {
|
||||
|
|
@ -28,13 +32,30 @@ pub(crate) struct CountRepetitionMisplaced {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_var_still_repeating)]
|
||||
pub(crate) struct VarStillRepeating {
|
||||
#[diag(expand_metavar_still_repeating)]
|
||||
pub(crate) struct MacroVarStillRepeating {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub ident: MacroRulesNormalizedIdent,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_metavar_still_repeating)]
|
||||
pub(crate) struct MetaVarStillRepeatingLint {
|
||||
#[label]
|
||||
pub label: Span,
|
||||
pub ident: MacroRulesNormalizedIdent,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_metavariable_wrong_operator)]
|
||||
pub(crate) struct MetaVariableWrongOperator {
|
||||
#[label(expand_binder_label)]
|
||||
pub binder: Span,
|
||||
#[label(expand_occurrence_label)]
|
||||
pub occurrence: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_meta_var_dif_seq_matchers)]
|
||||
pub(crate) struct MetaVarsDifSeqMatchers {
|
||||
|
|
@ -43,6 +64,12 @@ pub(crate) struct MetaVarsDifSeqMatchers {
|
|||
pub msg: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_unknown_macro_variable)]
|
||||
pub(crate) struct UnknownMacroVariable {
|
||||
pub name: MacroRulesNormalizedIdent,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_resolve_relative_path)]
|
||||
pub(crate) struct ResolveRelativePath {
|
||||
|
|
@ -345,6 +372,15 @@ pub(crate) struct DuplicateMatcherBinding {
|
|||
pub prev: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(expand_duplicate_matcher_binding)]
|
||||
pub(crate) struct DuplicateMatcherBindingLint {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[label(expand_label2)]
|
||||
pub prev: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_missing_fragment_specifier)]
|
||||
#[note]
|
||||
|
|
|
|||
|
|
@ -108,8 +108,7 @@
|
|||
use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind};
|
||||
use rustc_ast::{DUMMY_NODE_ID, NodeId};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_lint_defs::BuiltinLintDiag;
|
||||
use rustc_errors::DecorateDiagCompat;
|
||||
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::{ErrorGuaranteed, MacroRulesNormalizedIdent, Span, kw};
|
||||
|
|
@ -245,9 +244,12 @@ fn check_binders(
|
|||
// There are 3 possibilities:
|
||||
if let Some(prev_info) = binders.get(&name) {
|
||||
// 1. The meta-variable is already bound in the current LHS: This is an error.
|
||||
let mut span = MultiSpan::from_span(span);
|
||||
span.push_span_label(prev_info.span, "previous declaration");
|
||||
buffer_lint(psess, span, node_id, BuiltinLintDiag::DuplicateMatcherBinding);
|
||||
buffer_lint(
|
||||
psess,
|
||||
span,
|
||||
node_id,
|
||||
errors::DuplicateMatcherBindingLint { span, prev: prev_info.span },
|
||||
);
|
||||
} else if get_binder_info(macros, binders, name).is_none() {
|
||||
// 2. The meta-variable is free: This is a binder.
|
||||
binders.insert(name, BinderInfo { span, ops: ops.into() });
|
||||
|
|
@ -579,7 +581,7 @@ fn check_ops_is_prefix(
|
|||
return;
|
||||
}
|
||||
}
|
||||
buffer_lint(psess, span.into(), node_id, BuiltinLintDiag::UnknownMacroVariable(name));
|
||||
buffer_lint(psess, span, node_id, errors::UnknownMacroVariable { name });
|
||||
}
|
||||
|
||||
/// Returns whether `binder_ops` is a prefix of `occurrence_ops`.
|
||||
|
|
@ -604,29 +606,42 @@ fn ops_is_prefix(
|
|||
psess: &ParseSess,
|
||||
node_id: NodeId,
|
||||
span: Span,
|
||||
name: MacroRulesNormalizedIdent,
|
||||
ident: MacroRulesNormalizedIdent,
|
||||
binder_ops: &[KleeneToken],
|
||||
occurrence_ops: &[KleeneToken],
|
||||
) {
|
||||
for (i, binder) in binder_ops.iter().enumerate() {
|
||||
if i >= occurrence_ops.len() {
|
||||
let mut span = MultiSpan::from_span(span);
|
||||
span.push_span_label(binder.span, "expected repetition");
|
||||
buffer_lint(psess, span, node_id, BuiltinLintDiag::MetaVariableStillRepeating(name));
|
||||
buffer_lint(
|
||||
psess,
|
||||
span,
|
||||
node_id,
|
||||
errors::MetaVarStillRepeatingLint { label: binder.span, ident },
|
||||
);
|
||||
return;
|
||||
}
|
||||
let occurrence = &occurrence_ops[i];
|
||||
if occurrence.op != binder.op {
|
||||
let mut span = MultiSpan::from_span(span);
|
||||
span.push_span_label(binder.span, "expected repetition");
|
||||
span.push_span_label(occurrence.span, "conflicting repetition");
|
||||
buffer_lint(psess, span, node_id, BuiltinLintDiag::MetaVariableWrongOperator);
|
||||
buffer_lint(
|
||||
psess,
|
||||
span,
|
||||
node_id,
|
||||
errors::MetaVariableWrongOperator {
|
||||
binder: binder.span,
|
||||
occurrence: occurrence.span,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn buffer_lint(psess: &ParseSess, span: MultiSpan, node_id: NodeId, diag: BuiltinLintDiag) {
|
||||
fn buffer_lint(
|
||||
psess: &ParseSess,
|
||||
span: Span,
|
||||
node_id: NodeId,
|
||||
diag: impl Into<DecorateDiagCompat>,
|
||||
) {
|
||||
// Macros loaded from other crates have dummy node ids.
|
||||
if node_id != DUMMY_NODE_ID {
|
||||
psess.buffer_lint(META_VARIABLE_MISUSE, span, node_id, diag);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ use rustc_span::{
|
|||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use crate::errors::{
|
||||
CountRepetitionMisplaced, MetaVarsDifSeqMatchers, MustRepeatOnce, MveUnrecognizedVar,
|
||||
NoSyntaxVarsExprRepeat, VarStillRepeating,
|
||||
CountRepetitionMisplaced, MacroVarStillRepeating, MetaVarsDifSeqMatchers, MustRepeatOnce,
|
||||
MveUnrecognizedVar, NoSyntaxVarsExprRepeat,
|
||||
};
|
||||
use crate::mbe::macro_parser::NamedMatch;
|
||||
use crate::mbe::macro_parser::NamedMatch::*;
|
||||
|
|
@ -483,7 +483,7 @@ fn transcribe_metavar<'tx>(
|
|||
}
|
||||
MatchedSeq(..) => {
|
||||
// We were unable to descend far enough. This is an error.
|
||||
return Err(dcx.create_err(VarStillRepeating { span: sp, ident }));
|
||||
return Err(dcx.create_err(MacroVarStillRepeating { span: sp, ident }));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,6 @@ lint_atomic_ordering_load = atomic loads cannot have `Release` or `AcqRel` order
|
|||
lint_atomic_ordering_store = atomic stores cannot have `Acquire` or `AcqRel` ordering
|
||||
.help = consider using ordering modes `Release`, `SeqCst` or `Relaxed`
|
||||
|
||||
lint_avoid_att_syntax =
|
||||
avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
|
||||
|
||||
lint_avoid_intel_syntax =
|
||||
avoid using `.intel_syntax`, Intel syntax is the default
|
||||
|
||||
lint_bad_attribute_argument = bad attribute argument
|
||||
|
||||
lint_bad_opt_access = {$msg}
|
||||
|
|
@ -190,9 +184,6 @@ lint_builtin_while_true = denote infinite loops with `loop {"{"} ... {"}"}`
|
|||
lint_byte_slice_in_packed_struct_with_derive = {$ty} slice in a packed struct that derives a built-in trait
|
||||
.help = consider implementing the trait by hand, or remove the `packed` attribute
|
||||
|
||||
lint_cfg_attr_no_attributes =
|
||||
`#[cfg_attr]` does not expand to any attributes
|
||||
|
||||
lint_check_name_unknown_tool = unknown lint tool: `{$tool_name}`
|
||||
|
||||
lint_closure_returning_async_block = closure returning async block can be made into an async closure
|
||||
|
|
@ -249,11 +240,6 @@ lint_dropping_copy_types = calls to `std::mem::drop` with a value that implement
|
|||
lint_dropping_references = calls to `std::mem::drop` with a reference instead of an owned value does nothing
|
||||
.label = argument has type `{$arg_ty}`
|
||||
|
||||
lint_duplicate_macro_attribute =
|
||||
duplicated attribute
|
||||
|
||||
lint_duplicate_matcher_binding = duplicate matcher binding
|
||||
|
||||
lint_enum_intrinsics_mem_discriminant =
|
||||
the return value of `mem::discriminant` is unspecified when called with a non-enum type
|
||||
.note = the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum
|
||||
|
|
@ -409,9 +395,6 @@ lint_improper_ctypes_union_layout_help = consider adding a `#[repr(C)]` or `#[re
|
|||
lint_improper_ctypes_union_layout_reason = this union has unspecified layout
|
||||
lint_improper_ctypes_union_non_exhaustive = this union is non-exhaustive
|
||||
|
||||
lint_incomplete_include =
|
||||
include macro expected single expression in source
|
||||
|
||||
lint_invalid_asm_label_binary = avoid using labels containing only the digits `0` and `1` in inline assembly
|
||||
.label = use a different label that doesn't start with `0` or `1`
|
||||
.help = start numbering with `2` instead
|
||||
|
|
@ -476,9 +459,6 @@ lint_legacy_derive_helpers = derive helper attribute is used before it is introd
|
|||
lint_lintpass_by_hand = implementing `LintPass` by hand
|
||||
.help = try using `declare_lint_pass!` or `impl_lint_pass!` instead
|
||||
|
||||
lint_macro_expanded_macro_exports_accessed_by_absolute_paths = macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
|
||||
.note = the macro is defined here
|
||||
|
||||
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
|
||||
|
|
@ -499,10 +479,6 @@ lint_map_unit_fn = `Iterator::map` call that discard the iterator's values
|
|||
.map_label = after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
|
||||
.suggestion = you might have meant to use `Iterator::for_each`
|
||||
|
||||
lint_metavariable_still_repeating = variable `{$name}` is still repeating at this depth
|
||||
|
||||
lint_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
|
||||
|
||||
lint_mismatched_lifetime_syntaxes_eliding_while_named =
|
||||
eliding a lifetime that's named elsewhere is confusing
|
||||
|
||||
|
|
@ -719,9 +695,6 @@ lint_pattern_in_foreign = patterns aren't allowed in foreign function declaratio
|
|||
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_proc_macro_derive_resolution_fallback = cannot find {$ns_descr} `{$ident}` in this scope
|
||||
.label = names from parent modules are not accessible without an explicit import
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -935,13 +908,9 @@ lint_unknown_lint =
|
|||
*[false] did you mean: `{$replace}`
|
||||
}
|
||||
|
||||
lint_unknown_macro_variable = unknown macro variable `{$name}`
|
||||
|
||||
lint_unknown_tool_in_scoped_lint = unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}`
|
||||
.help = add `#![register_tool({$tool_name})]` to the crate root
|
||||
|
||||
lint_unnameable_test_items = cannot test inner items
|
||||
|
||||
lint_unnecessary_qualification = unnecessary qualification
|
||||
.suggestion = remove the unnecessary path segments
|
||||
|
||||
|
|
|
|||
|
|
@ -64,17 +64,6 @@ pub fn decorate_builtin_lint(
|
|||
}
|
||||
.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::ProcMacroDeriveResolutionFallback {
|
||||
span: macro_span,
|
||||
ns_descr,
|
||||
ident,
|
||||
} => lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns_descr, ident }
|
||||
.decorate_lint(diag),
|
||||
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
|
||||
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def }
|
||||
.decorate_lint(diag)
|
||||
}
|
||||
|
||||
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
|
||||
lints::ElidedLifetimesInPaths {
|
||||
subdiag: elided_lifetime_in_path_suggestion(
|
||||
|
|
@ -398,36 +387,6 @@ pub fn decorate_builtin_lint(
|
|||
BuiltinLintDiag::UnstableFeature(msg) => {
|
||||
lints::UnstableFeature { msg }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::AvoidUsingIntelSyntax => {
|
||||
lints::AvoidIntelSyntax.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::AvoidUsingAttSyntax => {
|
||||
lints::AvoidAttSyntax.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::IncompleteInclude => {
|
||||
lints::IncompleteInclude.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::UnnameableTestItems => {
|
||||
lints::UnnameableTestItems.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::DuplicateMacroAttribute => {
|
||||
lints::DuplicateMacroAttribute.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::CfgAttrNoAttributes => {
|
||||
lints::CfgAttrNoAttributes.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
|
||||
lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::MetaVariableWrongOperator => {
|
||||
lints::MetaVariableWrongOperator.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::DuplicateMatcherBinding => {
|
||||
lints::DuplicateMatcherBinding.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::UnknownMacroVariable(name) => {
|
||||
lints::UnknownMacroVariable { name }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => {
|
||||
lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ 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, MacroRulesNormalizedIdent, Span, Symbol, sym};
|
||||
use rustc_span::{Ident, Span, Symbol, sym};
|
||||
|
||||
use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
|
||||
use crate::errors::{OverruledAttributeSub, RequestedLevel};
|
||||
|
|
@ -2585,50 +2585,6 @@ impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_avoid_intel_syntax)]
|
||||
pub(crate) struct AvoidIntelSyntax;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_avoid_att_syntax)]
|
||||
pub(crate) struct AvoidAttSyntax;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_incomplete_include)]
|
||||
pub(crate) struct IncompleteInclude;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unnameable_test_items)]
|
||||
pub(crate) struct UnnameableTestItems;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_duplicate_macro_attribute)]
|
||||
pub(crate) struct DuplicateMacroAttribute;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_cfg_attr_no_attributes)]
|
||||
pub(crate) struct CfgAttrNoAttributes;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_metavariable_still_repeating)]
|
||||
pub(crate) struct MetaVariableStillRepeating {
|
||||
pub name: MacroRulesNormalizedIdent,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_metavariable_wrong_operator)]
|
||||
pub(crate) struct MetaVariableWrongOperator;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_duplicate_matcher_binding)]
|
||||
pub(crate) struct DuplicateMatcherBinding;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unknown_macro_variable)]
|
||||
pub(crate) struct UnknownMacroVariable {
|
||||
pub name: MacroRulesNormalizedIdent,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_unused_crate_dependency)]
|
||||
#[help]
|
||||
|
|
@ -2714,22 +2670,6 @@ pub(crate) struct AbsPathWithModuleSugg {
|
|||
pub replacement: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_proc_macro_derive_resolution_fallback)]
|
||||
pub(crate) struct ProcMacroDeriveResolutionFallback {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub ns_descr: &'static str,
|
||||
pub ident: Ident,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_macro_expanded_macro_exports_accessed_by_absolute_paths)]
|
||||
pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
|
||||
#[note]
|
||||
pub definition: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_hidden_lifetime_parameters)]
|
||||
pub(crate) struct ElidedLifetimesInPaths {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use rustc_hir_id::{HashStableContext, HirId, ItemLocalId};
|
|||
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
|
||||
use rustc_span::def_id::DefPathHash;
|
||||
pub use rustc_span::edition::Edition;
|
||||
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol, sym};
|
||||
use rustc_span::{Ident, Span, Symbol, sym};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use self::Level::*;
|
||||
|
|
@ -620,12 +620,6 @@ pub enum DeprecatedSinceKind {
|
|||
#[derive(Debug)]
|
||||
pub enum BuiltinLintDiag {
|
||||
AbsPathWithModule(Span),
|
||||
ProcMacroDeriveResolutionFallback {
|
||||
span: Span,
|
||||
ns_descr: &'static str,
|
||||
ident: Ident,
|
||||
},
|
||||
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),
|
||||
ElidedLifetimesInPaths(usize, Span, bool, Span),
|
||||
UnknownCrateTypes {
|
||||
span: Span,
|
||||
|
|
@ -774,16 +768,6 @@ pub enum BuiltinLintDiag {
|
|||
UnusedMacroDefinition(Symbol),
|
||||
MacroRuleNeverUsed(usize, Symbol),
|
||||
UnstableFeature(DiagMessage),
|
||||
AvoidUsingIntelSyntax,
|
||||
AvoidUsingAttSyntax,
|
||||
IncompleteInclude,
|
||||
UnnameableTestItems,
|
||||
DuplicateMacroAttribute,
|
||||
CfgAttrNoAttributes,
|
||||
MetaVariableStillRepeating(MacroRulesNormalizedIdent),
|
||||
MetaVariableWrongOperator,
|
||||
DuplicateMatcherBinding,
|
||||
UnknownMacroVariable(MacroRulesNormalizedIdent),
|
||||
UnusedCrateDependency {
|
||||
extern_crate: Symbol,
|
||||
local_crate: Symbol,
|
||||
|
|
|
|||
|
|
@ -260,6 +260,9 @@ resolve_macro_defined_later =
|
|||
resolve_macro_expanded_extern_crate_cannot_shadow_extern_arguments =
|
||||
macro-expanded `extern crate` items cannot shadow names passed with `--extern`
|
||||
|
||||
resolve_macro_expanded_macro_exports_accessed_by_absolute_paths = macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
|
||||
.note = the macro is defined here
|
||||
|
||||
resolve_macro_expected_found =
|
||||
expected {$expected}, found {$found} `{$macro_path}`
|
||||
.label = not {$article} {$expected}
|
||||
|
|
@ -339,6 +342,9 @@ resolve_param_in_ty_of_const_param =
|
|||
|
||||
resolve_pattern_doesnt_bind_name = pattern doesn't bind `{$name}`
|
||||
|
||||
resolve_proc_macro_derive_resolution_fallback = cannot find {$ns_descr} `{$ident}` in this scope
|
||||
.label = names from parent modules are not accessible without an explicit import
|
||||
|
||||
resolve_proc_macro_same_crate = can't use a procedural macro from the same crate that defines it
|
||||
.help = you can define integration tests in a directory named `tests`
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
||||
CRATE_NODE_ID,
|
||||
span_use,
|
||||
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def),
|
||||
errors::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use rustc_errors::{
|
|||
Applicability, Diag, ElidedLifetimeInPathSubdiag, EmissionGuarantee, IntoDiagArg, MultiSpan,
|
||||
Subdiagnostic,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_span::{Ident, Span, Symbol};
|
||||
|
||||
use crate::late::PatternSource;
|
||||
|
|
@ -566,6 +566,22 @@ pub(crate) struct ProcMacroSameCrate {
|
|||
pub(crate) is_test: bool,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(resolve_proc_macro_derive_resolution_fallback)]
|
||||
pub(crate) struct ProcMacroDeriveResolutionFallback {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub ns_descr: &'static str,
|
||||
pub ident: Ident,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(resolve_macro_expanded_macro_exports_accessed_by_absolute_paths)]
|
||||
pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
|
||||
#[note]
|
||||
pub definition: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_imported_crate)]
|
||||
pub(crate) struct CrateImported {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use rustc_ast::{self as ast, NodeId};
|
|||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PartialRes, PerNS};
|
||||
use rustc_middle::bug;
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
|
||||
|
|
@ -520,7 +519,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
|
||||
lint_id,
|
||||
orig_ident.span,
|
||||
BuiltinLintDiag::ProcMacroDeriveResolutionFallback {
|
||||
errors::ProcMacroDeriveResolutionFallback {
|
||||
span: orig_ident.span,
|
||||
ns_descr: ns.descr(),
|
||||
ident,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ error: duplicate matcher binding
|
|||
--> $DIR/issue-61053-duplicate-binder.rs:7:20
|
||||
|
|
||||
LL | ($x:tt $x:tt) => { $x };
|
||||
| -- ^^
|
||||
| -- ^^ duplicate binding
|
||||
| |
|
||||
| previous declaration
|
||||
| previous binding
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-61053-duplicate-binder.rs:1:9
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue