Skip to content

Commit f28428e

Browse files
authored
Rollup merge of #140151 - RalfJung:drop_in_place-is-not-an-intrinsic, r=Mark-Simulacrum
remove intrinsics::drop_in_place This was only ever accidentally stable, and has been marked as deprecated since Rust 1.52, released almost 4 years ago. We've removed the old serialization `derive`s, maybe we can remove this one as well? As suggested by ``@jhpratt,`` let's see what crater says for this one.
2 parents 2bce1ad + e7efab9 commit f28428e

14 files changed

+31
-41
lines changed

library/core/src/intrinsics/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ pub mod simd;
7474
#[cfg(all(target_has_atomic = "8", target_has_atomic = "32", target_has_atomic = "ptr"))]
7575
use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering};
7676

77-
#[stable(feature = "drop_in_place", since = "1.8.0")]
78-
#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"]
79-
#[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")]
80-
#[inline]
81-
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
82-
// SAFETY: see `ptr::drop_in_place`
83-
unsafe { crate::ptr::drop_in_place(to_drop) }
84-
}
85-
8677
// N.B., these intrinsics take raw pointers because they mutate aliased
8778
// memory, which is not valid for either `&` or `&mut`.
8879

tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let _3: ();
99
let mut _4: *mut std::vec::Vec<A>;
1010
let mut _5: *mut std::option::Option<B>;
11-
+ scope 1 (inlined std::ptr::drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) {
11+
+ scope 1 (inlined drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) {
1212
+ let mut _6: &mut std::vec::Vec<A>;
1313
+ let mut _7: ();
1414
+ scope 2 (inlined <Vec<A> as Drop>::drop) {
@@ -38,14 +38,14 @@
3838
+ scope 13 (inlined std::ptr::from_raw_parts_mut::<[A], A>) {
3939
+ }
4040
+ }
41-
+ scope 14 (inlined std::ptr::drop_in_place::<[A]> - shim(Some([A]))) {
41+
+ scope 14 (inlined drop_in_place::<[A]> - shim(Some([A]))) {
4242
+ let mut _12: usize;
4343
+ let mut _13: *mut A;
4444
+ let mut _14: bool;
4545
+ }
4646
+ }
4747
+ }
48-
+ scope 15 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
48+
+ scope 15 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
4949
+ let mut _15: isize;
5050
+ let mut _16: isize;
5151
+ }
@@ -54,7 +54,7 @@
5454
StorageLive(_3);
5555
StorageLive(_4);
5656
_4 = copy _1;
57-
- _3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind unreachable];
57+
- _3 = drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind unreachable];
5858
+ StorageLive(_6);
5959
+ StorageLive(_7);
6060
+ _6 = &mut (*_4);
@@ -82,7 +82,7 @@
8282
StorageDead(_3);
8383
StorageLive(_5);
8484
_5 = copy _2;
85-
- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
85+
- _0 = drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
8686
+ StorageLive(_15);
8787
+ StorageLive(_16);
8888
+ _15 = discriminant((*_5));

tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let _3: ();
99
let mut _4: *mut std::vec::Vec<A>;
1010
let mut _5: *mut std::option::Option<B>;
11-
+ scope 1 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
11+
+ scope 1 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
1212
+ let mut _6: isize;
1313
+ let mut _7: isize;
1414
+ }
@@ -17,15 +17,15 @@
1717
StorageLive(_3);
1818
StorageLive(_4);
1919
_4 = copy _1;
20-
_3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind continue];
20+
_3 = drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind continue];
2121
}
2222

2323
bb1: {
2424
StorageDead(_4);
2525
StorageDead(_3);
2626
StorageLive(_5);
2727
_5 = copy _2;
28-
- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind continue];
28+
- _0 = drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind continue];
2929
+ StorageLive(_6);
3030
+ StorageLive(_7);
3131
+ _6 = discriminant((*_5));

tests/mir-opt/inline/inline_shims.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn clone<A, B>(f: fn(A, B)) -> fn(A, B) {
1111
// EMIT_MIR inline_shims.drop.Inline.diff
1212
pub fn drop<A, B>(a: *mut Vec<A>, b: *mut Option<B>) {
1313
// CHECK-LABEL: fn drop(
14-
// CHECK: (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>)))
14+
// CHECK: (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>)))
1515
unsafe { std::ptr::drop_in_place(a) }
1616
unsafe { std::ptr::drop_in_place(b) }
1717
}

tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-abort.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
1+
// MIR for `drop_in_place` after SimplifyCfg-make_shim
22

3-
fn std::ptr::drop_in_place(_1: *mut Test) -> () {
3+
fn drop_in_place(_1: *mut Test) -> () {
44
let mut _0: ();
55
let mut _2: &mut Test;
66
let mut _3: &mut Test;

tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
1+
// MIR for `drop_in_place` after SimplifyCfg-make_shim
22

3-
fn std::ptr::drop_in_place(_1: *mut Test) -> () {
3+
fn drop_in_place(_1: *mut Test) -> () {
44
let mut _0: ();
55
let mut _2: &mut Test;
66
let mut _3: &mut Test;

tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String;42].AddMovesForPackedDrops.before.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
1+
// MIR for `drop_in_place` before AddMovesForPackedDrops
22

3-
fn std::ptr::drop_in_place(_1: *mut [String; 42]) -> () {
3+
fn drop_in_place(_1: *mut [String; 42]) -> () {
44
let mut _0: ();
55
let mut _2: *mut [std::string::String; 42];
66
let mut _3: *mut [std::string::String];

tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
1+
// MIR for `drop_in_place` before AddMovesForPackedDrops
22

3-
fn std::ptr::drop_in_place(_1: *mut [String]) -> () {
3+
fn drop_in_place(_1: *mut [String]) -> () {
44
let mut _0: ();
55
let mut _2: usize;
66
let mut _3: usize;

tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
1+
// MIR for `drop_in_place` before AddMovesForPackedDrops
22

3-
fn std::ptr::drop_in_place(_1: *mut Vec<i32>) -> () {
3+
fn drop_in_place(_1: *mut Vec<i32>) -> () {
44
let mut _0: ();
55
let mut _2: &mut std::vec::Vec<i32>;
66
let mut _3: ();

tests/ui/consts/miri_unleashed/assoc_const.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error[E0080]: evaluation of `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed
1+
error[E0080]: evaluation of `drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed
22
--> $DIR/assoc_const.rs:12:31
33
|
44
LL | const F: u32 = (U::X, 42).1;
55
| ^ calling non-const function `<Vec<u32> as Drop>::drop`
66
|
7-
note: inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))`
7+
note: inside `drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))`
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
9-
note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))`
9+
note: inside `drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))`
1010
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
1111

1212
note: erroneous constant encountered

tests/ui/consts/miri_unleashed/drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ static TEST_BAD: () = {
1515
let _v: Vec<i32> = Vec::new();
1616
}; //~ ERROR could not evaluate static initializer
1717
//~| NOTE calling non-const function `<Vec<i32> as Drop>::drop`
18-
//~| NOTE inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
18+
//~| NOTE inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
1919

2020
//~? WARN skipping const checks

tests/ui/consts/miri_unleashed/drop.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer
44
LL | };
55
| ^ calling non-const function `<Vec<i32> as Drop>::drop`
66
|
7-
note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
7+
note: inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
88
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
99

1010
warning: skipping const checks

tests/ui/consts/qualif-indirect-mutation-fail.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ error[E0080]: evaluation of constant value failed
1313
LL | };
1414
| ^ calling non-const function `<Vec<u8> as Drop>::drop`
1515
|
16-
note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))`
16+
note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))`
1717
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
18-
note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
18+
note: inside `drop_in_place::<String> - shim(Some(String))`
1919
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
20-
note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
20+
note: inside `drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
2121
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
2222

2323
error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time
@@ -34,11 +34,11 @@ error[E0080]: evaluation of constant value failed
3434
LL | };
3535
| ^ calling non-const function `<Vec<u8> as Drop>::drop`
3636
|
37-
note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))`
37+
note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))`
3838
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
39-
note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
39+
note: inside `drop_in_place::<String> - shim(Some(String))`
4040
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
41-
note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
41+
note: inside `drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
4242
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
4343

4444
error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time

tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
#![allow(unused_imports)]
99
#![allow(deprecated)]
1010

11-
use std::intrinsics::drop_in_place as _;
1211
use std::intrinsics::copy_nonoverlapping as _;
1312
use std::intrinsics::copy as _;
1413
use std::intrinsics::write_bytes as _;
15-
use std::intrinsics::{drop_in_place, copy_nonoverlapping, copy, write_bytes};
14+
use std::intrinsics::{copy_nonoverlapping, copy, write_bytes};
1615

1716
fn main() {}

0 commit comments

Comments
 (0)