Skip to content

Commit 1e087f2

Browse files
committed
mark linked list cursor-like patterns as known-bugs
these are known-bugs for the polonius alpha, where they show the same imprecision as NLLs, but are supported by the old datalog implementation
1 parent 0ea7f38 commit 1e087f2

9 files changed

+68
-13
lines changed

tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0499]: cannot borrow `*elements` as mutable more than once at a time
2-
--> $DIR/iterating-updating-cursor-issue-108704.rs:40:26
2+
--> $DIR/iterating-updating-cursor-issue-108704.rs:41:26
33
|
44
LL | for (idx, el) in elements.iter_mut().enumerate() {
55
| ^^^^^^^^
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0499]: cannot borrow `*elements` as mutable more than once at a time
2+
--> $DIR/iterating-updating-cursor-issue-108704.rs:41:26
3+
|
4+
LL | for (idx, el) in elements.iter_mut().enumerate() {
5+
| ^^^^^^^^
6+
| |
7+
| `*elements` was mutably borrowed here in the previous iteration of the loop
8+
| first borrow used here, in later iteration of loop
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0499`.

tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![crate_type = "lib"]
22

3-
// An example from #108704 of the linked-list cursor-like pattern of #46859/#48001.
3+
// An example from #108704 of the linked-list cursor-like pattern of #46859/#48001, where the
4+
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
45

56
//@ ignore-compare-mode-polonius (explicit revisions)
67
//@ revisions: nll polonius legacy
78
//@ [nll] known-bug: #108704
8-
//@ [polonius] check-pass
9+
//@ [polonius] known-bug: #108704
910
//@ [polonius] compile-flags: -Z polonius=next
1011
//@ [legacy] check-pass
1112
//@ [legacy] compile-flags: -Z polonius=legacy
@@ -32,7 +33,7 @@ fn merge_tree_ok(root: &mut Root, path: Vec<String>) {
3233
}
3334
}
3435

35-
// NLLs fail here
36+
// NLLs and polonius alpha fail here
3637
fn merge_tree_ko(root: &mut Root, path: Vec<String>) {
3738
let mut elements = &mut root.children;
3839

tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0499]: cannot borrow `p.0` as mutable more than once at a time
2-
--> $DIR/iterating-updating-cursor-issue-57165.rs:29:20
2+
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:20
33
|
44
LL | while let Some(now) = p {
55
| ^^^ - first borrow used here, in later iteration of loop
66
| |
77
| `p.0` was mutably borrowed here in the previous iteration of the loop
88

99
error[E0503]: cannot use `*p` because it was mutably borrowed
10-
--> $DIR/iterating-updating-cursor-issue-57165.rs:29:27
10+
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:27
1111
|
1212
LL | while let Some(now) = p {
1313
| --- ^
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0499]: cannot borrow `p.0` as mutable more than once at a time
2+
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:20
3+
|
4+
LL | while let Some(now) = p {
5+
| ^^^ - first borrow used here, in later iteration of loop
6+
| |
7+
| `p.0` was mutably borrowed here in the previous iteration of the loop
8+
9+
error[E0503]: cannot use `*p` because it was mutably borrowed
10+
--> $DIR/iterating-updating-cursor-issue-57165.rs:30:27
11+
|
12+
LL | while let Some(now) = p {
13+
| --- ^
14+
| | |
15+
| | use of borrowed `p.0`
16+
| | borrow later used here
17+
| `p.0` is borrowed here
18+
19+
error: aborting due to 2 previous errors
20+
21+
Some errors have detailed explanations: E0499, E0503.
22+
For more information about an error, try `rustc --explain E0499`.

tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![crate_type = "lib"]
22

3-
// An example from #57165 of the linked-list cursor-like pattern of #46859/#48001.
3+
// An example from #57165 of the linked-list cursor-like pattern of #46859/#48001, where the
4+
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
45

56
//@ ignore-compare-mode-polonius (explicit revisions)
67
//@ revisions: nll polonius legacy
78
//@ [nll] known-bug: #57165
8-
//@ [polonius] check-pass
9+
//@ [polonius] known-bug: #57165
910
//@ [polonius] compile-flags: -Z polonius=next
1011
//@ [legacy] check-pass
1112
//@ [legacy] compile-flags: -Z polonius=legacy
@@ -22,7 +23,7 @@ fn no_control_flow() {
2223
}
2324
}
2425

25-
// NLLs fail here
26+
// NLLs and polonius alpha fail here
2627
fn conditional() {
2728
let mut b = Some(Box::new(X { next: None }));
2829
let mut p = &mut b;

tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0506]: cannot assign to `*node_ref` because it is borrowed
2-
--> $DIR/iterating-updating-cursor-issue-63908.rs:42:5
2+
--> $DIR/iterating-updating-cursor-issue-63908.rs:43:5
33
|
44
LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
55
| - let's call the lifetime of this reference `'1`
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0506]: cannot assign to `*node_ref` because it is borrowed
2+
--> $DIR/iterating-updating-cursor-issue-63908.rs:43:5
3+
|
4+
LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
5+
| - let's call the lifetime of this reference `'1`
6+
LL | loop {
7+
LL | let next_ref = &mut node_ref.as_mut().unwrap().next;
8+
| -------- `*node_ref` is borrowed here
9+
...
10+
LL | node_ref = next_ref;
11+
| ------------------- assignment requires that `*node_ref` is borrowed for `'1`
12+
...
13+
LL | *node_ref = None;
14+
| ^^^^^^^^^ `*node_ref` is assigned to here but it was already borrowed
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0506`.

tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![crate_type = "lib"]
22

3-
// An example from #63908 of the linked-list cursor-like pattern of #46859/#48001.
3+
// An example from #63908 of the linked-list cursor-like pattern of #46859/#48001, where the
4+
// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation.
45

56
//@ ignore-compare-mode-polonius (explicit revisions)
67
//@ revisions: nll polonius legacy
78
//@ [nll] known-bug: #63908
8-
//@ [polonius] check-pass
9+
//@ [polonius] known-bug: #63908
910
//@ [polonius] compile-flags: -Z polonius=next
1011
//@ [legacy] check-pass
1112
//@ [legacy] compile-flags: -Z polonius=legacy
@@ -27,7 +28,7 @@ fn remove_last_node_recursive<T>(node_ref: &mut List<T>) {
2728
}
2829
}
2930

30-
// NLLs fail here
31+
// NLLs and polonius alpha fail here
3132
fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) {
3233
loop {
3334
let next_ref = &mut node_ref.as_mut().unwrap().next;

0 commit comments

Comments
 (0)