diff --git a/Cargo.toml b/Cargo.toml index 5b1332b18f5..609f847b4a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ compiletest_rs = "0.0.11" regex = "*" regex_macros = "*" lazy_static = "*" +rustc-serialize = "0.3" [features] diff --git a/tests/compile-fail/used_underscore_binding.rs b/tests/compile-fail/used_underscore_binding.rs index fd1b3bfc162..39a33c96876 100644 --- a/tests/compile-fail/used_underscore_binding.rs +++ b/tests/compile-fail/used_underscore_binding.rs @@ -12,14 +12,6 @@ fn in_macro(_foo: u32) { println!("{}", _foo); //~ ERROR used binding which is prefixed with an underscore } -// TODO: This doesn't actually correctly test this. Need to find a #[derive(...)] which sets off -// the lint if the `in_attributes_expansion` test isn't there -/// Test that we do not lint for unused underscores in a MacroAttribute expansion -#[derive(Clone)] -struct MacroAttributesTest { - _foo: u32, -} - // Struct for testing use of fields prefixed with an underscore struct StructFieldTest { _underscore_field: u32, @@ -76,7 +68,6 @@ fn non_variables() { fn main() { let foo = 0u32; - let _ = MacroAttributesTest{_foo: 0}; // tests of unused_underscore lint let _ = prefix_underscore(foo); in_macro(foo); diff --git a/tests/used_underscore_binding_macro.rs b/tests/used_underscore_binding_macro.rs new file mode 100644 index 00000000000..4170f907b0a --- /dev/null +++ b/tests/used_underscore_binding_macro.rs @@ -0,0 +1,16 @@ +#![feature(plugin)] +#![plugin(clippy)] + +extern crate rustc_serialize; + +/// Test that we do not lint for unused underscores in a MacroAttribute expansion +#[deny(used_underscore_binding)] +#[derive(RustcEncodable)] +struct MacroAttributesTest { + _foo: u32, +} + +#[test] +fn macro_attributes_test() { + let _ = MacroAttributesTest{_foo: 0}; +}