Skip to content

Commit 571651c

Browse files
authored
Rollup merge of rust-lang#124293 - oli-obk:miri_intrinsic_fallback_body, r=RalfJung
Let miri and const eval execute intrinsics' fallback bodies fixes rust-lang/miri#3397 r? ``@RalfJung``
2 parents 8187d38 + 6b993f5 commit 571651c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/src/intrinsics.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ pub const unsafe fn assume(b: bool) {
987987
#[unstable(feature = "core_intrinsics", issue = "none")]
988988
#[rustc_intrinsic]
989989
#[rustc_nounwind]
990+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
990991
pub const fn likely(b: bool) -> bool {
991992
b
992993
}
@@ -1006,6 +1007,7 @@ pub const fn likely(b: bool) -> bool {
10061007
#[unstable(feature = "core_intrinsics", issue = "none")]
10071008
#[rustc_intrinsic]
10081009
#[rustc_nounwind]
1010+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
10091011
pub const fn unlikely(b: bool) -> bool {
10101012
b
10111013
}
@@ -2469,6 +2471,7 @@ extern "rust-intrinsic" {
24692471
#[rustc_nounwind]
24702472
#[rustc_do_not_const_check]
24712473
#[inline]
2474+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
24722475
pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
24732476
(ptr == other) as u8
24742477
}
@@ -2733,8 +2736,10 @@ pub const fn ub_checks() -> bool {
27332736
#[unstable(feature = "core_intrinsics", issue = "none")]
27342737
#[rustc_nounwind]
27352738
#[rustc_intrinsic]
2739+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
27362740
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
2737-
// const eval overrides this function, but runtime code should always just return null pointers.
2741+
// const eval overrides this function, but runtime code for now just returns null pointers.
2742+
// See <https://github.com/rust-lang/rust/issues/93935>.
27382743
crate::ptr::null_mut()
27392744
}
27402745

@@ -2752,7 +2757,10 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
27522757
#[unstable(feature = "core_intrinsics", issue = "none")]
27532758
#[rustc_nounwind]
27542759
#[rustc_intrinsic]
2755-
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
2760+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
2761+
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
2762+
// Runtime NOP
2763+
}
27562764

27572765
/// `ptr` must point to a vtable.
27582766
/// The intrinsic will return the size stored in that vtable.

0 commit comments

Comments
 (0)