]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-17263.rs
New upstream version 1.50.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-17263.rs
1 // check-pass
2
3 #![feature(box_syntax)]
4
5 struct Foo { a: isize, b: isize }
6
7 fn main() {
8 let mut x: Box<_> = box Foo { a: 1, b: 2 };
9 let (a, b) = (&mut x.a, &mut x.b);
10
11 let mut foo: Box<_> = box Foo { a: 1, b: 2 };
12 let (c, d) = (&mut foo.a, &foo.b);
13
14 // We explicitly use the references created above to illustrate that the
15 // borrow checker is accepting this code *not* because of artificially
16 // short lifetimes, but rather because it understands that all the
17 // references are of disjoint parts of memory.
18 use_imm(d);
19 use_mut(c);
20 use_mut(b);
21 use_mut(a);
22 }
23
24 fn use_mut<T>(_: &mut T) { }
25 fn use_imm<T>(_: &T) { }