Skip to content

Commit

Permalink
Add test for linting on 'cfg_attr(,)'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jun 22, 2019
1 parent 02877ac commit af710c9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Check that `#[cfg_attr($PREDICATE,)]` triggers the `unused_attribute` lint.

// compile-flags: --cfg TRUE

#![deny(unused)]

#[cfg_attr(FALSE,)] //~ ERROR unused attribute
fn _f() {}

#[cfg_attr(TRUE,)] //~ ERROR unused attribute
fn _g() {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error: unused attribute
--> $DIR/cfg-attr-empty-is-unused.rs:7:1
|
LL | #[cfg_attr(FALSE,)]
| ^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/cfg-attr-empty-is-unused.rs:5:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: #[deny(unused_attributes)] implied by #[deny(unused)]

error: unused attribute
--> $DIR/cfg-attr-empty-is-unused.rs:10:1
|
LL | #[cfg_attr(TRUE,)]
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

0 comments on commit af710c9

Please sign in to comment.