Skip to content

Commit af710c9

Browse files
committed
Add test for linting on 'cfg_attr(,)'.
1 parent 02877ac commit af710c9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Check that `#[cfg_attr($PREDICATE,)]` triggers the `unused_attribute` lint.
2+
3+
// compile-flags: --cfg TRUE
4+
5+
#![deny(unused)]
6+
7+
#[cfg_attr(FALSE,)] //~ ERROR unused attribute
8+
fn _f() {}
9+
10+
#[cfg_attr(TRUE,)] //~ ERROR unused attribute
11+
fn _g() {}
12+
13+
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: unused attribute
2+
--> $DIR/cfg-attr-empty-is-unused.rs:7:1
3+
|
4+
LL | #[cfg_attr(FALSE,)]
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/cfg-attr-empty-is-unused.rs:5:9
9+
|
10+
LL | #![deny(unused)]
11+
| ^^^^^^
12+
= note: #[deny(unused_attributes)] implied by #[deny(unused)]
13+
14+
error: unused attribute
15+
--> $DIR/cfg-attr-empty-is-unused.rs:10:1
16+
|
17+
LL | #[cfg_attr(TRUE,)]
18+
| ^^^^^^^^^^^^^^^^^^
19+
20+
error: aborting due to 2 previous errors
21+

0 commit comments

Comments
 (0)