Skip to content

Commit

Permalink
restructure issue-78262 to test polonius
Browse files Browse the repository at this point in the history
This test is ignored in the NLL compare-mode and manually checks the NLL
output. This makes the polonius compare-mode fail, even though the
output is the same as NLL.
  • Loading branch information
lqd committed Aug 3, 2021
1 parent 6421432 commit 8a21c2f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/test/ui/regions/issue-78262.default.stderr
@@ -1,13 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-78262.rs:12:28
--> $DIR/issue-78262.rs:14: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 12:13...
--> $DIR/issue-78262.rs:12:13
note: the anonymous lifetime #1 defined on the body at 14:13...
--> $DIR/issue-78262.rs:14:13
|
LL | let f = |x: &dyn TT| x.func();
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/regions/issue-78262.nll.stderr
@@ -1,5 +1,5 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/issue-78262.rs:12:26
--> $DIR/issue-78262.rs:14:26
|
LL | let f = |x: &dyn TT| x.func();
| - ^^^^^^^^ `x` escapes the closure body here
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/regions/issue-78262.polonius.stderr
@@ -0,0 +1,11 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/issue-78262.rs:14: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

For more information about this error, try `rustc --explain E0521`.
7 changes: 5 additions & 2 deletions src/test/ui/regions/issue-78262.rs
@@ -1,6 +1,8 @@
// revisions: nll default
// revisions: default nll polonius
// ignore-compare-mode-nll
//[nll]compile-flags: -Z borrowck=mir
// ignore-compare-mode-polonius
// [nll] compile-flags: -Z borrowck=mir
// [polonius] compile-flags: -Z borrowck=mir -Z polonius

trait TT {}

Expand All @@ -11,4 +13,5 @@ impl dyn TT {
fn main() {
let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
//[nll]~^ ERROR: borrowed data escapes outside of closure
//[polonius]~^^ ERROR: borrowed data escapes outside of closure
}

0 comments on commit 8a21c2f

Please sign in to comment.