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 1db413a

Browse files
Auto merge of #145881 - fmease:mv-var-to-dyn-buf-lints, r=<try>
[WIP] Move more early buffered lints to dyn lint diagnostics
2 parents a2c8b0b + 5cecd4a commit 1db413a

File tree

27 files changed

+232
-327
lines changed

27 files changed

+232
-327
lines changed

‎compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ ast_passes_match_arm_with_no_body =
201201
.suggestion = add a body after the pattern
202202
203203
ast_passes_missing_unsafe_on_extern = extern blocks must be unsafe
204+
.suggestion = needs `unsafe` before the extern keyword
204205
205206
ast_passes_module_nonascii = trying to load file for module `{$name}` with non-ascii identifier name
206207
.help = consider using the `#[path]` attribute to specify filesystem path

‎compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11041104
MISSING_UNSAFE_ON_EXTERN,
11051105
item.id,
11061106
item.span,
1107-
BuiltinLintDiag::MissingUnsafeOnExtern {
1107+
errors::MissingUnsafeOnExternLint {
11081108
suggestion: item.span.shrink_to_lo(),
11091109
},
11101110
);

‎compiler/rustc_ast_passes/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@ pub(crate) struct MissingUnsafeOnExtern {
489489
pub span: Span,
490490
}
491491

492+
#[derive(LintDiagnostic)]
493+
#[diag(ast_passes_missing_unsafe_on_extern)]
494+
pub(crate) struct MissingUnsafeOnExternLint {
495+
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
496+
pub suggestion: Span,
497+
}
498+
492499
#[derive(Diagnostic)]
493500
#[diag(ast_passes_fieldless_union)]
494501
pub(crate) struct FieldlessUnion {

‎compiler/rustc_builtin_macros/messages.ftl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ builtin_macros_autodiff_ty_activity = {$act} can not be used for this type
6464
builtin_macros_autodiff_unknown_activity = did not recognize Activity: `{$act}`
6565
6666
builtin_macros_autodiff_width = autodiff width must fit u32, but is {$width}
67+
68+
builtin_macros_avoid_att_syntax = avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
69+
70+
builtin_macros_avoid_intel_syntax = avoid using `.intel_syntax`, Intel syntax is the default
71+
6772
builtin_macros_bad_derive_target = `derive` may only be applied to `struct`s, `enum`s and `union`s
6873
.label = not applicable here
6974
.label2 = not a `struct`, `enum` or `union`
@@ -138,6 +143,8 @@ builtin_macros_derive_path_args_list = traits in `#[derive(...)]` don't accept a
138143
builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept values
139144
.suggestion = remove the value
140145
146+
builtin_macros_duplicate_macro_attribute = duplicated attribute
147+
141148
builtin_macros_env_not_defined = environment variable `{$var}` not defined at compile time
142149
.cargo = Cargo sets build script variables at run time. Use `std::env::var({$var_expr})` instead
143150
.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
231238
232239
builtin_macros_derive_from_usage_note = `#[derive(From)]` can only be used on structs with exactly one field
233240
241+
builtin_macros_incomplete_include = include macro expected single expression in source
242+
234243
builtin_macros_multiple_default_attrs = multiple `#[default]` attributes
235244
.note = only one `#[default]` attribute is needed
236245
.label = `#[default]` used here
@@ -294,3 +303,5 @@ builtin_macros_unexpected_lit = expected path to a trait, found literal
294303
.label = not a trait
295304
.str_lit = try using `#[derive({$sym})]`
296305
.other = for example, write `#[derive(Debug)]` for `Debug`
306+
307+
builtin_macros_unnameable_test_items = cannot test inner items

‎compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use lint::BuiltinLintDiag;
21
use rustc_ast::tokenstream::TokenStream;
32
use rustc_ast::{AsmMacro, token};
43
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
@@ -352,15 +351,15 @@ fn expand_preparsed_asm(
352351
lint::builtin::BAD_ASM_STYLE,
353352
find_span(".intel_syntax"),
354353
ecx.current_expansion.lint_node_id,
355-
BuiltinLintDiag::AvoidUsingIntelSyntax,
354+
errors::AvoidIntelSyntax,
356355
);
357356
}
358357
if template_str.contains(".att_syntax") {
359358
ecx.psess().buffer_lint(
360359
lint::builtin::BAD_ASM_STYLE,
361360
find_span(".att_syntax"),
362361
ecx.current_expansion.lint_node_id,
363-
BuiltinLintDiag::AvoidUsingAttSyntax,
362+
errors::AvoidAttSyntax,
364363
);
365364
}
366365
}

‎compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,29 @@ use rustc_errors::{
33
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
44
Subdiagnostic,
55
};
6-
use rustc_macros::{Diagnostic, Subdiagnostic};
6+
use rustc_macros::{Diagnostic, LintDiagnostic,Subdiagnostic};
77
use rustc_span::{Ident, Span, Symbol};
88

9+
#[derive(LintDiagnostic)]
10+
#[diag(builtin_macros_avoid_intel_syntax)]
11+
pub(crate) struct AvoidIntelSyntax;
12+
13+
#[derive(LintDiagnostic)]
14+
#[diag(builtin_macros_avoid_att_syntax)]
15+
pub(crate) struct AvoidAttSyntax;
16+
17+
#[derive(LintDiagnostic)]
18+
#[diag(builtin_macros_incomplete_include)]
19+
pub(crate) struct IncompleteInclude;
20+
21+
#[derive(LintDiagnostic)]
22+
#[diag(builtin_macros_unnameable_test_items)]
23+
pub(crate) struct UnnameableTestItems;
24+
25+
#[derive(LintDiagnostic)]
26+
#[diag(builtin_macros_duplicate_macro_attribute)]
27+
pub(crate) struct DuplicateMacroAttribute;
28+
929
#[derive(Diagnostic)]
1030
#[diag(builtin_macros_requires_cfg_pattern)]
1131
pub(crate) struct RequiresCfgPattern {

‎compiler/rustc_builtin_macros/src/source_util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_expand::base::{
1010
DummyResult, ExpandResult, ExtCtxt, MacEager, MacResult, MacroExpanderResult, resolve_path,
1111
};
1212
use rustc_expand::module::DirOwnership;
13-
use rustc_lint_defs::BuiltinLintDiag;
1413
use rustc_parse::parser::{ForceCollect, Parser};
1514
use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, utf8_error};
1615
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
@@ -150,7 +149,7 @@ pub(crate) fn expand_include<'cx>(
150149
INCOMPLETE_INCLUDE,
151150
self.p.token.span,
152151
self.node_id,
153-
BuiltinLintDiag::IncompleteInclude,
152+
errors::IncompleteInclude,
154153
);
155154
}
156155
Some(expr)

‎compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_errors::DiagCtxtHandle;
1111
use rustc_expand::base::{ExtCtxt, ResolverExpand};
1212
use rustc_expand::expand::{AstFragment, ExpansionConfig};
1313
use rustc_feature::Features;
14-
use rustc_lint_defs::BuiltinLintDiag;
1514
use rustc_session::Session;
1615
use rustc_session::lint::builtin::UNNAMEABLE_TEST_ITEMS;
1716
use rustc_span::hygiene::{AstPass, SyntaxContext, Transparency};
@@ -165,7 +164,7 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
165164
UNNAMEABLE_TEST_ITEMS,
166165
attr.span,
167166
i.id,
168-
BuiltinLintDiag::UnnameableTestItems,
167+
errors::UnnameableTestItems,
169168
);
170169
}
171170
}

‎compiler/rustc_builtin_macros/src/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
55
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt};
66
use rustc_expand::expand::AstFragment;
77
use rustc_feature::AttributeTemplate;
8-
use rustc_lint_defs::BuiltinLintDiag;
98
use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES;
109
use rustc_parse::{exp, parser};
1110
use rustc_session::errors::report_lit_error;
@@ -49,7 +48,7 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
4948
DUPLICATE_MACRO_ATTRIBUTES,
5049
attr.span,
5150
ecx.current_expansion.lint_node_id,
52-
BuiltinLintDiag::DuplicateMacroAttribute,
51+
errors::DuplicateMacroAttribute,
5352
);
5453
}
5554
}

‎compiler/rustc_expand/messages.ftl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ expand_attributes_on_expressions_experimental =
33
.help_outer_doc = `///` is used for outer documentation comments; for a plain comment, use `//`
44
.help_inner_doc = `//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !`
55
6+
expand_cfg_attr_no_attributes = `#[cfg_attr]` does not expand to any attributes
7+
68
expand_collapse_debuginfo_illegal =
79
illegal value for attribute #[collapse_debuginfo(no|external|yes)]
810
@@ -78,6 +80,10 @@ expand_macro_body_stability =
7880
.label = invalid body stability attribute
7981
.label2 = body stability attribute affects this macro
8082
83+
expand_macro_call_unused_doc_comment = unused doc comment
84+
.label = rustdoc does not generate documentation for macro invocations
85+
.help = to document an item produced by a macro, the macro must produce the documentation as part of its expansion
86+
8187
expand_macro_const_stability =
8288
macros cannot have const stability attributes
8389
.label = invalid const stability attribute
@@ -89,6 +95,13 @@ expand_malformed_feature_attribute =
8995
malformed `feature` attribute input
9096
.expected = expected just one word
9197
98+
expand_metavariable_still_repeating = variable `{$name}` is still repeating at this depth
99+
.label = expected repetition
100+
101+
expand_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
102+
.binder_label = expected repetition
103+
.occurrence_label = conflicting repetition
104+
92105
expand_meta_var_dif_seq_matchers = {$msg}
93106
94107
expand_missing_fragment_specifier = missing fragment specifier
@@ -176,6 +189,8 @@ expand_resolve_relative_path =
176189
177190
expand_trace_macro = trace_macro
178191
192+
expand_unknown_macro_variable = unknown macro variable `{$name}`
193+
179194
expand_unsupported_key_value =
180195
key-value macro attributes are not supported
181196

0 commit comments

Comments
(0)

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