From af710c9e79345497fdad53873f0acefa0e26fddf Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 22 Jun 2019 12:12:26 +0200 Subject: [PATCH] Add test for linting on 'cfg_attr(,)'. --- .../cfg-attr-empty-is-unused.rs | 13 ++++++++++++ .../cfg-attr-empty-is-unused.stderr | 21 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.rs create mode 100644 src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.stderr diff --git a/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.rs b/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.rs new file mode 100644 index 00000000000..4c96d6e7ca1 --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.rs @@ -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() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.stderr b/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.stderr new file mode 100644 index 00000000000..cd3563e66c7 --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-attr-empty-is-unused.stderr @@ -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 +