Skip to content

Commit c1abc30

Browse files
Make declare_lint take any amount of boolean fields
1 parent aa4ee2c commit c1abc30

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/librustc/lint/builtin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare_lint! {
2222
pub CONST_ERR,
2323
Deny,
2424
"constant evaluation detected erroneous expression",
25-
report_in_external_macro: true
25+
report_in_external_macro
2626
}
2727

2828
declare_lint! {
@@ -71,7 +71,7 @@ declare_lint! {
7171
pub UNREACHABLE_CODE,
7272
Warn,
7373
"detects unreachable code paths",
74-
report_in_external_macro: true
74+
report_in_external_macro
7575
}
7676

7777
declare_lint! {
@@ -211,7 +211,7 @@ declare_lint! {
211211
pub DEPRECATED,
212212
Warn,
213213
"detects use of deprecated items",
214-
report_in_external_macro: true
214+
report_in_external_macro
215215
}
216216

217217
declare_lint! {
@@ -381,7 +381,7 @@ declare_lint! {
381381
pub DEPRECATED_IN_FUTURE,
382382
Allow,
383383
"detects use of items that will be deprecated in a future version",
384-
report_in_external_macro: true
384+
report_in_external_macro
385385
}
386386

387387
declare_lint! {

src/librustc/lint/mod.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ pub struct Lint {
8181
}
8282

8383
impl Lint {
84+
pub const fn default_fields_for_macro() -> Self {
85+
Lint {
86+
name: "",
87+
default_level: Level::Forbid,
88+
desc: "",
89+
edition_lint_opts: None,
90+
is_plugin: false,
91+
report_in_external_macro: false,
92+
}
93+
}
94+
8495
/// Returns the `rust::lint::Lint` for a `syntax::early_buffered_lints::BufferedEarlyLintId`.
8596
pub fn from_parser_lint_id(lint_id: BufferedEarlyLintId) -> &'static Self {
8697
match lint_id {
@@ -107,19 +118,19 @@ impl Lint {
107118
#[macro_export]
108119
macro_rules! declare_lint {
109120
($vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
110-
declare_lint!{$vis $NAME, $Level, $desc, false}
121+
declare_lint!(
122+
$vis $NAME, $Level, $desc,
123+
);
111124
);
112-
($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro: $rep: expr) => (
113-
declare_lint!{$vis $NAME, $Level, $desc, $rep}
114-
);
115-
($vis: vis $NAME: ident, $Level: ident, $desc: expr, $external: expr) => (
125+
($vis: vis $NAME: ident, $Level: ident, $desc: expr, $($v:ident),*) => (
116126
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
117127
name: stringify!($NAME),
118128
default_level: $crate::lint::$Level,
119129
desc: $desc,
120130
edition_lint_opts: None,
121-
report_in_external_macro: $external,
122131
is_plugin: false,
132+
$($v: true,)*
133+
..$crate::lint::Lint::default_fields_for_macro()
123134
};
124135
);
125136
($vis: vis $NAME: ident, $Level: ident, $desc: expr,

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ declare_lint! {
280280
pub MISSING_DOCS,
281281
Allow,
282282
"detects missing documentation for public members",
283-
report_in_external_macro: true
283+
report_in_external_macro
284284
}
285285

286286
pub struct MissingDoc {
@@ -1374,7 +1374,7 @@ declare_lint! {
13741374
UNNAMEABLE_TEST_ITEMS,
13751375
Warn,
13761376
"detects an item that cannot be named being marked as `#[test_case]`",
1377-
report_in_external_macro: true
1377+
report_in_external_macro
13781378
}
13791379

13801380
pub struct UnnameableTestItems {

src/librustc_lint/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ declare_lint! {
2525
pub UNUSED_MUST_USE,
2626
Warn,
2727
"unused result of a type flagged as `#[must_use]`",
28-
report_in_external_macro: true
28+
report_in_external_macro
2929
}
3030

3131
declare_lint! {

0 commit comments

Comments
 (0)