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 #103957 - JakobDegen:drop-retag, r=RalfJung
Retag as FnEntry on `drop_in_place`
This commit changes the mir drop shim to always retag its argument as if it were a `&mut`.
cc rust-lang/unsafe-code-guidelines#373
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected because it is an argument of call ID
2
+
--> $DIR/drop_in_place_protector.rs:LL:CC
3
+
|
4
+
LL | let _val = *P;
5
+
| ^^ not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected because it is an argument of call ID
6
+
|
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
+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
9
+
help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x1]
10
+
--> $DIR/drop_in_place_protector.rs:LL:CC
11
+
|
12
+
LL | let x = core::ptr::addr_of_mut!(x);
13
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
14
+
help: <TAG> is this argument
15
+
--> $DIR/drop_in_place_protector.rs:LL:CC
16
+
|
17
+
LL | core::ptr::drop_in_place(x);
18
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
19
+
= note: BACKTRACE:
20
+
= note: inside `<HasDrop as std::ops::Drop>::drop` at $DIR/drop_in_place_protector.rs:LL:CC
21
+
= note: inside `std::ptr::drop_in_place::<HasDrop> - shim(Some(HasDrop))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
22
+
= note: inside `std::ptr::drop_in_place::<(HasDrop, u8)> - shim(Some((HasDrop, u8)))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
23
+
note: inside `main`
24
+
--> $DIR/drop_in_place_protector.rs:LL:CC
25
+
|
26
+
LL | core::ptr::drop_in_place(x);
27
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
28
+
= note: this error originates in the macro `core::ptr::addr_of_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
29
+
30
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: Undefined Behavior: trying to retag from <TAG> for Unique permission at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
| trying to retag from <TAG> for Unique permission at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
8
+
| this error occurs as part of retag at ALLOC[0x0..0x1]
9
+
|
10
+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
11
+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
12
+
help: <TAG> was created by a SharedReadOnly retag at offsets [0x0..0x1]
13
+
--> $DIR/drop_in_place_retag.rs:LL:CC
14
+
|
15
+
LL | let x = core::ptr::addr_of!(x);
16
+
| ^^^^^^^^^^^^^^^^^^^^^^
17
+
= note: BACKTRACE:
18
+
= note: inside `std::ptr::drop_in_place::<u8> - shim(None)` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
19
+
note: inside `main`
20
+
--> $DIR/drop_in_place_retag.rs:LL:CC
21
+
|
22
+
LL | core::ptr::drop_in_place(x.cast_mut());
23
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24
+
= note: this error originates in the macro `core::ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info)
25
+
26
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
0 commit comments