about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-04 04:04:47 +0000
committerbors <bors@rust-lang.org>2021-07-04 04:04:47 +0000
commit71a567fae4c282aa5ecb1e6e48f020ade8df23e7 (patch)
tree588d7f9f4cfca43a7c5e871b390d096eec0dd602 /src/test
parent154071194641d8db6c056b0d83dd0d071f9f6758 (diff)
parent0d1919c7ab149e0ed7f88643f3f94d59c06429bd (diff)
downloadrust-71a567fae4c282aa5ecb1e6e48f020ade8df23e7.tar.gz
rust-71a567fae4c282aa5ecb1e6e48f020ade8df23e7.zip
Auto merge of #86833 - crlf0710:remove-std-raw-mod, r=SimonSapin
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`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/cast/fat-ptr-cast-rpass.rs17
-rw-r--r--src/test/ui/unsized/unsized3-rpass.rs25
2 files changed, 15 insertions, 27 deletions
diff --git a/src/test/ui/cast/fat-ptr-cast-rpass.rs b/src/test/ui/cast/fat-ptr-cast-rpass.rs
index 9fa2255e1b3..f5747eb8b96 100644
--- a/src/test/ui/cast/fat-ptr-cast-rpass.rs
+++ b/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) {}
@@ -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);
 }
diff --git a/src/test/ui/unsized/unsized3-rpass.rs b/src/test/ui/unsized/unsized3-rpass.rs
index 65efbd6b520..c5c5ed26c73 100644
--- a/src/test/ui/unsized/unsized3-rpass.rs
+++ b/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> {
@@ -28,7 +27,7 @@ trait Tr {
 }
 
 struct St {
-    f: usize
+    f: usize,
 }
 
 impl Tr for St {
@@ -38,7 +37,7 @@ impl Tr for St {
 }
 
 struct Qux<'a> {
-    f: Tr+'a
+    f: Tr + 'a,
 }
 
 pub fn main() {
@@ -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);
@@ -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();
@@ -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);
     }
 }