diff options
| author | lqd <remy.rakic+github@gmail.com> | 2019-07-16 17:34:06 +0200 |
|---|---|---|
| committer | lqd <remy.rakic+github@gmail.com> | 2019-07-22 12:46:55 +0200 |
| commit | c7f9a71d7875e5acced7f3a1b9f05a46be2104f4 (patch) | |
| tree | c944ce2887002ccac44b3716df762af61336d32b /src | |
| parent | 770129c28039ab7501cdc0f2f7ca1a38e22208f0 (diff) | |
| download | rust-c7f9a71d7875e5acced7f3a1b9f05a46be2104f4.tar.gz rust-c7f9a71d7875e5acced7f3a1b9f05a46be2104f4.zip | |
issue-46589 passes in Polonius and fails in NLL, duplicate it and manually check each outcome
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/nll/issue-46589.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/nll/issue-46589.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/nll/polonius/issue-46589.rs | 32 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/test/ui/nll/issue-46589.rs b/src/test/ui/nll/issue-46589.rs index 8c0c356e967..0a4c20d1515 100644 --- a/src/test/ui/nll/issue-46589.rs +++ b/src/test/ui/nll/issue-46589.rs @@ -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 { diff --git a/src/test/ui/nll/issue-46589.stderr b/src/test/ui/nll/issue-46589.stderr index 397909a4366..82cd364eeff 100644 --- a/src/test/ui/nll/issue-46589.stderr +++ b/src/test/ui/nll/issue-46589.stderr @@ -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 diff --git a/src/test/ui/nll/polonius/issue-46589.rs b/src/test/ui/nll/polonius/issue-46589.rs new file mode 100644 index 00000000000..b5792587ff0 --- /dev/null +++ b/src/test/ui/nll/polonius/issue-46589.rs @@ -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() {} |
