mark polonius=next's NLL imprecisions as known-bugs

- linked-list cursor-like patterns
- issue-46589

These are known-bugs for the polonius alpha, where they show the same
imprecision as NLLs, but are supported by the old datalog
implementation.
This commit is contained in:
Rémy Rakic 2025-08-08 14:29:50 +00:00
parent 9badbdf5f9
commit b99fe2b720
12 changed files with 90 additions and 20 deletions

View file

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

View file

@ -0,0 +1,15 @@
error[E0499]: cannot borrow `**other` as mutable more than once at a time
--> $DIR/issue-46589.rs:25:21
|
LL | *other = match (*other).get_self() {
| -------- first mutable borrow occurs here
LL | Some(s) => s,
LL | None => (*other).new_self()
| ^^^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0499`.

View file

@ -1,9 +1,10 @@
//@ 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
//@ revisions: nll polonius legacy
//@ [nll] known-bug: #46589
//@ [polonius] known-bug: #46589
//@ [polonius] compile-flags: -Zpolonius=next
//@ [legacy] check-pass
//@ [legacy] compile-flags: -Zpolonius=legacy
struct Foo;
@ -22,7 +23,6 @@ impl Foo {
*other = match (*other).get_self() {
Some(s) => s,
None => (*other).new_self()
//[nll]~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499]
};
let c = other;

View file

@ -1,5 +1,5 @@
error[E0499]: cannot borrow `*elements` as mutable more than once at a time
--> $DIR/iterating-updating-cursor-issue-108704.rs:40:26
--> $DIR/iterating-updating-cursor-issue-108704.rs:41:26
|
LL | for (idx, el) in elements.iter_mut().enumerate() {
| ^^^^^^^^

View file

@ -0,0 +1,12 @@
error[E0499]: cannot borrow `*elements` as mutable more than once at a time
--> $DIR/iterating-updating-cursor-issue-108704.rs:41:26
|
LL | for (idx, el) in elements.iter_mut().enumerate() {
| ^^^^^^^^
| |
| `*elements` was mutably borrowed here in the previous iteration of the loop
| first borrow used here, in later iteration of loop
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0499`.

View file

@ -1,11 +1,12 @@
#![crate_type = "lib"]
// An example from #108704 of the linked-list cursor-like pattern of #46859/#48001.
// An example from #108704 of the linked-list cursor-like pattern of #46859/#48001, where the
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
//@ ignore-compare-mode-polonius (explicit revisions)
//@ revisions: nll polonius legacy
//@ [nll] known-bug: #108704
//@ [polonius] check-pass
//@ [polonius] known-bug: #108704
//@ [polonius] compile-flags: -Z polonius=next
//@ [legacy] check-pass
//@ [legacy] compile-flags: -Z polonius=legacy
@ -32,7 +33,7 @@ fn merge_tree_ok(root: &mut Root, path: Vec<String>) {
}
}
// NLLs fail here
// NLLs and polonius alpha fail here
fn merge_tree_ko(root: &mut Root, path: Vec<String>) {
let mut elements = &mut root.children;

View file

@ -1,5 +1,5 @@
error[E0499]: cannot borrow `p.0` as mutable more than once at a time
--> $DIR/iterating-updating-cursor-issue-57165.rs:29:20
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:20
|
LL | while let Some(now) = p {
| ^^^ - first borrow used here, in later iteration of loop
@ -7,7 +7,7 @@ LL | while let Some(now) = p {
| `p.0` was mutably borrowed here in the previous iteration of the loop
error[E0503]: cannot use `*p` because it was mutably borrowed
--> $DIR/iterating-updating-cursor-issue-57165.rs:29:27
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:27
|
LL | while let Some(now) = p {
| --- ^

View file

@ -0,0 +1,22 @@
error[E0499]: cannot borrow `p.0` as mutable more than once at a time
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:20
|
LL | while let Some(now) = p {
| ^^^ - first borrow used here, in later iteration of loop
| |
| `p.0` was mutably borrowed here in the previous iteration of the loop
error[E0503]: cannot use `*p` because it was mutably borrowed
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:27
|
LL | while let Some(now) = p {
| --- ^
| | |
| | use of borrowed `p.0`
| | borrow later used here
| `p.0` is borrowed here
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0499, E0503.
For more information about an error, try `rustc --explain E0499`.

View file

@ -1,11 +1,12 @@
#![crate_type = "lib"]
// An example from #57165 of the linked-list cursor-like pattern of #46859/#48001.
// An example from #57165 of the linked-list cursor-like pattern of #46859/#48001, where the
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
//@ ignore-compare-mode-polonius (explicit revisions)
//@ revisions: nll polonius legacy
//@ [nll] known-bug: #57165
//@ [polonius] check-pass
//@ [polonius] known-bug: #57165
//@ [polonius] compile-flags: -Z polonius=next
//@ [legacy] check-pass
//@ [legacy] compile-flags: -Z polonius=legacy
@ -22,7 +23,7 @@ fn no_control_flow() {
}
}
// NLLs fail here
// NLLs and polonius alpha fail here
fn conditional() {
let mut b = Some(Box::new(X { next: None }));
let mut p = &mut b;

View file

@ -1,5 +1,5 @@
error[E0506]: cannot assign to `*node_ref` because it is borrowed
--> $DIR/iterating-updating-cursor-issue-63908.rs:42:5
--> $DIR/iterating-updating-cursor-issue-63908.rs:43:5
|
LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
| - let's call the lifetime of this reference `'1`

View file

@ -0,0 +1,18 @@
error[E0506]: cannot assign to `*node_ref` because it is borrowed
--> $DIR/iterating-updating-cursor-issue-63908.rs:43:5
|
LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
| - let's call the lifetime of this reference `'1`
LL | loop {
LL | let next_ref = &mut node_ref.as_mut().unwrap().next;
| -------- `*node_ref` is borrowed here
...
LL | node_ref = next_ref;
| ------------------- assignment requires that `*node_ref` is borrowed for `'1`
...
LL | *node_ref = None;
| ^^^^^^^^^ `*node_ref` is assigned to here but it was already borrowed
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0506`.

View file

@ -1,11 +1,12 @@
#![crate_type = "lib"]
// An example from #63908 of the linked-list cursor-like pattern of #46859/#48001.
// An example from #63908 of the linked-list cursor-like pattern of #46859/#48001, where the
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
//@ ignore-compare-mode-polonius (explicit revisions)
//@ revisions: nll polonius legacy
//@ [nll] known-bug: #63908
//@ [polonius] check-pass
//@ [polonius] known-bug: #63908
//@ [polonius] compile-flags: -Z polonius=next
//@ [legacy] check-pass
//@ [legacy] compile-flags: -Z polonius=legacy
@ -27,7 +28,7 @@ fn remove_last_node_recursive<T>(node_ref: &mut List<T>) {
}
}
// NLLs fail here
// NLLs and polonius alpha fail here
fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
loop {
let next_ref = &mut node_ref.as_mut().unwrap().next;