fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1//@aux-build:proc_macros.rs 2#![warn(clippy::toplevel_ref_arg)] 3#![allow(clippy::uninlined_format_args, unused, clippy::useless_vec)] 4 5extern crate proc_macros; 6use proc_macros::{external, inline_macros}; 7 8#[inline_macros] 9fn main() { 10 // Closures should not warn 11 let y = |ref x| println!("{:?}", x); 12 y(1u8); 13 14 let _x = &1; 15 16 let _y: &(&_, u8) = &(&1, 2); 17 18 let _z = &(1 + 2); 19 20 let _z = &mut (1 + 2); 21 22 let (ref x, _) = (1, 2); // ok, not top level 23 println!("The answer is {}.", x); 24 25 let _x = &vec![1, 2, 3]; 26 27 // Make sure that allowing the lint works 28 #[allow(clippy::toplevel_ref_arg)] 29 let ref mut _x = 1_234_543; 30 31 // ok 32 for ref _x in 0..10 {} 33 34 // lint in macro 35 inline!(let _y = &42;); 36 37 // do not lint in external macro 38 external!(let ref _y = 42;); 39}