]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-17263.rs
Rollup merge of #106321 - compiler-errors:delayed-bug-backtrace, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-17263.rs
1 // check-pass
2
3 struct Foo { a: isize, b: isize }
4
5 fn main() {
6     let mut x: Box<_> = Box::new(Foo { a: 1, b: 2 });
7     let (a, b) = (&mut x.a, &mut x.b);
8
9     let mut foo: Box<_> = Box::new(Foo { a: 1, b: 2 });
10     let (c, d) = (&mut foo.a, &foo.b);
11
12     // We explicitly use the references created above to illustrate that the
13     // borrow checker is accepting this code *not* because of artificially
14     // short lifetimes, but rather because it understands that all the
15     // references are of disjoint parts of memory.
16     use_imm(d);
17     use_mut(c);
18     use_mut(b);
19     use_mut(a);
20 }
21
22 fn use_mut<T>(_: &mut T) { }
23 fn use_imm<T>(_: &T) { }