Skip to content

Commit eaa3b35

Browse files
committed
most const intrinsics don't need an explicit rustc_const_unstable any more
1 parent 601642f commit eaa3b35

8 files changed

+44
-57
lines changed

library/core/src/intrinsics.rs

+32-41
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,6 @@ pub const fn bitreverse<T: Copy>(_x: T) -> T {
23892389
/// large and difficult to optimize.
23902390
///
23912391
/// The stabilized version of this intrinsic is [`Ord::cmp`].
2392-
#[rustc_const_unstable(feature = "const_three_way_compare", issue = "none")]
23932392
#[rustc_intrinsic]
23942393
#[rustc_intrinsic_must_be_overridden]
23952394
pub const fn three_way_compare<T: Copy>(_lhs: T, _rhss: T) -> crate::cmp::Ordering {
@@ -2457,7 +2456,7 @@ pub const fn mul_with_overflow<T: Copy>(_x: T, _y: T) -> (T, bool) {
24572456
/// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`
24582457
///
24592458
/// This intrinsic does not have a stable counterpart.
2460-
#[rustc_const_unstable(feature = "const_exact_div", issue = "none")]
2459+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_exact_div", issue = "none"))]
24612460
#[rustc_nounwind]
24622461
#[rustc_intrinsic]
24632462
#[rustc_intrinsic_must_be_overridden]
@@ -2784,7 +2783,7 @@ pub const unsafe fn ptr_offset_from<T>(_ptr: *const T, _base: *const T) -> isize
27842783
}
27852784

27862785
/// See documentation of `<*const T>::sub_ptr` for details.
2787-
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
2786+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892"))]
27882787
#[rustc_nounwind]
27892788
#[rustc_intrinsic]
27902789
#[rustc_intrinsic_must_be_overridden]
@@ -2796,8 +2795,7 @@ pub const unsafe fn ptr_offset_from_unsigned<T>(_ptr: *const T, _base: *const T)
27962795
/// Returns `2` if the result is unknown.
27972796
/// Returns `1` if the pointers are guaranteed equal
27982797
/// Returns `0` if the pointers are guaranteed inequal
2799-
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
2800-
#[unstable(feature = "core_intrinsics", issue = "none")]
2798+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020"))]
28012799
#[rustc_intrinsic]
28022800
#[rustc_nounwind]
28032801
#[rustc_do_not_const_check]
@@ -2830,7 +2828,7 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
28302828
///
28312829
/// (The implementation is allowed to branch on the results of comparisons,
28322830
/// which is UB if any of their inputs are `undef`.)
2833-
#[rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none")]
2831+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_intrinsic_raw_eq", issue = "none"))]
28342832
#[rustc_nounwind]
28352833
#[rustc_intrinsic]
28362834
#[rustc_intrinsic_must_be_overridden]
@@ -2852,7 +2850,10 @@ pub const unsafe fn raw_eq<T>(_a: &T, _b: &T) -> bool {
28522850
/// that differs. That allows optimizations that can read in large chunks.
28532851
///
28542852
/// [valid]: crate::ptr#safety
2855-
#[rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none")]
2853+
#[cfg_attr(
2854+
bootstrap,
2855+
rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none")
2856+
)]
28562857
#[rustc_nounwind]
28572858
#[rustc_intrinsic]
28582859
#[rustc_intrinsic_must_be_overridden]
@@ -2863,7 +2864,7 @@ pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: u
28632864
/// See documentation of [`std::hint::black_box`] for details.
28642865
///
28652866
/// [`std::hint::black_box`]: crate::hint::black_box
2866-
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
2867+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_black_box", issue = "none"))]
28672868
#[rustc_nounwind]
28682869
#[rustc_intrinsic]
28692870
#[rustc_intrinsic_must_be_overridden]
@@ -3036,7 +3037,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
30363037
#[rustc_nounwind]
30373038
#[inline]
30383039
#[rustc_intrinsic]
3039-
// This has fallback `const fn` MIR, so shouldn't need stability, see #122652
3040+
// Unstable because `swap_nonoverlapping` is unstable.
30403041
#[rustc_const_unstable(feature = "const_typed_swap", issue = "none")]
30413042
pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
30423043
// SAFETY: The caller provided single non-overlapping items behind
@@ -3059,7 +3060,6 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
30593060
/// primarily used by [`ub_checks::assert_unsafe_precondition`].
30603061
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ub_checks", issue = "none"))]
30613062
#[cfg_attr(not(bootstrap), rustc_const_stable_intrinsic)] // just for UB checks
3062-
#[unstable(feature = "core_intrinsics", issue = "none")]
30633063
#[inline(always)]
30643064
#[rustc_intrinsic]
30653065
pub const fn ub_checks() -> bool {
@@ -3075,7 +3075,6 @@ pub const fn ub_checks() -> bool {
30753075
/// - At compile time, a compile error occurs if this constraint is violated.
30763076
/// - At runtime, it is not checked.
30773077
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
3078-
#[unstable(feature = "core_intrinsics", issue = "none")]
30793078
#[rustc_nounwind]
30803079
#[rustc_intrinsic]
30813080
#[miri::intrinsic_fallback_is_spec]
@@ -3175,7 +3174,7 @@ pub const fn min_align_of<T>() -> usize {
31753174
/// It's "tracking issue" is [#91971](https://github.com/rust-lang/rust/issues/91971).
31763175
#[rustc_nounwind]
31773176
#[unstable(feature = "core_intrinsics", issue = "none")]
3178-
#[rustc_const_unstable(feature = "const_pref_align_of", issue = "91971")]
3177+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_pref_align_of", issue = "91971"))]
31793178
#[rustc_intrinsic]
31803179
#[rustc_intrinsic_must_be_overridden]
31813180
pub const unsafe fn pref_align_of<T>() -> usize {
@@ -3193,7 +3192,7 @@ pub const unsafe fn pref_align_of<T>() -> usize {
31933192
/// The to-be-stabilized version of this intrinsic is [`crate::mem::variant_count`].
31943193
#[rustc_nounwind]
31953194
#[unstable(feature = "core_intrinsics", issue = "none")]
3196-
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
3195+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "variant_count", issue = "73662"))]
31973196
#[rustc_intrinsic]
31983197
#[rustc_intrinsic_must_be_overridden]
31993198
pub const fn variant_count<T>() -> usize {
@@ -3209,7 +3208,7 @@ pub const fn variant_count<T>() -> usize {
32093208
/// See [`crate::mem::size_of_val_raw`] for safety conditions.
32103209
#[rustc_nounwind]
32113210
#[unstable(feature = "core_intrinsics", issue = "none")]
3212-
#[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")]
3211+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_size_of_val", issue = "46571"))]
32133212
#[rustc_intrinsic]
32143213
#[rustc_intrinsic_must_be_overridden]
32153214
pub const unsafe fn size_of_val<T: ?Sized>(_ptr: *const T) -> usize {
@@ -3225,7 +3224,7 @@ pub const unsafe fn size_of_val<T: ?Sized>(_ptr: *const T) -> usize {
32253224
/// See [`crate::mem::align_of_val_raw`] for safety conditions.
32263225
#[rustc_nounwind]
32273226
#[unstable(feature = "core_intrinsics", issue = "none")]
3228-
#[rustc_const_unstable(feature = "const_align_of_val", issue = "46571")]
3227+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_align_of_val", issue = "46571"))]
32293228
#[rustc_intrinsic]
32303229
#[rustc_intrinsic_must_be_overridden]
32313230
pub const unsafe fn min_align_of_val<T: ?Sized>(_ptr: *const T) -> usize {
@@ -3242,7 +3241,7 @@ pub const unsafe fn min_align_of_val<T: ?Sized>(_ptr: *const T) -> usize {
32423241
/// The stabilized version of this intrinsic is [`core::any::type_name`].
32433242
#[rustc_nounwind]
32443243
#[unstable(feature = "core_intrinsics", issue = "none")]
3245-
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
3244+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_name", issue = "63084"))]
32463245
#[rustc_intrinsic]
32473246
#[rustc_intrinsic_must_be_overridden]
32483247
pub const fn type_name<T: ?Sized>() -> &'static str {
@@ -3261,7 +3260,7 @@ pub const fn type_name<T: ?Sized>() -> &'static str {
32613260
/// The stabilized version of this intrinsic is [`core::any::TypeId::of`].
32623261
#[rustc_nounwind]
32633262
#[unstable(feature = "core_intrinsics", issue = "none")]
3264-
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
3263+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_type_id", issue = "77125"))]
32653264
#[rustc_intrinsic]
32663265
#[rustc_intrinsic_must_be_overridden]
32673266
pub const fn type_id<T: ?Sized + 'static>() -> u128 {
@@ -3636,8 +3635,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
36363635
/// The stabilized version of this intrinsic is
36373636
/// [`f16::min`]
36383637
#[rustc_nounwind]
3639-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3640-
#[rustc_const_unstable(feature = "f16", issue = "116909")]
3638+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))]
36413639
#[rustc_intrinsic]
36423640
#[rustc_intrinsic_must_be_overridden]
36433641
pub const fn minnumf16(_x: f16, _y: f16) -> f16 {
@@ -3654,7 +3652,7 @@ pub const fn minnumf16(_x: f16, _y: f16) -> f16 {
36543652
/// The stabilized version of this intrinsic is
36553653
/// [`f32::min`]
36563654
#[rustc_nounwind]
3657-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3655+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
36583656
#[rustc_intrinsic]
36593657
#[rustc_intrinsic_must_be_overridden]
36603658
pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
@@ -3671,7 +3669,7 @@ pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
36713669
/// The stabilized version of this intrinsic is
36723670
/// [`f64::min`]
36733671
#[rustc_nounwind]
3674-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3672+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
36753673
#[rustc_intrinsic]
36763674
#[rustc_intrinsic_must_be_overridden]
36773675
pub const fn minnumf64(_x: f64, _y: f64) -> f64 {
@@ -3688,8 +3686,7 @@ pub const fn minnumf64(_x: f64, _y: f64) -> f64 {
36883686
/// The stabilized version of this intrinsic is
36893687
/// [`f128::min`]
36903688
#[rustc_nounwind]
3691-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3692-
#[rustc_const_unstable(feature = "f128", issue = "116909")]
3689+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))]
36933690
#[rustc_intrinsic]
36943691
#[rustc_intrinsic_must_be_overridden]
36953692
pub const fn minnumf128(_x: f128, _y: f128) -> f128 {
@@ -3706,8 +3703,7 @@ pub const fn minnumf128(_x: f128, _y: f128) -> f128 {
37063703
/// The stabilized version of this intrinsic is
37073704
/// [`f16::max`]
37083705
#[rustc_nounwind]
3709-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3710-
#[rustc_const_unstable(feature = "f16", issue = "116909")]
3706+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))]
37113707
#[rustc_intrinsic]
37123708
#[rustc_intrinsic_must_be_overridden]
37133709
pub const fn maxnumf16(_x: f16, _y: f16) -> f16 {
@@ -3724,7 +3720,7 @@ pub const fn maxnumf16(_x: f16, _y: f16) -> f16 {
37243720
/// The stabilized version of this intrinsic is
37253721
/// [`f32::max`]
37263722
#[rustc_nounwind]
3727-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3723+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
37283724
#[rustc_intrinsic]
37293725
#[rustc_intrinsic_must_be_overridden]
37303726
pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
@@ -3741,7 +3737,7 @@ pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
37413737
/// The stabilized version of this intrinsic is
37423738
/// [`f64::max`]
37433739
#[rustc_nounwind]
3744-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3740+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
37453741
#[rustc_intrinsic]
37463742
#[rustc_intrinsic_must_be_overridden]
37473743
pub const fn maxnumf64(_x: f64, _y: f64) -> f64 {
@@ -3758,8 +3754,7 @@ pub const fn maxnumf64(_x: f64, _y: f64) -> f64 {
37583754
/// The stabilized version of this intrinsic is
37593755
/// [`f128::max`]
37603756
#[rustc_nounwind]
3761-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3762-
#[rustc_const_unstable(feature = "f128", issue = "116909")]
3757+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))]
37633758
#[rustc_intrinsic]
37643759
#[rustc_intrinsic_must_be_overridden]
37653760
pub const fn maxnumf128(_x: f128, _y: f128) -> f128 {
@@ -3771,8 +3766,7 @@ pub const fn maxnumf128(_x: f128, _y: f128) -> f128 {
37713766
/// The stabilized version of this intrinsic is
37723767
/// [`f16::abs`](../../std/primitive.f16.html#method.abs)
37733768
#[rustc_nounwind]
3774-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3775-
#[rustc_const_unstable(feature = "f16", issue = "116909")]
3769+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))]
37763770
#[rustc_intrinsic]
37773771
#[rustc_intrinsic_must_be_overridden]
37783772
pub const unsafe fn fabsf16(_x: f16) -> f16 {
@@ -3784,7 +3778,7 @@ pub const unsafe fn fabsf16(_x: f16) -> f16 {
37843778
/// The stabilized version of this intrinsic is
37853779
/// [`f32::abs`](../../std/primitive.f32.html#method.abs)
37863780
#[rustc_nounwind]
3787-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3781+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
37883782
#[rustc_intrinsic]
37893783
#[rustc_intrinsic_must_be_overridden]
37903784
pub const unsafe fn fabsf32(_x: f32) -> f32 {
@@ -3796,7 +3790,7 @@ pub const unsafe fn fabsf32(_x: f32) -> f32 {
37963790
/// The stabilized version of this intrinsic is
37973791
/// [`f64::abs`](../../std/primitive.f64.html#method.abs)
37983792
#[rustc_nounwind]
3799-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3793+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
38003794
#[rustc_intrinsic]
38013795
#[rustc_intrinsic_must_be_overridden]
38023796
pub const unsafe fn fabsf64(_x: f64) -> f64 {
@@ -3808,8 +3802,7 @@ pub const unsafe fn fabsf64(_x: f64) -> f64 {
38083802
/// The stabilized version of this intrinsic is
38093803
/// [`f128::abs`](../../std/primitive.f128.html#method.abs)
38103804
#[rustc_nounwind]
3811-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3812-
#[rustc_const_unstable(feature = "f128", issue = "116909")]
3805+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))]
38133806
#[rustc_intrinsic]
38143807
#[rustc_intrinsic_must_be_overridden]
38153808
pub const unsafe fn fabsf128(_x: f128) -> f128 {
@@ -3821,8 +3814,7 @@ pub const unsafe fn fabsf128(_x: f128) -> f128 {
38213814
/// The stabilized version of this intrinsic is
38223815
/// [`f16::copysign`](../../std/primitive.f16.html#method.copysign)
38233816
#[rustc_nounwind]
3824-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3825-
#[rustc_const_unstable(feature = "f16", issue = "116909")]
3817+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f16", issue = "116909"))]
38263818
#[rustc_intrinsic]
38273819
#[rustc_intrinsic_must_be_overridden]
38283820
pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 {
@@ -3834,7 +3826,7 @@ pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 {
38343826
/// The stabilized version of this intrinsic is
38353827
/// [`f32::copysign`](../../std/primitive.f32.html#method.copysign)
38363828
#[rustc_nounwind]
3837-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3829+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
38383830
#[rustc_intrinsic]
38393831
#[rustc_intrinsic_must_be_overridden]
38403832
pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
@@ -3845,7 +3837,7 @@ pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
38453837
/// The stabilized version of this intrinsic is
38463838
/// [`f64::copysign`](../../std/primitive.f64.html#method.copysign)
38473839
#[rustc_nounwind]
3848-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3840+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
38493841
#[rustc_intrinsic]
38503842
#[rustc_intrinsic_must_be_overridden]
38513843
pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 {
@@ -3857,8 +3849,7 @@ pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 {
38573849
/// The stabilized version of this intrinsic is
38583850
/// [`f128::copysign`](../../std/primitive.f128.html#method.copysign)
38593851
#[rustc_nounwind]
3860-
// #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
3861-
#[rustc_const_unstable(feature = "f128", issue = "116909")]
3852+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "f128", issue = "116909"))]
38623853
#[rustc_intrinsic]
38633854
#[rustc_intrinsic_must_be_overridden]
38643855
pub const unsafe fn copysignf128(_x: f128, _y: f128) -> f128 {

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
//
108108
// Library features:
109109
// tidy-alphabetical-start
110+
#![cfg_attr(bootstrap, feature(const_exact_div))]
110111
#![cfg_attr(bootstrap, feature(const_fmt_arguments_new))]
111112
#![feature(array_ptr_get)]
112113
#![feature(asm_experimental_arch)]
@@ -120,7 +121,6 @@
120121
#![feature(const_black_box)]
121122
#![feature(const_char_encode_utf16)]
122123
#![feature(const_eval_select)]
123-
#![feature(const_exact_div)]
124124
#![feature(const_float_methods)]
125125
#![feature(const_hash)]
126126
#![feature(const_heap)]

tests/ui/consts/const-compare-bytes-ub.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ check-fail
22

33
#![feature(core_intrinsics)]
4-
#![feature(const_intrinsic_compare_bytes)]
54
use std::intrinsics::compare_bytes;
65
use std::mem::MaybeUninit;
76

tests/ui/consts/const-compare-bytes-ub.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/const-compare-bytes-ub.rs:10:9
2+
--> $DIR/const-compare-bytes-ub.rs:9:9
33
|
44
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got a null pointer
66

77
error[E0080]: evaluation of constant value failed
8-
--> $DIR/const-compare-bytes-ub.rs:14:9
8+
--> $DIR/const-compare-bytes-ub.rs:13:9
99
|
1010
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
1212

1313
error[E0080]: evaluation of constant value failed
14-
--> $DIR/const-compare-bytes-ub.rs:18:9
14+
--> $DIR/const-compare-bytes-ub.rs:17:9
1515
|
1616
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
1818

1919
error[E0080]: evaluation of constant value failed
20-
--> $DIR/const-compare-bytes-ub.rs:22:9
20+
--> $DIR/const-compare-bytes-ub.rs:21:9
2121
|
2222
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 which is only 3 bytes from the end of the allocation
2424

2525
error[E0080]: evaluation of constant value failed
26-
--> $DIR/const-compare-bytes-ub.rs:26:9
26+
--> $DIR/const-compare-bytes-ub.rs:25:9
2727
|
2828
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 which is only 3 bytes from the end of the allocation
3030

3131
error[E0080]: evaluation of constant value failed
32-
--> $DIR/const-compare-bytes-ub.rs:30:9
32+
--> $DIR/const-compare-bytes-ub.rs:29:9
3333
|
3434
LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1)
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
3636

3737
error[E0080]: evaluation of constant value failed
38-
--> $DIR/const-compare-bytes-ub.rs:34:9
38+
--> $DIR/const-compare-bytes-ub.rs:33:9
3939
|
4040
LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
4242

4343
error[E0080]: evaluation of constant value failed
44-
--> $DIR/const-compare-bytes-ub.rs:38:9
44+
--> $DIR/const-compare-bytes-ub.rs:37:9
4545
|
4646
LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>())
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer

tests/ui/consts/const-compare-bytes.rs

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

33
#![feature(core_intrinsics)]
4-
#![feature(const_intrinsic_compare_bytes)]
54
use std::intrinsics::compare_bytes;
65

76
fn main() {

tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(core_intrinsics)]
2-
#![feature(const_intrinsic_raw_eq)]
32

43
const RAW_EQ_PADDING: bool = unsafe {
54
std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))

0 commit comments

Comments
 (0)