Skip to content

Commit 59c0265

Browse files
committed
intrinsics: deprecate calling them via the unstable std::intrinsics path
1 parent fe94c91 commit 59c0265

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

library/core/src/intrinsics/mod.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,11 @@ pub const fn forget<T: ?Sized>(_: T) {
19091909
/// }
19101910
/// ```
19111911
#[stable(feature = "rust1", since = "1.0.0")]
1912-
#[rustc_allowed_through_unstable_modules]
1912+
#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)]
1913+
#[cfg_attr(
1914+
not(bootstrap),
1915+
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
1916+
)]
19131917
#[rustc_const_stable(feature = "const_transmute", since = "1.56.0")]
19141918
#[rustc_diagnostic_item = "transmute"]
19151919
#[rustc_nounwind]
@@ -4353,7 +4357,11 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *cons
43534357
/// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
43544358
#[doc(alias = "memcpy")]
43554359
#[stable(feature = "rust1", since = "1.0.0")]
4356-
#[rustc_allowed_through_unstable_modules]
4360+
#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)]
4361+
#[cfg_attr(
4362+
not(bootstrap),
4363+
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
4364+
)]
43574365
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
43584366
#[inline(always)]
43594367
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4457,7 +4465,11 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
44574465
/// ```
44584466
#[doc(alias = "memmove")]
44594467
#[stable(feature = "rust1", since = "1.0.0")]
4460-
#[rustc_allowed_through_unstable_modules]
4468+
#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)]
4469+
#[cfg_attr(
4470+
not(bootstrap),
4471+
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
4472+
)]
44614473
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
44624474
#[inline(always)]
44634475
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4540,7 +4552,11 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
45404552
/// ```
45414553
#[doc(alias = "memset")]
45424554
#[stable(feature = "rust1", since = "1.0.0")]
4543-
#[rustc_allowed_through_unstable_modules]
4555+
#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)]
4556+
#[cfg_attr(
4557+
not(bootstrap),
4558+
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
4559+
)]
45444560
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
45454561
#[inline(always)]
45464562
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

tests/ui/stability-attribute/accidental-stable-in-unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ use core::unicode::UNICODE_VERSION; //~ ERROR use of unstable library feature `u
88
// Known accidental stabilizations with known users
99
// fully stable @ core::mem::transmute
1010
use core::intrinsics::transmute; // depended upon by rand_core
11+
//~^WARN deprecated

tests/ui/stability-attribute/accidental-stable-in-unstable.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ LL | use core::unicode::UNICODE_VERSION;
77
= help: add `#![feature(unicode_internals)]` to the crate attributes to enable
88
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99

10-
error: aborting due to 1 previous error
10+
warning: use of deprecated module `std::intrinsics`: import this function via `std::mem` instead
11+
--> $DIR/accidental-stable-in-unstable.rs:10:23
12+
|
13+
LL | use core::intrinsics::transmute; // depended upon by rand_core
14+
| ^^^^^^^^^
15+
|
16+
= note: `#[warn(deprecated)]` on by default
17+
18+
error: aborting due to 1 previous error; 1 warning emitted
1119

1220
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)