Merge pull request #1617 from sinkuu/proc_macro_pass_by_value

Filter out proc_macro_derive functions
This commit is contained in:
Oliver Schneider 2017-03-24 10:10:24 +01:00 committed by GitHub
commit 4f473f7f60
2 changed files with 24 additions and 2 deletions

View File

@ -59,8 +59,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!() }