]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-unused-mut-locals.rs
Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup
[rust.git] / src / test / ui / borrowck / borrowck-unused-mut-locals.rs
1 // run-pass
2 #![deny(unused_mut)]
3
4 #[derive(Debug)]
5 struct A {}
6
7 fn init_a() -> A {
8     A {}
9 }
10
11 #[derive(Debug)]
12 struct B<'a> {
13     ed: &'a mut A,
14 }
15
16 fn init_b<'a>(ed: &'a mut A) -> B<'a> {
17     B { ed }
18 }
19
20 #[derive(Debug)]
21 struct C<'a> {
22     pd: &'a mut B<'a>,
23 }
24
25 fn init_c<'a>(pd: &'a mut B<'a>) -> C<'a> {
26     C { pd }
27 }
28
29 #[derive(Debug)]
30 struct D<'a> {
31     sd: &'a mut C<'a>,
32 }
33
34 fn init_d<'a>(sd: &'a mut C<'a>) -> D<'a> {
35     D { sd }
36 }
37
38 fn main() {
39     let mut a = init_a();
40     let mut b = init_b(&mut a);
41     let mut c = init_c(&mut b);
42
43     let d = init_d(&mut c);
44
45     println!("{:?}", d)
46 }