You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #2918 - Vanille-N:tb-diags, r=RalfJung
TB: improve error messages (distinguish between accesses and reborrows)
I don't remember where, but there was a complaint that while SB's error messages distinguish between "invalidated by an access" and "invalidated by a reborrow", TB's error messages do not.
// NOTE: `transition_range` is explicitly absent from the error message, it has no significance
94
124
// to the user. The meaningful one is `access_range`.
95
-
self.events.push((Some(span.data()),format!("{this} later transitioned to {endpoint} due to a {rel} {access_kind} at offsets {access_range:?}", endpoint = transition.endpoint(), rel = if is_foreign {"foreign"} else {"child"})));
96
-
self.events.push((None,format!("this corresponds to {}", transition.summary())));
125
+
let access = access_cause.print_as_access(is_foreign);
126
+
self.events.push((Some(span.data()),format!("{this} later transitioned to {endpoint} due to a {access} at offsets {access_range:?}", endpoint = transition.endpoint())));
127
+
self.events
128
+
.push((None,format!("this transition corresponds to {}", transition.summary())));
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/alias_through_mutation.tree.stderr
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ LL | let _val = *target_alias;
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
8
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>
9
-
= help: the conflicting tag <TAG> has state Disabled which forbids child read accesses
9
+
= help: the conflicting tag <TAG> has state Disabled which forbids this child read access
10
10
help: the accessed tag <TAG> was created here
11
11
--> $DIR/alias_through_mutation.rs:LL:CC
12
12
|
@@ -22,7 +22,7 @@ help: the conflicting tag <TAG> later transitioned to Disabled due to a foreign
22
22
|
23
23
LL | *target = 13;
24
24
| ^^^^^^^^^^^^
25
-
= help: this corresponds to a loss of read and write permissions
25
+
= help: this transition corresponds to a loss of read and write permissions
26
26
= note: BACKTRACE (of the first span):
27
27
= note: inside `main` at $DIR/alias_through_mutation.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/aliasing_mut1.tree.stderr
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,18 @@ LL | *x = 1;
5
5
| ^^^^^^ write access through <TAG> is forbidden
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
-
= help: the accessed tag <TAG> has state Frozen which forbids child write accesses
8
+
= help: the accessed tag <TAG> has state Frozen which forbids this child write access
9
9
help: the accessed tag <TAG> was created here, in the initial state Reserved
10
10
--> $DIR/aliasing_mut1.rs:LL:CC
11
11
|
12
12
LL | pub fn safe(x: &mut i32, y: &mut i32) {
13
13
| ^
14
-
help: the accessed tag <TAG> later transitioned to Frozen due to a foreign read access at offsets [0x0..0x4]
14
+
help: the accessed tag <TAG> later transitioned to Frozen due to a reborrow (acting as a foreign read access) at offsets [0x0..0x4]
15
15
--> $DIR/aliasing_mut1.rs:LL:CC
16
16
|
17
17
LL | pub fn safe(x: &mut i32, y: &mut i32) {
18
18
| ^
19
-
= help: this corresponds to a loss of write permissions
19
+
= help: this transition corresponds to a loss of write permissions
20
20
= note: BACKTRACE (of the first span):
21
21
= note: inside `safe` at $DIR/aliasing_mut1.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/aliasing_mut2.tree.stderr
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ LL | *y = 2;
5
5
| ^^^^^^ write access through <TAG> is forbidden
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
-
= help: the accessed tag <TAG> has state Frozen which forbids child write accesses
8
+
= help: the accessed tag <TAG> has state Frozen which forbids this child write access
9
9
help: the accessed tag <TAG> was created here, in the initial state Reserved
10
10
--> $DIR/aliasing_mut2.rs:LL:CC
11
11
|
@@ -16,7 +16,7 @@ help: the accessed tag <TAG> later transitioned to Frozen due to a foreign read
16
16
|
17
17
LL | let _v = *x;
18
18
| ^^
19
-
= help: this corresponds to a loss of write permissions
19
+
= help: this transition corresponds to a loss of write permissions
20
20
= note: BACKTRACE (of the first span):
21
21
= note: inside `safe` at $DIR/aliasing_mut2.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/aliasing_mut3.tree.stderr
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,18 @@ LL | *x = 1;
5
5
| ^^^^^^ write access through <TAG> is forbidden
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
-
= help: the accessed tag <TAG> has state Frozen which forbids child write accesses
8
+
= help: the accessed tag <TAG> has state Frozen which forbids this child write access
9
9
help: the accessed tag <TAG> was created here, in the initial state Reserved
10
10
--> $DIR/aliasing_mut3.rs:LL:CC
11
11
|
12
12
LL | pub fn safe(x: &mut i32, y: &i32) {
13
13
| ^
14
-
help: the accessed tag <TAG> later transitioned to Frozen due to a foreign read access at offsets [0x0..0x4]
14
+
help: the accessed tag <TAG> later transitioned to Frozen due to a reborrow (acting as a foreign read access) at offsets [0x0..0x4]
15
15
--> $DIR/aliasing_mut3.rs:LL:CC
16
16
|
17
17
LL | pub fn safe(x: &mut i32, y: &i32) {
18
18
| ^
19
-
= help: this corresponds to a loss of write permissions
19
+
= help: this transition corresponds to a loss of write permissions
20
20
= note: BACKTRACE (of the first span):
21
21
= note: inside `safe` at $DIR/aliasing_mut3.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/aliasing_mut4.tree.stderr
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ LL | ptr::write(dest, src);
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
8
= help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
9
-
= help: the access would cause the protected tag <TAG> to transition from Frozen to Disabled
10
-
= help: this is a loss of read permissions, which is not allowed for protected tags
9
+
= help: this foreign write access would cause the protected tag <TAG> to transition from Frozen to Disabled
10
+
= help: this transition would be a loss of read permissions, which is not allowed for protected tags
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/box_noalias_violation.tree.stderr
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ LL | *y
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
8
= help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
9
-
= help: the access would cause the protected tag <TAG> to transition from Active to Frozen
10
-
= help: this is a loss of write permissions, which is not allowed for protected tags
9
+
= help: this foreign read access would cause the protected tag <TAG> to transition from Active to Frozen
10
+
= help: this transition would be a loss of write permissions, which is not allowed for protected tags
11
11
help: the accessed tag <TAG> was created here
12
12
--> $DIR/box_noalias_violation.rs:LL:CC
13
13
|
@@ -23,7 +23,7 @@ help: the protected tag <TAG> later transitioned to Active due to a child write
23
23
|
24
24
LL | *x = 5;
25
25
| ^^^^^^
26
-
= help: this corresponds to the first write to a 2-phase borrowed mutable reference
26
+
= help: this transition corresponds to the first write to a 2-phase borrowed mutable reference
27
27
= note: BACKTRACE (of the first span):
28
28
= note: inside `test` at $DIR/box_noalias_violation.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/both_borrows/buggy_as_mut_slice.tree.stderr
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ LL | v2[1] = 7;
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8
8
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>
9
-
= help: the conflicting tag <TAG> has state Disabled which forbids child write accesses
9
+
= help: the conflicting tag <TAG> has state Disabled which forbids this child write access
10
10
help: the accessed tag <TAG> was created here
11
11
--> $DIR/buggy_as_mut_slice.rs:LL:CC
12
12
|
@@ -22,7 +22,7 @@ help: the conflicting tag <TAG> later transitioned to Disabled due to a foreign
22
22
|
23
23
LL | v1[1] = 5;
24
24
| ^^^^^^^^^
25
-
= help: this corresponds to a loss of read and write permissions
25
+
= help: this transition corresponds to a loss of read and write permissions
26
26
= note: BACKTRACE (of the first span):
27
27
= note: inside `main` at $DIR/buggy_as_mut_slice.rs:LL:CC
0 commit comments