Test with NLL explicitly

This commit is contained in:
Yuki Okushi 2020-10-25 11:43:26 +09:00
parent 7b4c397b73
commit 4ec396ea5d
3 changed files with 19 additions and 4 deletions

View File

@ -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();
| ^^^^^^^^^^^^^^^^^^^^^

View File

@ -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

View File

@ -1,3 +1,7 @@
// revisions: nll default
// ignore-compare-mode-nll
//[nll]compile-flags: -Z borrowck=mir
trait TT {}
impl dyn TT {
@ -5,5 +9,6 @@ impl dyn TT {
}
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
}