Skip to content

Commit 1163c28

Browse files
authored
Rollup merge of #146187 - clarfonthey:const-drop-in-place, r=oli-obk
Unstably constify `ptr::drop_in_place` and related methods Tracking: rust-lang/rust#109342 Supercedes: rust-lang/rust#145725 Makes methods const: * `core::ptr::drop_in_place` * `core::mem::ManuallyDrop::drop` * `core::mem::MaybeUninit::assume_init_drop` * `<[core::mem::MaybeUninit<_>]>::assume_init_drop` * `<*mut _>::drop_in_place` * `core::ptr::NonNull::drop_in_place`
2 parents a2b1ce7 + 85f0ae1 commit 1163c28

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tests/fail/stacked_borrows/drop_in_place_retag.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error: Undefined Behavior: trying to retag from <TAG> for Unique permission at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
22
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
33
|
4-
LL | pub unsafe fn drop_in_place<T: PointeeSized>(to_drop: *mut T) {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this error occurs as part of retag at ALLOC[0x0..0x1]
4+
LL | / pub const unsafe fn drop_in_place<T: PointeeSized>(to_drop: *mut T)
5+
LL | | where
6+
LL | | T: [const] Destruct,
7+
| |________________________^ this error occurs as part of retag at ALLOC[0x0..0x1]
68
|
79
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
810
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

tests/fail/unaligned_pointers/drop_in_place.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error: Undefined Behavior: constructing invalid value: encountered an unaligned reference (required ALIGN byte alignment but found ALIGN)
22
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
33
|
4-
LL | pub unsafe fn drop_in_place<T: PointeeSized>(to_drop: *mut T) {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
4+
LL | / pub const unsafe fn drop_in_place<T: PointeeSized>(to_drop: *mut T)
5+
LL | | where
6+
LL | | T: [const] Destruct,
7+
| |________________________^ Undefined Behavior occurred here
68
|
79
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
810
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

0 commit comments

Comments
 (0)