Skip to content

remove intrinsics::drop_in_place #140151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ pub mod simd;
#[cfg(all(target_has_atomic = "8", target_has_atomic = "32", target_has_atomic = "ptr"))]
use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering};

#[stable(feature = "drop_in_place", since = "1.8.0")]
#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"]
#[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")]
#[inline]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
// SAFETY: see `ptr::drop_in_place`
unsafe { crate::ptr::drop_in_place(to_drop) }
}

// N.B., these intrinsics take raw pointers because they mutate aliased
// memory, which is not valid for either `&` or `&mut`.

Expand Down
10 changes: 5 additions & 5 deletions tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let _3: ();
let mut _4: *mut std::vec::Vec<A>;
let mut _5: *mut std::option::Option<B>;
+ scope 1 (inlined std::ptr::drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) {
+ scope 1 (inlined drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) {
+ let mut _6: &mut std::vec::Vec<A>;
+ let mut _7: ();
+ scope 2 (inlined <Vec<A> as Drop>::drop) {
Expand Down Expand Up @@ -38,14 +38,14 @@
+ scope 13 (inlined std::ptr::from_raw_parts_mut::<[A], A>) {
+ }
+ }
+ scope 14 (inlined std::ptr::drop_in_place::<[A]> - shim(Some([A]))) {
+ scope 14 (inlined drop_in_place::<[A]> - shim(Some([A]))) {
+ let mut _12: usize;
+ let mut _13: *mut A;
+ let mut _14: bool;
+ }
+ }
+ }
+ scope 15 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
+ scope 15 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
+ let mut _15: isize;
+ let mut _16: isize;
+ }
Expand All @@ -54,7 +54,7 @@
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
- _3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind unreachable];
- _3 = drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind unreachable];
+ StorageLive(_6);
+ StorageLive(_7);
+ _6 = &mut (*_4);
Expand Down Expand Up @@ -82,7 +82,7 @@
StorageDead(_3);
StorageLive(_5);
_5 = copy _2;
- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
- _0 = drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
+ StorageLive(_15);
+ StorageLive(_16);
+ _15 = discriminant((*_5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let _3: ();
let mut _4: *mut std::vec::Vec<A>;
let mut _5: *mut std::option::Option<B>;
+ scope 1 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
+ scope 1 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
+ let mut _6: isize;
+ let mut _7: isize;
+ }
Expand All @@ -17,15 +17,15 @@
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
_3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind continue];
_3 = drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind continue];
}

bb1: {
StorageDead(_4);
StorageDead(_3);
StorageLive(_5);
_5 = copy _2;
- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind continue];
- _0 = drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind continue];
+ StorageLive(_6);
+ StorageLive(_7);
+ _6 = discriminant((*_5));
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/inline/inline_shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn clone<A, B>(f: fn(A, B)) -> fn(A, B) {
// EMIT_MIR inline_shims.drop.Inline.diff
pub fn drop<A, B>(a: *mut Vec<A>, b: *mut Option<B>) {
// CHECK-LABEL: fn drop(
// CHECK: (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>)))
// CHECK: (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>)))
unsafe { std::ptr::drop_in_place(a) }
unsafe { std::ptr::drop_in_place(b) }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
// MIR for `drop_in_place` after SimplifyCfg-make_shim

fn std::ptr::drop_in_place(_1: *mut Test) -> () {
fn drop_in_place(_1: *mut Test) -> () {
let mut _0: ();
let mut _2: &mut Test;
let mut _3: &mut Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIR for `std::ptr::drop_in_place` after SimplifyCfg-make_shim
// MIR for `drop_in_place` after SimplifyCfg-make_shim

fn std::ptr::drop_in_place(_1: *mut Test) -> () {
fn drop_in_place(_1: *mut Test) -> () {
let mut _0: ();
let mut _2: &mut Test;
let mut _3: &mut Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
// MIR for `drop_in_place` before AddMovesForPackedDrops

fn std::ptr::drop_in_place(_1: *mut [String; 42]) -> () {
fn drop_in_place(_1: *mut [String; 42]) -> () {
let mut _0: ();
let mut _2: *mut [std::string::String; 42];
let mut _3: *mut [std::string::String];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
// MIR for `drop_in_place` before AddMovesForPackedDrops

fn std::ptr::drop_in_place(_1: *mut [String]) -> () {
fn drop_in_place(_1: *mut [String]) -> () {
let mut _0: ();
let mut _2: usize;
let mut _3: usize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
// MIR for `drop_in_place` before AddMovesForPackedDrops

fn std::ptr::drop_in_place(_1: *mut Vec<i32>) -> () {
fn drop_in_place(_1: *mut Vec<i32>) -> () {
let mut _0: ();
let mut _2: &mut std::vec::Vec<i32>;
let mut _3: ();
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/consts/miri_unleashed/assoc_const.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0080]: evaluation of `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed
error[E0080]: evaluation of `drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed
--> $DIR/assoc_const.rs:12:31
|
LL | const F: u32 = (U::X, 42).1;
| ^ calling non-const function `<Vec<u32> as Drop>::drop`
|
note: inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))`
note: inside `drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))`
note: inside `drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL

note: erroneous constant encountered
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/miri_unleashed/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ static TEST_BAD: () = {
let _v: Vec<i32> = Vec::new();
}; //~ ERROR could not evaluate static initializer
//~| NOTE calling non-const function `<Vec<i32> as Drop>::drop`
//~| NOTE inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
//~| NOTE inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`

//~? WARN skipping const checks
2 changes: 1 addition & 1 deletion tests/ui/consts/miri_unleashed/drop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer
LL | };
| ^ calling non-const function `<Vec<i32> as Drop>::drop`
|
note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
note: inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL

warning: skipping const checks
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/consts/qualif-indirect-mutation-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ error[E0080]: evaluation of constant value failed
LL | };
| ^ calling non-const function `<Vec<u8> as Drop>::drop`
|
note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))`
note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))`
note: inside `drop_in_place::<String> - shim(Some(String))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
note: inside `drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL

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

error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#![allow(unused_imports)]
#![allow(deprecated)]

use std::intrinsics::drop_in_place as _;
use std::intrinsics::copy_nonoverlapping as _;
use std::intrinsics::copy as _;
use std::intrinsics::write_bytes as _;
use std::intrinsics::{drop_in_place, copy_nonoverlapping, copy, write_bytes};
use std::intrinsics::{copy_nonoverlapping, copy, write_bytes};

fn main() {}
Loading