Filter out proc_macro_derive functions (fixes #1615)

This commit is contained in:
sinkuu 2017-03-13 07:30:18 +09:00
parent b409356a04
commit a712271df6
2 changed files with 24 additions and 2 deletions

View file

@ -55,8 +55,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
return;
}
if !matches!(kind, FnKind::ItemFn(..)) {
return;
match kind {
FnKind::ItemFn(.., attrs) => {
for a in attrs {
if_let_chain!{[
a.meta_item_list().is_some(),
let Some(name) = a.name(),
&*name.as_str() == "proc_macro_derive",
], {
return;
}}
}
},
_ => return,
}
// Allows these to be passed by value.

View file

@ -0,0 +1,11 @@
#![feature(plugin)]
#![plugin(clippy)]
#![crate_type = "proc-macro"]
#![deny(needless_pass_by_value)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(Foo)]
pub fn foo(_input: TokenStream) -> TokenStream { unimplemented!() }