escape-argument-callee: improve comment per arielb1's suggestions

This commit is contained in:
Niko Matsakis 2017-12-06 16:18:28 -05:00
parent 05977fe751
commit dac59ac93a
2 changed files with 23 additions and 18 deletions

View File

@ -10,12 +10,17 @@
// 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

View 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 []