Skip to content

Commit dac59ac

Browse files
committed
escape-argument-callee: improve comment per arielb1's suggestions
1 parent 05977fe commit dac59ac

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/test/ui/nll/closure-requirements/escape-argument-callee.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010

1111
// Test closure that:
1212
//
13-
// - takes an argument `y`
14-
// - stores `y` into another, longer-lived spot
13+
// - takes an argument `y` with lifetime `'a` (in the code, it's anonymous)
14+
// - stores `y` into another, longer-lived spot with lifetime `'b`
1515
//
16-
// *but* the signature of the closure doesn't indicate that `y` lives
17-
// long enough for that. The closure reports the error (and hence we
18-
// see it before the closure's "external requirements" report).
16+
// Because `'a` and `'b` are two different, unrelated higher-ranked
17+
// regions with no relationship to one another, this is an error. This
18+
// error is reported by the closure itself and is not propagated to
19+
// its creator: this is because `'a` and `'b` are higher-ranked
20+
// (late-bound) regions and the closure is not allowed to propagate
21+
// additional where clauses between higher-ranked regions, only those
22+
// that appear free in its type (hence, we see it before the closure's
23+
// "external requirements" report).
1924

2025
// compile-flags:-Znll -Zborrowck=mir -Zverbose
2126

src/test/ui/nll/closure-requirements/escape-argument-callee.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
warning: not reporting region error due to -Znll
2-
--> $DIR/escape-argument-callee.rs:31:50
2+
--> $DIR/escape-argument-callee.rs:36:50
33
|
4-
31 | let mut closure = expect_sig(|p, y| *p = y);
4+
36 | let mut closure = expect_sig(|p, y| *p = y);
55
| ^
66

77
error: free region `'_#4r` does not outlive free region `'_#3r`
8-
--> $DIR/escape-argument-callee.rs:31:45
8+
--> $DIR/escape-argument-callee.rs:36:45
99
|
10-
31 | let mut closure = expect_sig(|p, y| *p = y);
10+
36 | let mut closure = expect_sig(|p, y| *p = y);
1111
| ^^^^^^
1212

1313
note: External requirements
14-
--> $DIR/escape-argument-callee.rs:31:38
14+
--> $DIR/escape-argument-callee.rs:36:38
1515
|
16-
31 | let mut closure = expect_sig(|p, y| *p = y);
16+
36 | let mut closure = expect_sig(|p, y| *p = y);
1717
| ^^^^^^^^^^^^^
1818
|
1919
= 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
2323
= note: number of external vids: 1
2424

2525
note: No external requirements
26-
--> $DIR/escape-argument-callee.rs:25:1
26+
--> $DIR/escape-argument-callee.rs:30:1
2727
|
28-
25 | / fn test() {
29-
26 | | let x = 44;
30-
27 | | let mut p = &x;
31-
28 | |
28+
30 | / fn test() {
29+
31 | | let x = 44;
30+
32 | | let mut p = &x;
31+
33 | |
3232
... |
33-
37 | | deref(p);
34-
38 | | }
33+
42 | | deref(p);
34+
43 | | }
3535
| |_^
3636
|
3737
= note: defining type: DefId(0/0:3 ~ escape_argument_callee[317d]::test[0]) with substs []

0 commit comments

Comments
 (0)