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