]> git.lizzy.rs Git - rust.git/commitdiff
escape-upvar-ref: patch comment per arielb1
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 6 Dec 2017 21:19:26 +0000 (16:19 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 7 Dec 2017 10:28:03 +0000 (05:28 -0500)
src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

index 5d14501cdbba71abbcc1be889e6e703e4b912c64..548a5ae59690c0bac938a6a1acf402d32ca71465 100644 (file)
@@ -9,8 +9,15 @@
 // except according to those terms.
 
 // Test closure that:
-// - captures a variable `y`
-// - stores reference to `y` into another, longer-lived spot
+//
+// - captures a variable `y` by reference
+// - stores that reference to `y` into another, longer-lived place (`p`)
+//
+// Both of these are upvars of reference type (the capture of `y` is
+// of type `&'a i32`, the capture of `p` is of type `&mut &'b
+// i32`). The closure thus computes a relationship between `'a` and
+// `'b`.  This relationship is propagated to the closure creator,
+// which reports an error.
 
 // compile-flags:-Znll -Zborrowck=mir -Zverbose
 
index 0a182fbc278e805133dc12caa496021c71dd5a4a..47ba66ade6533ed4bed408710cb97f1cf828cf3a 100644 (file)
@@ -1,7 +1,7 @@
 note: External requirements
-  --> $DIR/escape-upvar-ref.rs:26:27
+  --> $DIR/escape-upvar-ref.rs:33:27
    |
-26 |         let mut closure = || p = &y;
+33 |         let mut closure = || p = &y;
    |                           ^^^^^^^^^
    |
    = note: defining type: DefId(0/1:9 ~ escape_upvar_ref[317d]::test[0]::{{closure}}[0]) with closure substs [
@@ -14,26 +14,26 @@ note: External requirements
    = note: where '_#3r: '_#2r
 
 note: No external requirements
-  --> $DIR/escape-upvar-ref.rs:20:1
+  --> $DIR/escape-upvar-ref.rs:27:1
    |
-20 | / fn test() {
-21 | |     let x = 44;
-22 | |     let mut p = &x;
-23 | |
+27 | / fn test() {
+28 | |     let x = 44;
+29 | |     let mut p = &x;
+30 | |
 ...  |
-30 | |     deref(p);
-31 | | }
+37 | |     deref(p);
+38 | | }
    | |_^
    |
    = note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
 
 error[E0597]: borrowed value does not live long enough
-  --> $DIR/escape-upvar-ref.rs:28:6
+  --> $DIR/escape-upvar-ref.rs:35:6
    |
-25 |         let y = 22;
+32 |         let y = 22;
    |             - temporary value created here
 ...
-28 |     } //~ ERROR borrowed value does not live long enough
+35 |     } //~ ERROR borrowed value does not live long enough
    |      ^ temporary value dropped here while still borrowed
    |
    = note: consider using a `let` binding to increase its lifetime