Skip to content

Commit 6ee31e2

Browse files
committed
escape-upvar-ref: patch comment per arielb1
1 parent 8b657d3 commit 6ee31e2

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/test/ui/nll/closure-requirements/escape-upvar-ref.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@
99
// except according to those terms.
1010

1111
// Test closure that:
12-
// - captures a variable `y`
13-
// - stores reference to `y` into another, longer-lived spot
12+
//
13+
// - captures a variable `y` by reference
14+
// - stores that reference to `y` into another, longer-lived place (`p`)
15+
//
16+
// Both of these are upvars of reference type (the capture of `y` is
17+
// of type `&'a i32`, the capture of `p` is of type `&mut &'b
18+
// i32`). The closure thus computes a relationship between `'a` and
19+
// `'b`. This relationship is propagated to the closure creator,
20+
// which reports an error.
1421

1522
// compile-flags:-Znll -Zborrowck=mir -Zverbose
1623

src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
note: External requirements
2-
--> $DIR/escape-upvar-ref.rs:26:27
2+
--> $DIR/escape-upvar-ref.rs:33:27
33
|
4-
26 | let mut closure = || p = &y;
4+
33 | let mut closure = || p = &y;
55
| ^^^^^^^^^
66
|
77
= 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
1414
= note: where '_#3r: '_#2r
1515

1616
note: No external requirements
17-
--> $DIR/escape-upvar-ref.rs:20:1
17+
--> $DIR/escape-upvar-ref.rs:27:1
1818
|
19-
20 | / fn test() {
20-
21 | | let x = 44;
21-
22 | | let mut p = &x;
22-
23 | |
19+
27 | / fn test() {
20+
28 | | let x = 44;
21+
29 | | let mut p = &x;
22+
30 | |
2323
... |
24-
30 | | deref(p);
25-
31 | | }
24+
37 | | deref(p);
25+
38 | | }
2626
| |_^
2727
|
2828
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
2929

3030
error[E0597]: borrowed value does not live long enough
31-
--> $DIR/escape-upvar-ref.rs:28:6
31+
--> $DIR/escape-upvar-ref.rs:35:6
3232
|
33-
25 | let y = 22;
33+
32 | let y = 22;
3434
| - temporary value created here
3535
...
36-
28 | } //~ ERROR borrowed value does not live long enough
36+
35 | } //~ ERROR borrowed value does not live long enough
3737
| ^ temporary value dropped here while still borrowed
3838
|
3939
= note: consider using a `let` binding to increase its lifetime

0 commit comments

Comments
 (0)