mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Merge pull request #1617 from sinkuu/proc_macro_pass_by_value
Filter out proc_macro_derive functions
This commit is contained in:
commit
4f473f7f60
@ -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.
|
||||
|
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 New Issue
Block a user