Skip to content

Commit 782b9f5

Browse files
committed
escape-argument: improve comment per arielb1's suggestion
1 parent dac59ac commit 782b9f5

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
// enough to store `y`.
1818
//
1919
// The error is reported in the caller: invoking the closure links the
20-
// lifetime of the borrow that is given as `y` and forces it to live
21-
// too long.
20+
// lifetime of the variable that is given as `y` (via subtyping) and
21+
// thus forces the corresponding borrow to live too long. This is
22+
// basically checking that the MIR type checker correctly enforces the
23+
// closure signature.
2224

2325
// compile-flags:-Znll -Zborrowck=mir -Zverbose
2426

src/test/ui/nll/closure-requirements/escape-argument.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-argument.rs:34:38
2+
--> $DIR/escape-argument.rs:36:38
33
|
4-
34 | let mut closure = expect_sig(|p, y| *p = y);
4+
36 | let mut closure = expect_sig(|p, y| *p = y);
55
| ^^^^^^^^^^^^^
66
|
77
= note: defining type: DefId(0/1:9 ~ escape_argument[317d]::test[0]::{{closure}}[0]) with closure substs [
@@ -11,26 +11,26 @@ note: External requirements
1111
= note: number of external vids: 1
1212

1313
note: No external requirements
14-
--> $DIR/escape-argument.rs:28:1
14+
--> $DIR/escape-argument.rs:30:1
1515
|
16-
28 | / fn test() {
17-
29 | | let x = 44;
18-
30 | | let mut p = &x;
19-
31 | |
16+
30 | / fn test() {
17+
31 | | let x = 44;
18+
32 | | let mut p = &x;
19+
33 | |
2020
... |
21-
39 | | deref(p);
22-
40 | | }
21+
41 | | deref(p);
22+
42 | | }
2323
| |_^
2424
|
2525
= note: defining type: DefId(0/0:3 ~ escape_argument[317d]::test[0]) with substs []
2626

2727
error[E0597]: borrowed value does not live long enough
28-
--> $DIR/escape-argument.rs:36:6
28+
--> $DIR/escape-argument.rs:38:6
2929
|
30-
33 | let y = 22;
30+
35 | let y = 22;
3131
| - temporary value created here
3232
...
33-
36 | }
33+
38 | }
3434
| ^ temporary value dropped here while still borrowed
3535
|
3636
= note: consider using a `let` binding to increase its lifetime

0 commit comments

Comments
 (0)