]> git.lizzy.rs Git - rust.git/commitdiff
escape-argument-callee: improve comment per arielb1's suggestions
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 6 Dec 2017 21:18:28 +0000 (16:18 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 7 Dec 2017 10:28:02 +0000 (05:28 -0500)
src/test/ui/nll/closure-requirements/escape-argument-callee.rs
src/test/ui/nll/closure-requirements/escape-argument-callee.stderr

index dae8c84224015b6970ca2777afe5c35ce91d1d8e..1e34aaf1ea03003e92c37f0138ed0c030b7f1be9 100644 (file)
 
 // Test closure that:
 //
-// - takes an argument `y`
-// - stores `y` into another, longer-lived spot
+// - takes an argument `y` with lifetime `'a` (in the code, it's anonymous)
+// - stores `y` into another, longer-lived spot with lifetime `'b`
 //
-// *but* the signature of the closure doesn't indicate that `y` lives
-// long enough for that. The closure reports the error (and hence we
-// see it before the closure's "external requirements" report).
+// Because `'a` and `'b` are two different, unrelated higher-ranked
+// regions with no relationship to one another, this is an error. This
+// error is reported by the closure itself and is not propagated to
+// its creator: this is because `'a` and `'b` are higher-ranked
+// (late-bound) regions and the closure is not allowed to propagate
+// additional where clauses between higher-ranked regions, only those
+// that appear free in its type (hence, we see it before the closure's
+// "external requirements" report).
 
 // compile-flags:-Znll -Zborrowck=mir -Zverbose
 
index 2d36143d5b324750f8d895e871f90e0ecbc2ae37..c842d51a2ad749554a4a1864ad258c2887051ef0 100644 (file)
@@ -1,19 +1,19 @@
 warning: not reporting region error due to -Znll
-  --> $DIR/escape-argument-callee.rs:31:50
+  --> $DIR/escape-argument-callee.rs:36:50
    |
-31 |         let mut closure = expect_sig(|p, y| *p = y);
+36 |         let mut closure = expect_sig(|p, y| *p = y);
    |                                                  ^
 
 error: free region `'_#4r` does not outlive free region `'_#3r`
-  --> $DIR/escape-argument-callee.rs:31:45
+  --> $DIR/escape-argument-callee.rs:36:45
    |
-31 |         let mut closure = expect_sig(|p, y| *p = y);
+36 |         let mut closure = expect_sig(|p, y| *p = y);
    |                                             ^^^^^^
 
 note: External requirements
-  --> $DIR/escape-argument-callee.rs:31:38
+  --> $DIR/escape-argument-callee.rs:36:38
    |
-31 |         let mut closure = expect_sig(|p, y| *p = y);
+36 |         let mut closure = expect_sig(|p, y| *p = y);
    |                                      ^^^^^^^^^^^^^
    |
    = note: defining type: DefId(0/1:9 ~ escape_argument_callee[317d]::test[0]::{{closure}}[0]) with closure substs [
@@ -23,15 +23,15 @@ note: External requirements
    = note: number of external vids: 1
 
 note: No external requirements
-  --> $DIR/escape-argument-callee.rs:25:1
+  --> $DIR/escape-argument-callee.rs:30:1
    |
-25 | / fn test() {
-26 | |     let x = 44;
-27 | |     let mut p = &x;
-28 | |
+30 | / fn test() {
+31 | |     let x = 44;
+32 | |     let mut p = &x;
+33 | |
 ...  |
-37 | |     deref(p);
-38 | | }
+42 | |     deref(p);
+43 | | }
    | |_^
    |
    = note: defining type: DefId(0/0:3 ~ escape_argument_callee[317d]::test[0]) with substs []