Lint empty 'derive()' as unused attribute.

This commit is contained in:
Mazdak Farrokhzad 2019-06-22 13:19:34 +02:00
parent 305930cffe
commit e994d35e9b
5 changed files with 14 additions and 18 deletions

View File

@ -30,10 +30,6 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) ->
match attr.parse_list(cx.parse_sess,
|parser| parser.parse_path_allowing_meta(PathStyle::Mod)) {
Ok(ref traits) if traits.is_empty() => {
cx.span_warn(attr.span, "empty trait list in `derive`");
false
}
Ok(traits) => {
result.extend(traits);
true

View File

@ -1,6 +1,6 @@
// compile-pass
#![deny(unused)]
#[derive()] //~ WARNING empty trait list in `derive`
struct Bar;
#[derive()] //~ ERROR unused attribute
struct _Bar;
pub fn main() {}

View File

@ -1,6 +1,15 @@
warning: empty trait list in `derive`
error: unused attribute
--> $DIR/deriving-meta-empty-trait-list.rs:3:1
|
LL | #[derive()]
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/deriving-meta-empty-trait-list.rs:1:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: #[deny(unused_attributes)] implied by #[deny(unused)]
error: aborting due to previous error

View File

@ -4,9 +4,6 @@
#[derive(Copy="bad")] //~ ERROR expected one of `)`, `,`, or `::`, found `=`
struct Test2;
#[derive()] //~ WARNING empty trait list
struct Test3;
#[derive] //~ ERROR malformed `derive` attribute input
struct Test4;

View File

@ -10,14 +10,8 @@ error: expected one of `)`, `,`, or `::`, found `=`
LL | #[derive(Copy="bad")]
| ^ expected one of `)`, `,`, or `::` here
warning: empty trait list in `derive`
--> $DIR/malformed-derive-entry.rs:7:1
|
LL | #[derive()]
| ^^^^^^^^^^^
error: malformed `derive` attribute input
--> $DIR/malformed-derive-entry.rs:10:1
--> $DIR/malformed-derive-entry.rs:7:1
|
LL | #[derive]
| ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]`