2020-10-24 08:50:11 +00:00
|
|
|
// aux-build:macro_rules.rs
|
|
|
|
|
2019-09-23 09:19:24 +00:00
|
|
|
#![warn(clippy::toplevel_ref_arg)]
|
|
|
|
#![allow(unused)]
|
|
|
|
|
2020-10-24 08:50:11 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate macro_rules;
|
|
|
|
|
2019-09-23 09:19:24 +00:00
|
|
|
fn the_answer(ref mut x: u8) {
|
|
|
|
*x = 42;
|
|
|
|
}
|
|
|
|
|
2020-10-24 08:50:11 +00:00
|
|
|
macro_rules! gen_function {
|
|
|
|
() => {
|
|
|
|
fn fun_example(ref _x: usize) {}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-23 09:19:24 +00:00
|
|
|
fn main() {
|
|
|
|
let mut x = 0;
|
|
|
|
the_answer(x);
|
2020-10-24 08:50:11 +00:00
|
|
|
|
|
|
|
// lint in macro
|
|
|
|
#[allow(unused)]
|
|
|
|
{
|
|
|
|
gen_function!();
|
|
|
|
}
|
|
|
|
|
|
|
|
// do not lint in external macro
|
|
|
|
{
|
|
|
|
ref_arg_function!();
|
|
|
|
}
|
2019-09-23 09:19:24 +00:00
|
|
|
}
|