Skip to content

Commit

Permalink
Test with NLL explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Oct 25, 2020
1 parent 7b4c397 commit 4ec396e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-78262.rs:8:28
--> $DIR/issue-78262.rs:12:28
|
LL | let f = |x: &dyn TT| x.func();
| ^^^^ lifetime mismatch
|
= note: expected reference `&(dyn TT + 'static)`
found reference `&dyn TT`
note: the anonymous lifetime #1 defined on the body at 8:13...
--> $DIR/issue-78262.rs:8:13
note: the anonymous lifetime #1 defined on the body at 12:13...
--> $DIR/issue-78262.rs:12:13
|
LL | let f = |x: &dyn TT| x.func();
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/regions/issue-78262.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/issue-78262.rs:12:26
|
LL | let f = |x: &dyn TT| x.func();
| - ^^^^^^^^ `x` escapes the closure body here
| |
| `x` is a reference that is only valid in the closure body

error: aborting due to previous error

7 changes: 6 additions & 1 deletion src/test/ui/regions/issue-78262.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// revisions: nll default
// ignore-compare-mode-nll
//[nll]compile-flags: -Z borrowck=mir

trait TT {}

impl dyn TT {
fn func(&self) {}
}

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

0 comments on commit 4ec396e

Please sign in to comment.