]> git.proxmox.com Git - rustc.git/blob - tests/ui/closures/2229_closure_analysis/diagnostics/multilevel-path.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / closures / 2229_closure_analysis / diagnostics / multilevel-path.rs
1 // edition:2021
2
3 // Test that when a borrow checker diagnostics are emitted, it's as precise
4 // as the capture by the closure.
5
6 #![allow(unused)]
7
8 struct Point {
9 x: i32,
10 y: i32,
11 }
12 struct Wrapper {
13 p: Point,
14 }
15
16 fn main() {
17 let mut w = Wrapper { p: Point { x: 10, y: 10 } };
18
19 let mut c = || {
20 w.p.x += 20;
21 };
22
23 let py = &mut w.p.x;
24 //~^ ERROR: cannot borrow `w.p.x` as mutable more than once at a time
25 c();
26
27 *py = 20
28 }