]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/borrowck/issue-85765.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / borrowck / issue-85765.rs
index b82e0298158aa7c0a22af435a46a5efcd00d930c..1a5f7434fe2bb2173d8183a060bfa7d8790033cd 100644 (file)
@@ -5,4 +5,11 @@ fn main() {
     rofl.push(Vec::new());
     //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference
     //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+
+    let mut mutvar = 42;
+    let r = &mutvar;
+    //~^ HELP consider changing this to be a mutable reference
+    *r = 0;
+    //~^ ERROR cannot assign to `*r`, which is behind a `&` reference
+    //~| NOTE `r` is a `&` reference, so the data it refers to cannot be written
 }