Skip to content

Commit c7f9a71

Browse files
committed
issue-46589 passes in Polonius and fails in NLL, duplicate it and manually check each outcome
1 parent 770129c commit c7f9a71

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/test/ui/nll/issue-46589.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// This tests passes in Polonius mode, so is skipped in the automated compare-mode.
2+
// We will manually check it passes in Polonius tests, as we can't have a test here
3+
// which conditionally passes depending on a test revision/compile-flags.
4+
5+
// ignore-compare-mode-polonius
6+
17
struct Foo;
28

39
impl Foo {

src/test/ui/nll/issue-46589.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0499]: cannot borrow `**other` as mutable more than once at a time
2-
--> $DIR/issue-46589.rs:17:21
2+
--> $DIR/issue-46589.rs:23:21
33
|
44
LL | *other = match (*other).get_self() {
55
| -------- first mutable borrow occurs here
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This test is a copy of `ui/nll/issue-46589.rs` which fails in NLL but succeeds in Polonius.
2+
// As we can't have a test here which conditionally passes depending on a test
3+
// revision/compile-flags. We ensure here that it passes in Polonius mode.
4+
5+
// check-pass
6+
// compile-flags: -Z borrowck=mir -Z polonius
7+
// ignore-compare-mode-nll
8+
9+
struct Foo;
10+
11+
impl Foo {
12+
fn get_self(&mut self) -> Option<&mut Self> {
13+
Some(self)
14+
}
15+
16+
fn new_self(&mut self) -> &mut Self {
17+
self
18+
}
19+
20+
fn trigger_bug(&mut self) {
21+
let other = &mut (&mut *self);
22+
23+
*other = match (*other).get_self() {
24+
Some(s) => s,
25+
None => (*other).new_self()
26+
};
27+
28+
let c = other;
29+
}
30+
}
31+
32+
fn main() {}

0 commit comments

Comments
 (0)