Skip to content

Commit 4ec396e

Browse files
committed
Test with NLL explicitly
1 parent 7b4c397 commit 4ec396e

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/test/ui/regions/issue-78262.stderr src/test/ui/regions/issue-78262.default.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-78262.rs:8:28
2+
--> $DIR/issue-78262.rs:12:28
33
|
44
LL | let f = |x: &dyn TT| x.func();
55
| ^^^^ lifetime mismatch
66
|
77
= note: expected reference `&(dyn TT + 'static)`
88
found reference `&dyn TT`
9-
note: the anonymous lifetime #1 defined on the body at 8:13...
10-
--> $DIR/issue-78262.rs:8:13
9+
note: the anonymous lifetime #1 defined on the body at 12:13...
10+
--> $DIR/issue-78262.rs:12:13
1111
|
1212
LL | let f = |x: &dyn TT| x.func();
1313
| ^^^^^^^^^^^^^^^^^^^^^
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0521]: borrowed data escapes outside of closure
2+
--> $DIR/issue-78262.rs:12:26
3+
|
4+
LL | let f = |x: &dyn TT| x.func();
5+
| - ^^^^^^^^ `x` escapes the closure body here
6+
| |
7+
| `x` is a reference that is only valid in the closure body
8+
9+
error: aborting due to previous error
10+

src/test/ui/regions/issue-78262.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
// revisions: nll default
2+
// ignore-compare-mode-nll
3+
//[nll]compile-flags: -Z borrowck=mir
4+
15
trait TT {}
26

37
impl dyn TT {
48
fn func(&self) {}
59
}
610

711
fn main() {
8-
let f = |x: &dyn TT| x.func(); //~ ERROR: mismatched types
12+
let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
13+
//[nll]~^ ERROR: borrowed data escapes outside of closure
914
}

0 commit comments

Comments
 (0)