]> git.lizzy.rs Git - rust.git/blob - tests/ui/toplevel_ref_arg.rs
Add regression test for macro expansion
[rust.git] / tests / ui / toplevel_ref_arg.rs
1 // run-rustfix
2
3 #![warn(clippy::toplevel_ref_arg)]
4 #![allow(unused)]
5
6 fn main() {
7     // Closures should not warn
8     let y = |ref x| println!("{:?}", x);
9     y(1u8);
10
11     let ref x = 1;
12
13     let ref y: (&_, u8) = (&1, 2);
14
15     let ref z = 1 + 2;
16
17     let ref mut z = 1 + 2;
18
19     let (ref x, _) = (1, 2); // ok, not top level
20     println!("The answer is {}.", x);
21
22     let ref x = vec![1, 2, 3];
23
24     // Make sure that allowing the lint works
25     #[allow(clippy::toplevel_ref_arg)]
26     let ref mut x = 1_234_543;
27 }