File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed
src/test/ui/nll/closure-requirements Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 17
17
// enough to store `y`.
18
18
//
19
19
// 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.
22
24
23
25
// compile-flags:-Znll -Zborrowck=mir -Zverbose
24
26
Original file line number Diff line number Diff line change 1
1
note: External requirements
2
- --> $DIR/escape-argument.rs:34 :38
2
+ --> $DIR/escape-argument.rs:36 :38
3
3
|
4
- 34 | let mut closure = expect_sig(|p, y| *p = y);
4
+ 36 | let mut closure = expect_sig(|p, y| *p = y);
5
5
| ^^^^^^^^^^^^^
6
6
|
7
7
= note: defining type: DefId(0/1:9 ~ escape_argument[317d]::test[0]::{{closure}}[0]) with closure substs [
@@ -11,26 +11,26 @@ note: External requirements
11
11
= note: number of external vids: 1
12
12
13
13
note: No external requirements
14
- --> $DIR/escape-argument.rs:28 :1
14
+ --> $DIR/escape-argument.rs:30 :1
15
15
|
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 | |
20
20
... |
21
- 39 | | deref(p);
22
- 40 | | }
21
+ 41 | | deref(p);
22
+ 42 | | }
23
23
| |_^
24
24
|
25
25
= note: defining type: DefId(0/0:3 ~ escape_argument[317d]::test[0]) with substs []
26
26
27
27
error[E0597]: borrowed value does not live long enough
28
- --> $DIR/escape-argument.rs:36 :6
28
+ --> $DIR/escape-argument.rs:38 :6
29
29
|
30
- 33 | let y = 22;
30
+ 35 | let y = 22;
31
31
| - temporary value created here
32
32
...
33
- 36 | }
33
+ 38 | }
34
34
| ^ temporary value dropped here while still borrowed
35
35
|
36
36
= note: consider using a `let` binding to increase its lifetime
You can’t perform that action at this time.
0 commit comments