mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Filter out proc_macro_derive functions (fixes #1615)
This commit is contained in:
parent
b409356a04
commit
a712271df6
2 changed files with 24 additions and 2 deletions
|
@ -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.
|
||||
|
|
11
tests/ui/needless_pass_by_value_proc_macro.rs
Normal file
11
tests/ui/needless_pass_by_value_proc_macro.rs
Normal 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!() }
|
Loading…
Reference in a new issue