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