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