Skip to content

Commit

Permalink
Auto merge of #86833 - crlf0710:remove-std-raw-mod, r=SimonSapin
Browse files Browse the repository at this point in the history
Remove the deprecated `core::raw` and `std::raw` module.

A few months has passed since #84207. I think now it's time for the final removal.

Closes #27751.

r? `@m-ou-se`
  • Loading branch information
bors committed Jul 4, 2021
2 parents 1540711 + 0d1919c commit 71a567f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 146 deletions.
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Expand Up @@ -255,7 +255,6 @@ pub mod option;
pub mod panic;
pub mod panicking;
pub mod pin;
pub mod raw;
pub mod result;
#[unstable(feature = "async_stream", issue = "79024")]
pub mod stream;
Expand Down
90 changes: 0 additions & 90 deletions library/core/src/raw.rs

This file was deleted.

1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Expand Up @@ -29,7 +29,6 @@
#![feature(try_find)]
#![feature(is_sorted)]
#![feature(pattern)]
#![feature(raw)]
#![feature(sort_internals)]
#![feature(slice_partition_at_index)]
#![feature(maybe_uninit_uninit_array)]
Expand Down
22 changes: 0 additions & 22 deletions library/core/tests/mem.rs
Expand Up @@ -97,28 +97,6 @@ fn test_transmute_copy() {
assert_eq!(1, unsafe { transmute_copy(&1) });
}

// Remove this test when `std::raw` is removed.
// The replacement pointer metadata APIs are tested in library/core/tests/ptr.rs
#[allow(deprecated)]
#[test]
fn test_transmute() {
trait Foo {
fn dummy(&self) {}
}
impl Foo for isize {}

let a = box 100isize as Box<dyn Foo>;
unsafe {
let x: ::core::raw::TraitObject = transmute(a);
assert!(*(x.data as *const isize) == 100);
let _x: Box<dyn Foo> = transmute(x);
}

unsafe {
assert_eq!(transmute::<_, Vec<u8>>("L".to_string()), [76]);
}
}

#[test]
#[allow(dead_code)]
fn test_discriminant_send_sync() {
Expand Down
1 change: 0 additions & 1 deletion library/panic_unwind/src/lib.rs
Expand Up @@ -23,7 +23,6 @@
#![feature(unwind_attributes)]
#![feature(abi_thiscall)]
#![feature(rustc_attrs)]
#![feature(raw)]
#![panic_runtime]
#![feature(panic_runtime)]
// `real_imp` is unused with Miri, so silence warnings.
Expand Down
4 changes: 0 additions & 4 deletions library/std/src/lib.rs
Expand Up @@ -303,7 +303,6 @@
#![feature(pin_static_ref)]
#![feature(prelude_import)]
#![feature(ptr_internals)]
#![feature(raw)]
#![feature(ready_macro)]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
Expand Down Expand Up @@ -455,9 +454,6 @@ pub use core::pin;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::ptr;
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated, deprecated_in_future)]
pub use core::raw;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::result;
#[unstable(feature = "async_stream", issue = "79024")]
pub use core::stream;
Expand Down
17 changes: 4 additions & 13 deletions src/test/ui/cast/fat-ptr-cast-rpass.rs
@@ -1,12 +1,6 @@
// run-pass

// Remove this file when `std::raw` is removed.
// The replacement pointer metadata APIs are tested in library/core/tests/ptr.rs
#![allow(deprecated)]
#![feature(raw)]

use std::mem;
use std::raw;
#![feature(ptr_metadata)]

trait Foo {
fn foo(&self) {}
Expand All @@ -31,13 +25,10 @@ fn main() {

// And conversion to a void pointer/address for trait objects too.
let a: *mut dyn Foo = &mut Bar;
let b = a as *mut ();
let b = a as *mut () as usize;
let c = a as *const () as usize;
let d = unsafe {
let r: raw::TraitObject = mem::transmute(a);
r.data
};
let d = a.to_raw_parts().0 as usize;

assert_eq!(b, d);
assert_eq!(c, d as usize);
assert_eq!(c, d);
}
25 changes: 11 additions & 14 deletions src/test/ui/unsized/unsized3-rpass.rs
@@ -1,12 +1,11 @@
// run-pass
// Test structs with always-unsized fields.


#![allow(warnings)]
#![feature(box_syntax, unsize, raw)]
#![feature(box_syntax, unsize, ptr_metadata)]

use std::mem;
use std::raw;
use std::ptr;
use std::slice;

struct Foo<T> {
Expand All @@ -28,7 +27,7 @@ trait Tr {
}

struct St {
f: usize
f: usize,
}

impl Tr for St {
Expand All @@ -38,7 +37,7 @@ impl Tr for St {
}

struct Qux<'a> {
f: Tr+'a
f: Tr + 'a,
}

pub fn main() {
Expand All @@ -56,10 +55,10 @@ pub fn main() {

unsafe {
struct Foo_<T> {
f: [T; 3]
f: [T; 3],
}

let data: Box<Foo_<i32>> = box Foo_{f: [1, 2, 3] };
let data: Box<Foo_<i32>> = box Foo_ { f: [1, 2, 3] };
let x: &Foo<i32> = mem::transmute(slice::from_raw_parts(&*data, 3));
assert_eq!(x.f.len(), 3);
assert_eq!(x.f[0], 1);
Expand All @@ -69,8 +68,8 @@ pub fn main() {
f2: [u8; 5],
}

let data: Box<_> = box Baz_ {
f1: 42, f2: ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8] };
let data: Box<_> =
box Baz_ { f1: 42, f2: ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8] };
let x: &Baz = mem::transmute(slice::from_raw_parts(&*data, 5));
assert_eq!(x.f1, 42);
let chs: Vec<char> = x.f2.chars().collect();
Expand All @@ -82,15 +81,13 @@ pub fn main() {
assert_eq!(chs[4], 'e');

struct Qux_ {
f: St
f: St,
}

let obj: Box<St> = box St { f: 42 };
let obj: &Tr = &*obj;
let obj: raw::TraitObject = mem::transmute(&*obj);
let data: Box<_> = box Qux_{ f: St { f: 234 } };
let x: &Qux = mem::transmute(raw::TraitObject { vtable: obj.vtable,
data: mem::transmute(&*data) });
let data: Box<_> = box Qux_ { f: St { f: 234 } };
let x: &Qux = &*ptr::from_raw_parts::<Qux>((&*data as *const _).cast(), ptr::metadata(obj));
assert_eq!(x.f.foo(), 234);
}
}

0 comments on commit 71a567f

Please sign in to comment.