mirror of https://github.com/rust-lang/rust.git
Filter out proc_macro_derive functions (fixes #1615)
This commit is contained in:
parent
b409356a04
commit
a712271df6
|
@ -55,8 +55,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !matches!(kind, FnKind::ItemFn(..)) {
|
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;
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => return,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows these to be passed by value.
|
// Allows these to be passed by value.
|
||||||
|
|
|
@ -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!() }
|
Loading…
Reference in New Issue