issue-46589 passes in Polonius and fails in NLL, duplicate it and manually check each outcome

This commit is contained in:
lqd 2019-07-16 17:34:06 +02:00
parent 770129c280
commit c7f9a71d78
3 changed files with 39 additions and 1 deletions

View file

@ -1,3 +1,9 @@
// This tests passes in Polonius mode, so is skipped in the automated compare-mode.
// We will manually check it passes in Polonius tests, as we can't have a test here
// which conditionally passes depending on a test revision/compile-flags.
// ignore-compare-mode-polonius
struct Foo;
impl Foo {

View file

@ -1,5 +1,5 @@
error[E0499]: cannot borrow `**other` as mutable more than once at a time
--> $DIR/issue-46589.rs:17:21
--> $DIR/issue-46589.rs:23:21
|
LL | *other = match (*other).get_self() {
| -------- first mutable borrow occurs here

View file

@ -0,0 +1,32 @@
// This test is a copy of `ui/nll/issue-46589.rs` which fails in NLL but succeeds in Polonius.
// As we can't have a test here which conditionally passes depending on a test
// revision/compile-flags. We ensure here that it passes in Polonius mode.
// check-pass
// compile-flags: -Z borrowck=mir -Z polonius
// ignore-compare-mode-nll
struct Foo;
impl Foo {
fn get_self(&mut self) -> Option<&mut Self> {
Some(self)
}
fn new_self(&mut self) -> &mut Self {
self
}
fn trigger_bug(&mut self) {
let other = &mut (&mut *self);
*other = match (*other).get_self() {
Some(s) => s,
None => (*other).new_self()
};
let c = other;
}
}
fn main() {}