From b80a96c286628453dec50b9609570949d5d387a9 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 15 Apr 2021 02:25:40 +0200 Subject: [PATCH 1/4] Deprecate the core::raw / std::raw module It only contains the `TraitObject` struct which exposes components of wide pointer. Pointer metadata APIs are designed to replace this: https://github.com/rust-lang/rust/issues/81513 --- library/core/src/raw.rs | 4 ++++ library/std/src/lib.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/library/core/src/raw.rs b/library/core/src/raw.rs index 1227d9b01f011..6d1e28f4cd7d7 100644 --- a/library/core/src/raw.rs +++ b/library/core/src/raw.rs @@ -1,5 +1,9 @@ #![allow(missing_docs)] #![unstable(feature = "raw", issue = "27751")] +#![rustc_deprecated( + since = "1.53.0", + reason = "use pointer metadata APIs instead https://github.com/rust-lang/rust/issues/81513" +)] //! Contains struct definitions for the layout of compiler built-in types. //! diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 90603cd983677..39280f569c440 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -456,6 +456,7 @@ pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ptr; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated_in_future)] pub use core::raw; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; From 28efb22745640f5a3218195da6cfbaff1696ff2e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 14 Apr 2021 18:44:22 -0700 Subject: [PATCH 2/4] s/deprecated_in_future/deprecated/ --- library/std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 39280f569c440..f7345bef561aa 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -456,7 +456,7 @@ pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ptr; #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated_in_future)] +#[allow(deprecated)] pub use core::raw; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; From e9bd80f96134a3a6bb57b8d73526ae527143b20d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 14 Apr 2021 19:28:39 -0700 Subject: [PATCH 3/4] Requires deprecated *and* deprecated_in_future, depending on what stage is building --- library/std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index f7345bef561aa..e6d8892c6fc12 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -456,7 +456,7 @@ pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ptr; #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] +#[allow(deprecated, deprecated_in_future)] pub use core::raw; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; From 4d683c0292500738c80ba8824dfaf4d3a0df4ba0 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 15 Apr 2021 09:40:00 +0200 Subject: [PATCH 4/4] Allow use of deprecated std::raw in a test for that feature --- library/core/tests/mem.rs | 3 +++ src/test/ui/cast/fat-ptr-cast-rpass.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/library/core/tests/mem.rs b/library/core/tests/mem.rs index c0b75036f4f3e..dfdbc9305d2a3 100644 --- a/library/core/tests/mem.rs +++ b/library/core/tests/mem.rs @@ -97,6 +97,9 @@ 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 { diff --git a/src/test/ui/cast/fat-ptr-cast-rpass.rs b/src/test/ui/cast/fat-ptr-cast-rpass.rs index 5f5e621d762df..9fa2255e1b348 100644 --- a/src/test/ui/cast/fat-ptr-cast-rpass.rs +++ b/src/test/ui/cast/fat-ptr-cast-rpass.rs @@ -1,5 +1,8 @@ // 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; @@ -37,5 +40,4 @@ fn main() { assert_eq!(b, d); assert_eq!(c, d as usize); - }