summaryrefslogtreecommitdiffstats
path: root/tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs')
-rw-r--r--tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs b/tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs
new file mode 100644
index 000000000..3664d76c2
--- /dev/null
+++ b/tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs
@@ -0,0 +1,19 @@
+// edition:2021
+
+#[derive(Debug)]
+struct Point {
+ x: i32,
+ y: i32,
+}
+fn main() {
+ let mut p = Point {x: 1, y: 2 };
+
+ let y = &mut p.y;
+ let mut c = || {
+ //~^ ERROR cannot borrow `p` as mutable more than once at a time
+ let x = &mut p.x;
+ println!("{:?}", p);
+ };
+ c();
+ *y+=1;
+}