]> git.lizzy.rs Git - rust.git/blob - tests/ui/mut_mut.rs
Auto merge of #8374 - Alexendoo:bless-revisions, r=camsteffen
[rust.git] / tests / ui / mut_mut.rs
1 // aux-build:macro_rules.rs
2
3 #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
4 #![warn(clippy::mut_mut)]
5
6 #[macro_use]
7 extern crate macro_rules;
8
9 fn fun(x: &mut &mut u32) -> bool {
10     **x > 0
11 }
12
13 fn less_fun(x: *mut *mut u32) {
14     let y = x;
15 }
16
17 macro_rules! mut_ptr {
18     ($p:expr) => {
19         &mut $p
20     };
21 }
22
23 #[allow(unused_mut, unused_variables)]
24 fn main() {
25     let mut x = &mut &mut 1u32;
26     {
27         let mut y = &mut x;
28     }
29
30     if fun(x) {
31         let y: &mut &mut u32 = &mut &mut 2;
32         **y + **x;
33     }
34
35     if fun(x) {
36         let y: &mut &mut &mut u32 = &mut &mut &mut 2;
37         ***y + **x;
38     }
39
40     let mut z = mut_ptr!(&mut 3u32);
41 }
42
43 fn issue939() {
44     let array = [5, 6, 7, 8, 9];
45     let mut args = array.iter().skip(2);
46     for &arg in &mut args {
47         println!("{}", arg);
48     }
49
50     let args = &mut args;
51     for arg in args {
52         println!(":{}", arg);
53     }
54 }
55
56 fn issue6922() {
57     // do not lint from an external macro
58     mut_mut!();
59 }