Skip to content

Commit 71a567f

Browse files
committed
Auto merge of rust-lang#86833 - crlf0710:remove-std-raw-mod, r=SimonSapin
Remove the deprecated `core::raw` and `std::raw` module. A few months has passed since rust-lang#84207. I think now it's time for the final removal. Closes rust-lang#27751. r? `@m-ou-se`
2 parents 1540711 + 0d1919c commit 71a567f

File tree

8 files changed

+15
-146
lines changed

8 files changed

+15
-146
lines changed

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ pub mod option;
255255
pub mod panic;
256256
pub mod panicking;
257257
pub mod pin;
258-
pub mod raw;
259258
pub mod result;
260259
#[unstable(feature = "async_stream", issue = "79024")]
261260
pub mod stream;

library/core/src/raw.rs

-90
This file was deleted.

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(try_find)]
3030
#![feature(is_sorted)]
3131
#![feature(pattern)]
32-
#![feature(raw)]
3332
#![feature(sort_internals)]
3433
#![feature(slice_partition_at_index)]
3534
#![feature(maybe_uninit_uninit_array)]

library/core/tests/mem.rs

-22
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,6 @@ fn test_transmute_copy() {
9797
assert_eq!(1, unsafe { transmute_copy(&1) });
9898
}
9999

100-
// Remove this test when `std::raw` is removed.
101-
// The replacement pointer metadata APIs are tested in library/core/tests/ptr.rs
102-
#[allow(deprecated)]
103-
#[test]
104-
fn test_transmute() {
105-
trait Foo {
106-
fn dummy(&self) {}
107-
}
108-
impl Foo for isize {}
109-
110-
let a = box 100isize as Box<dyn Foo>;
111-
unsafe {
112-
let x: ::core::raw::TraitObject = transmute(a);
113-
assert!(*(x.data as *const isize) == 100);
114-
let _x: Box<dyn Foo> = transmute(x);
115-
}
116-
117-
unsafe {
118-
assert_eq!(transmute::<_, Vec<u8>>("L".to_string()), [76]);
119-
}
120-
}
121-
122100
#[test]
123101
#[allow(dead_code)]
124102
fn test_discriminant_send_sync() {

library/panic_unwind/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![feature(unwind_attributes)]
2424
#![feature(abi_thiscall)]
2525
#![feature(rustc_attrs)]
26-
#![feature(raw)]
2726
#![panic_runtime]
2827
#![feature(panic_runtime)]
2928
// `real_imp` is unused with Miri, so silence warnings.

library/std/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@
303303
#![feature(pin_static_ref)]
304304
#![feature(prelude_import)]
305305
#![feature(ptr_internals)]
306-
#![feature(raw)]
307306
#![feature(ready_macro)]
308307
#![feature(rustc_attrs)]
309308
#![feature(rustc_private)]
@@ -455,9 +454,6 @@ pub use core::pin;
455454
#[stable(feature = "rust1", since = "1.0.0")]
456455
pub use core::ptr;
457456
#[stable(feature = "rust1", since = "1.0.0")]
458-
#[allow(deprecated, deprecated_in_future)]
459-
pub use core::raw;
460-
#[stable(feature = "rust1", since = "1.0.0")]
461457
pub use core::result;
462458
#[unstable(feature = "async_stream", issue = "79024")]
463459
pub use core::stream;

src/test/ui/cast/fat-ptr-cast-rpass.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// run-pass
22

3-
// Remove this file when `std::raw` is removed.
4-
// The replacement pointer metadata APIs are tested in library/core/tests/ptr.rs
5-
#![allow(deprecated)]
6-
#![feature(raw)]
7-
8-
use std::mem;
9-
use std::raw;
3+
#![feature(ptr_metadata)]
104

115
trait Foo {
126
fn foo(&self) {}
@@ -31,13 +25,10 @@ fn main() {
3125

3226
// And conversion to a void pointer/address for trait objects too.
3327
let a: *mut dyn Foo = &mut Bar;
34-
let b = a as *mut ();
28+
let b = a as *mut () as usize;
3529
let c = a as *const () as usize;
36-
let d = unsafe {
37-
let r: raw::TraitObject = mem::transmute(a);
38-
r.data
39-
};
30+
let d = a.to_raw_parts().0 as usize;
4031

4132
assert_eq!(b, d);
42-
assert_eq!(c, d as usize);
33+
assert_eq!(c, d);
4334
}

src/test/ui/unsized/unsized3-rpass.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// run-pass
22
// Test structs with always-unsized fields.
33

4-
54
#![allow(warnings)]
6-
#![feature(box_syntax, unsize, raw)]
5+
#![feature(box_syntax, unsize, ptr_metadata)]
76

87
use std::mem;
9-
use std::raw;
8+
use std::ptr;
109
use std::slice;
1110

1211
struct Foo<T> {
@@ -28,7 +27,7 @@ trait Tr {
2827
}
2928

3029
struct St {
31-
f: usize
30+
f: usize,
3231
}
3332

3433
impl Tr for St {
@@ -38,7 +37,7 @@ impl Tr for St {
3837
}
3938

4039
struct Qux<'a> {
41-
f: Tr+'a
40+
f: Tr + 'a,
4241
}
4342

4443
pub fn main() {
@@ -56,10 +55,10 @@ pub fn main() {
5655

5756
unsafe {
5857
struct Foo_<T> {
59-
f: [T; 3]
58+
f: [T; 3],
6059
}
6160

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

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

8483
struct Qux_ {
85-
f: St
84+
f: St,
8685
}
8786

8887
let obj: Box<St> = box St { f: 42 };
8988
let obj: &Tr = &*obj;
90-
let obj: raw::TraitObject = mem::transmute(&*obj);
91-
let data: Box<_> = box Qux_{ f: St { f: 234 } };
92-
let x: &Qux = mem::transmute(raw::TraitObject { vtable: obj.vtable,
93-
data: mem::transmute(&*data) });
89+
let data: Box<_> = box Qux_ { f: St { f: 234 } };
90+
let x: &Qux = &*ptr::from_raw_parts::<Qux>((&*data as *const _).cast(), ptr::metadata(obj));
9491
assert_eq!(x.f.foo(), 234);
9592
}
9693
}

0 commit comments

Comments
 (0)