30 lines
753 B
Rust
Raw Normal View History

#![feature(proc_macro_quote)]
#![deny(rust_2018_idioms)]
2019-12-30 17:02:18 +09:00
// FIXME: Remove this attribute once the weird failure is gone.
#![allow(unused_extern_crates)]
extern crate proc_macro;
2016-06-25 18:12:29 +02:00
2019-07-18 17:23:22 +02:00
use proc_macro::{quote, TokenStream};
2016-06-25 18:12:29 +02:00
#[proc_macro_derive(ClippyMiniMacroTest)]
2020-12-30 16:37:59 -06:00
/// # Panics
///
/// Panics if the macro derivation fails
pub fn mini_macro(_: TokenStream) -> TokenStream {
quote!(
2019-07-18 17:23:22 +02:00
#[allow(unused)]
fn needless_take_by_value(s: String) {
println!("{}", s.len());
}
#[allow(unused)]
fn needless_loop(items: &[u8]) {
for i in 0..items.len() {
println!("{}", items[i]);
}
}
fn line_wrapper() {
println!("{}", line!());
}
)
}