Skip to content

Commit 9553ff7

Browse files
Rollup merge of #165982 - Enselic:at-report, r=davidtwco
compiler: Stop special-casing `report_in_external_macro` in `declare_tool_lint!` And make it follow style of the other boolean `@eval_always = true`. More cleanups can be made, but I wanted to keep the diff minimal to make review easier. ### Why this PR? Later, we will convert this from a bool to a three-variant enum. This PR is one small preparatory step towards fixing #112504. See #165210 for a sketch of how this commit contributes to a full solution. I want to split that PR up into smaller parts to distribute review load, and this is one part that can be reviewed in isolation.
2 parents 52f482f + f7613b5 commit 9553ff7

22 files changed

Lines changed: 58 additions & 73 deletions

‎compiler/rustc_lint/src/disallowed_pass_by_ref.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare_tool_lint! {
1515
pub rustc::DISALLOWED_PASS_BY_REF,
1616
Warn,
1717
"pass by reference of a type flagged as `#[rustc_pass_by_value]`",
18-
report_in_external_macro: true
18+
@report_in_external_macro = true
1919
}
2020

2121
declare_lint_pass!(DisallowedPassByRef => [DISALLOWED_PASS_BY_REF]);

‎compiler/rustc_lint/src/internal.rs‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_tool_lint! {
3434
pub rustc::DEFAULT_HASH_TYPES,
3535
Allow,
3636
"forbid HashMap and HashSet and suggest the FxHash* variants",
37-
report_in_external_macro: true
37+
@report_in_external_macro = true
3838
}
3939

4040
declare_lint_pass!(DefaultHashTypes => [DEFAULT_HASH_TYPES]);
@@ -73,7 +73,7 @@ declare_tool_lint! {
7373
pub rustc::POTENTIAL_QUERY_INSTABILITY,
7474
Allow,
7575
"require explicit opt-in when using potentially unstable methods or functions",
76-
report_in_external_macro: true
76+
@report_in_external_macro = true
7777
}
7878

7979
declare_tool_lint! {
@@ -84,7 +84,7 @@ declare_tool_lint! {
8484
pub rustc::UNTRACKED_QUERY_INFORMATION,
8585
Allow,
8686
"require explicit opt-in when accessing information not tracked by the query system",
87-
report_in_external_macro: true
87+
@report_in_external_macro = true
8888
}
8989

9090
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY, UNTRACKED_QUERY_INFORMATION]);
@@ -201,7 +201,7 @@ declare_tool_lint! {
201201
pub rustc::USAGE_OF_TY_TYKIND,
202202
Allow,
203203
"usage of `ty::TyKind` outside of the `ty::sty` module",
204-
report_in_external_macro: true
204+
@report_in_external_macro = true
205205
}
206206

207207
declare_tool_lint! {
@@ -210,7 +210,7 @@ declare_tool_lint! {
210210
pub rustc::USAGE_OF_QUALIFIED_TY,
211211
Allow,
212212
"using `ty::{Ty,TyCtxt}` instead of importing it",
213-
report_in_external_macro: true
213+
@report_in_external_macro = true
214214
}
215215

216216
declare_lint_pass!(TyTyKind => [
@@ -347,7 +347,7 @@ declare_tool_lint! {
347347
pub rustc::NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT,
348348
Allow,
349349
"non-glob import of `rustc_type_ir::inherent`",
350-
report_in_external_macro: true
350+
@report_in_external_macro = true
351351
}
352352

353353
declare_tool_lint! {
@@ -357,7 +357,7 @@ declare_tool_lint! {
357357
pub rustc::USAGE_OF_TYPE_IR_INHERENT,
358358
Allow,
359359
"usage `rustc_type_ir::inherent` outside of trait system",
360-
report_in_external_macro: true
360+
@report_in_external_macro = true
361361
}
362362

363363
declare_tool_lint! {
@@ -370,7 +370,7 @@ declare_tool_lint! {
370370
pub rustc::USAGE_OF_TYPE_IR_TRAITS,
371371
Allow,
372372
"usage `rustc_type_ir`-specific abstraction traits outside of trait system",
373-
report_in_external_macro: true
373+
@report_in_external_macro = true
374374
}
375375
declare_tool_lint! {
376376
/// The `direct_use_of_rustc_type_ir` lint detects usage of `rustc_type_ir`.
@@ -380,7 +380,7 @@ declare_tool_lint! {
380380
pub rustc::DIRECT_USE_OF_RUSTC_TYPE_IR,
381381
Allow,
382382
"usage `rustc_type_ir` abstraction outside of trait system",
383-
report_in_external_macro: true
383+
@report_in_external_macro = true
384384
}
385385

386386
declare_lint_pass!(TypeIr => [
@@ -541,7 +541,7 @@ declare_tool_lint! {
541541
pub rustc::BAD_OPT_ACCESS,
542542
Deny,
543543
"prevent using options by field access when there is a wrapper function",
544-
report_in_external_macro: true
544+
@report_in_external_macro = true
545545
}
546546

547547
declare_lint_pass!(BadOptAccess => [BAD_OPT_ACCESS]);
@@ -575,7 +575,7 @@ declare_tool_lint! {
575575
pub rustc::SYMBOL_INTERN_STRING_LITERAL,
576576
Allow,
577577
"Forbid uses of string literals in `Symbol::intern` or `Ident::from_str_and_span`, suggesting preinterning instead",
578-
report_in_external_macro: true
578+
@report_in_external_macro = true
579579
}
580580

581581
declare_lint_pass!(SymbolInternStringLiteral => [SYMBOL_INTERN_STRING_LITERAL]);
@@ -617,7 +617,7 @@ declare_tool_lint! {
617617
pub rustc::IMPLICIT_SYSROOT_CRATE_IMPORT,
618618
Allow,
619619
"Forbid uses of non-sysroot crates in `extern crate`",
620-
report_in_external_macro: true
620+
@report_in_external_macro = true
621621
}
622622

623623
declare_lint_pass!(ImplicitSysrootCrateImport => [IMPLICIT_SYSROOT_CRATE_IMPORT]);
@@ -651,7 +651,7 @@ declare_tool_lint! {
651651
pub rustc::BAD_USE_OF_FIND_ATTR,
652652
Allow,
653653
"Forbid `AttributeKind::` as a prefix in `find_attr!` macros.",
654-
report_in_external_macro: true
654+
@report_in_external_macro = true
655655
}
656656
declare_lint_pass!(BadUseOfFindAttr => [BAD_USE_OF_FIND_ATTR]);
657657

@@ -739,7 +739,7 @@ declare_tool_lint! {
739739
pub rustc::RUSTC_MUST_MATCH_EXHAUSTIVELY,
740740
Allow,
741741
"Forbids matches with wildcards, or if-let matching on enums marked with `#[rustc_must_match_exhaustively]`",
742-
report_in_external_macro: true
742+
@report_in_external_macro = true
743743
}
744744
declare_lint_pass!(RustcMustMatchExhaustively => [RUSTC_MUST_MATCH_EXHAUSTIVELY]);
745745

@@ -853,7 +853,7 @@ declare_tool_lint! {
853853
// This lint is meant to be manually enabled in selected crates (currently only `rustc_type_ir`)
854854
Allow,
855855
"Forbid implementing `TypeVisitable` without deriving `GenericTypeVisitable`",
856-
report_in_external_macro: true
856+
@report_in_external_macro = true
857857
}
858858

859859
declare_lint_pass!(MissingGenericTypeVisitableDerive => [MISSING_GENERIC_TYPE_VISITABLE_DERIVE]);

‎compiler/rustc_lint_defs/src/lib.rs‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -733,23 +733,8 @@ macro_rules! declare_lint {
733733
#[allow_internal_unstable(default_field_values)]
734734
macro_rules! declare_tool_lint {
735735
(
736-
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
737-
$(, @eval_always = $eval_always:literal)?
738-
$(, @feature_gate = $gate:ident;)?
739-
) => (
740-
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false $(, @eval_always = $eval_always)? $(, @feature_gate = $gate;)?}
741-
);
742-
(
743-
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
744-
report_in_external_macro: $rep:expr
745-
$(, @eval_always = $eval_always: literal)?
746-
$(, @feature_gate = $gate:ident;)?
747-
) => (
748-
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep $(, @eval_always = $eval_always)? $(, @feature_gate = $gate;)?}
749-
);
750-
(
751-
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
752-
$external:expr
736+
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr
737+
$(, @report_in_external_macro = $external:literal)?
753738
$(, @eval_always = $eval_always: literal)?
754739
$(, @feature_gate = $gate:ident;)?
755740
) => (
@@ -758,7 +743,7 @@ macro_rules! declare_tool_lint {
758743
name: &concat!(stringify!($tool), "::", stringify!($NAME)),
759744
default_level: $crate::$Level,
760745
desc: $desc,
761-
report_in_external_macro: $external,
746+
$(report_in_external_macro: $external,)?
762747
is_externally_loaded: true,
763748
$(feature_gate: Some(rustc_span::sym::$gate),)?
764749
$(eval_always: $eval_always,)?

‎src/tools/clippy/clippy_lints_internal/src/almost_standard_lint_formulation.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare_tool_lint! {
2020
pub clippy::ALMOST_STANDARD_LINT_FORMULATION,
2121
Warn,
2222
"lint formulations must have a standardized format.",
23-
report_in_external_macro: true
23+
@report_in_external_macro = true
2424
}
2525

2626
impl_lint_pass!(AlmostStandardFormulation => [ALMOST_STANDARD_LINT_FORMULATION]);

‎src/tools/clippy/clippy_lints_internal/src/collapsible_span_lint_calls.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ declare_tool_lint! {
6868
pub clippy::COLLAPSIBLE_SPAN_LINT_CALLS,
6969
Warn,
7070
"found collapsible `span_lint_and_then` calls",
71-
report_in_external_macro: true
71+
@report_in_external_macro = true
7272
}
7373

7474
declare_lint_pass!(CollapsibleCalls => [COLLAPSIBLE_SPAN_LINT_CALLS]);

‎src/tools/clippy/clippy_lints_internal/src/lint_without_lint_pass.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ declare_tool_lint! {
3939
pub clippy::LINT_WITHOUT_LINT_PASS,
4040
Warn,
4141
"declaring a lint without associating it in a LintPass",
42-
report_in_external_macro: true
42+
@report_in_external_macro = true
4343

4444
}
4545

@@ -63,7 +63,7 @@ declare_tool_lint! {
6363
pub clippy::DEFAULT_LINT,
6464
Warn,
6565
"found 'default lint description' in a lint declaration",
66-
report_in_external_macro: true
66+
@report_in_external_macro = true
6767
}
6868

6969
declare_tool_lint! {
@@ -76,7 +76,7 @@ declare_tool_lint! {
7676
pub clippy::INVALID_CLIPPY_VERSION_ATTRIBUTE,
7777
Warn,
7878
"found an invalid `clippy::version` attribute",
79-
report_in_external_macro: true
79+
@report_in_external_macro = true
8080
}
8181

8282
declare_tool_lint! {
@@ -85,7 +85,7 @@ declare_tool_lint! {
8585
pub clippy::MISSING_CLIPPY_VERSION_ATTRIBUTE,
8686
Warn,
8787
"found clippy lint without `clippy::version` attribute",
88-
report_in_external_macro: true
88+
@report_in_external_macro = true
8989
}
9090

9191
#[derive(Clone, Debug, Default)]

‎src/tools/clippy/clippy_lints_internal/src/msrv_attr_impl.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare_tool_lint! {
1313
pub clippy::MISSING_MSRV_ATTR_IMPL,
1414
Warn,
1515
"checking if all necessary steps were taken when adding a MSRV to a lint",
16-
report_in_external_macro: true
16+
@report_in_external_macro = true
1717
}
1818

1919
declare_lint_pass!(MsrvAttrImpl => [MISSING_MSRV_ATTR_IMPL]);

‎src/tools/clippy/clippy_lints_internal/src/outer_expn_data_pass.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ declare_tool_lint! {
2525
pub clippy::OUTER_EXPN_EXPN_DATA,
2626
Warn,
2727
"using `cx.outer_expn().expn_data()` instead of `cx.outer_expn_data()`",
28-
report_in_external_macro: true
28+
@report_in_external_macro = true
2929
}
3030

3131
declare_lint_pass!(OuterExpnDataPass => [OUTER_EXPN_EXPN_DATA]);

‎src/tools/clippy/clippy_lints_internal/src/symbols.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare_tool_lint! {
3030
pub clippy::INTERNING_LITERALS,
3131
Warn,
3232
"interning a symbol that is a literal",
33-
report_in_external_macro: true
33+
@report_in_external_macro = true
3434
}
3535

3636
declare_tool_lint! {
@@ -52,7 +52,7 @@ declare_tool_lint! {
5252
pub clippy::SYMBOL_AS_STR,
5353
Warn,
5454
"calls to `Symbol::as_str`",
55-
report_in_external_macro: true
55+
@report_in_external_macro = true
5656
}
5757

5858
#[derive(Default)]

‎src/tools/clippy/clippy_lints_internal/src/unnecessary_def_path.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare_tool_lint! {
3131
pub clippy::UNNECESSARY_DEF_PATH,
3232
Warn,
3333
"using a def path when a diagnostic item or a `LangItem` is available",
34-
report_in_external_macro: true
34+
@report_in_external_macro = true
3535
}
3636

3737
declare_lint_pass!(UnnecessaryDefPath => [UNNECESSARY_DEF_PATH]);

0 commit comments

Comments
 (0)