merge duplicate issue-46589 tests

also add explicit revisions for -Zpolonius=next
This commit is contained in:
Rémy Rakic 2025-01-30 12:47:04 +00:00
parent 6ce46a82cb
commit bb1385ca8b
4 changed files with 8 additions and 39 deletions

View file

@ -3146,7 +3146,6 @@ ui/nll/issue-97997.rs
ui/nll/issue-98170.rs
ui/nll/issue-98589-closures-relate-named-regions.rs
ui/nll/issue-98693.rs
ui/nll/polonius/issue-46589.rs
ui/nll/relate_tys/issue-48071.rs
ui/nll/ty-outlives/issue-53789-1.rs
ui/nll/ty-outlives/issue-53789-2.rs

View file

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

View file

@ -1,8 +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
//@ ignore-compare-mode-polonius (explicit revisions)
//@ revisions: nll polonius_next polonius
//@ [polonius_next] check-pass
//@ [polonius_next] compile-flags: -Zpolonius=next
//@ [polonius] check-pass
//@ [polonius] compile-flags: -Zpolonius
struct Foo;
@ -21,7 +22,7 @@ impl Foo {
*other = match (*other).get_self() {
Some(s) => s,
None => (*other).new_self()
//~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499]
//[nll]~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499]
};
let c = other;

View file

@ -1,31 +0,0 @@
// 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 polonius
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() {}