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 rust-lang#2513 - RalfJung:protected, r=saethlin
slightly improve protector-related error messages
I find the current retag messages confusing, since they sound like the item *was* protected, when it still actively *is* protected (and that is, in fact, the issue).
Example error message:
```
error: Undefined Behavior: not granting access to tag <3095> because incompatible item [Unique for <3099>] is protected by call 943
--> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:5:25
|
5 | let _val = unsafe { *x }; //~ ERROR: protect
| ^^ not granting access to tag <3095> because incompatible item [Unique for <3099>] is protected by call 943
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <3095> was created by a SharedReadWrite retag at offsets [0x0..0x4]
--> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:10:16
|
10 | let xraw = &mut x as *mut _;
| ^^^^^^
help: <3095> cannot be used for memory access because that would remove protected tag <3099>, protected by this function call
--> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:1:1
|
1 | / fn inner(x: *mut i32, _y: &mut i32) {
2 | | // If `x` and `y` alias, retagging is fine with this... but we really
3 | | // shouldn't be allowed to use `x` at all because `y` was assumed to be
4 | | // unique for the duration of this call.
5 | | let _val = unsafe { *x }; //~ ERROR: protect
6 | | }
| |_^
help: <3099> was derived from <3098>, which in turn was created here
--> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:17
|
12 | inner(xraw, xref);
| ^^^^
= note: backtrace:
= note: inside `inner` at tests/fail/stacked_borrows/invalidate_against_barrier1.rs:5:25
note: inside `main` at tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:5
--> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:5
|
12 | inner(xraw, xref);
| ^^^^^^^^^^^^^^^^^
```
r? `@saethlin`
Copy file name to clipboardExpand all lines: tests/fail/stacked_borrows/invalidate_against_protector1.stderr
+12-12
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,18 @@
1
1
error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
2
-
--> $DIR/invalidate_against_barrier1.rs:LL:CC
2
+
--> $DIR/invalidate_against_protector1.rs:LL:CC
3
3
|
4
4
LL | let _val = unsafe { *x };
5
5
| ^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
8
8
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
9
9
help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
10
-
--> $DIR/invalidate_against_barrier1.rs:LL:CC
10
+
--> $DIR/invalidate_against_protector1.rs:LL:CC
11
11
|
12
12
LL | let xraw = &mut x as *mut _;
13
13
| ^^^^^^
14
-
help: <TAG> was protected due to <TAG> which was created here
15
-
--> $DIR/invalidate_against_barrier1.rs:LL:CC
16
-
|
17
-
LL | inner(xraw, xref);
18
-
| ^^^^
19
-
help: this protector is live for this call
20
-
--> $DIR/invalidate_against_barrier1.rs:LL:CC
14
+
help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
15
+
--> $DIR/invalidate_against_protector1.rs:LL:CC
21
16
|
22
17
LL | / fn inner(x: *mut i32, _y: &mut i32) {
23
18
LL | | // If `x` and `y` alias, retagging is fine with this... but we really
@@ -26,10 +21,15 @@ LL | | // unique for the duration of this call.
26
21
LL | | let _val = unsafe { *x };
27
22
LL | | }
28
23
| |_^
24
+
help: <TAG> was derived from <TAG>, which in turn was created here
25
+
--> $DIR/invalidate_against_protector1.rs:LL:CC
26
+
|
27
+
LL | inner(xraw, xref);
28
+
| ^^^^
29
29
= note: backtrace:
30
-
= note: inside `inner` at $DIR/invalidate_against_barrier1.rs:LL:CC
31
-
note: inside `main` at $DIR/invalidate_against_barrier1.rs:LL:CC
32
-
--> $DIR/invalidate_against_barrier1.rs:LL:CC
30
+
= note: inside `inner` at $DIR/invalidate_against_protector1.rs:LL:CC
31
+
note: inside `main` at $DIR/invalidate_against_protector1.rs:LL:CC
Copy file name to clipboardExpand all lines: tests/fail/stacked_borrows/invalidate_against_protector2.stderr
+12-12
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,18 @@
1
1
error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
2
-
--> $DIR/invalidate_against_barrier2.rs:LL:CC
2
+
--> $DIR/invalidate_against_protector2.rs:LL:CC
3
3
|
4
4
LL | unsafe { *x = 0 };
5
5
| ^^^^^^ not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
6
6
|
7
7
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
8
8
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
9
9
help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
10
-
--> $DIR/invalidate_against_barrier2.rs:LL:CC
10
+
--> $DIR/invalidate_against_protector2.rs:LL:CC
11
11
|
12
12
LL | let xraw = &mut x as *mut _;
13
13
| ^^^^^^
14
-
help: <TAG> was protected due to <TAG> which was created here
15
-
--> $DIR/invalidate_against_barrier2.rs:LL:CC
16
-
|
17
-
LL | inner(xraw, xref);
18
-
| ^^^^
19
-
help: this protector is live for this call
20
-
--> $DIR/invalidate_against_barrier2.rs:LL:CC
14
+
help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
15
+
--> $DIR/invalidate_against_protector2.rs:LL:CC
21
16
|
22
17
LL | / fn inner(x: *mut i32, _y: &i32) {
23
18
LL | | // If `x` and `y` alias, retagging is fine with this... but we really
@@ -26,10 +21,15 @@ LL | | // immutable for the duration of this call.
26
21
LL | | unsafe { *x = 0 };
27
22
LL | | }
28
23
| |_^
24
+
help: <TAG> was derived from <TAG>, which in turn was created here
25
+
--> $DIR/invalidate_against_protector2.rs:LL:CC
26
+
|
27
+
LL | inner(xraw, xref);
28
+
| ^^^^
29
29
= note: backtrace:
30
-
= note: inside `inner` at $DIR/invalidate_against_barrier2.rs:LL:CC
31
-
note: inside `main` at $DIR/invalidate_against_barrier2.rs:LL:CC
32
-
--> $DIR/invalidate_against_barrier2.rs:LL:CC
30
+
= note: inside `inner` at $DIR/invalidate_against_protector2.rs:LL:CC
31
+
note: inside `main` at $DIR/invalidate_against_protector2.rs:LL:CC
0 commit comments