Skip to content

Commit 04dbfe3

Browse files
authored
Unrolled build for rust-lang#124896
Rollup merge of rust-lang#124896 - RalfJung:miri-intrinsic-fallback, r=oli-obk miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec Checking UB is not the only concern, we also have to make sure we are not losing out on non-determinism. r? ``@oli-obk`` (not urgent, take your time)
2 parents 22f5bdc + 75f5767 commit 04dbfe3

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

library/core/src/intrinsics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -987,7 +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)]
990+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
991991
pub const fn likely(b: bool) -> bool {
992992
b
993993
}
@@ -1007,7 +1007,7 @@ pub const fn likely(b: bool) -> bool {
10071007
#[unstable(feature = "core_intrinsics", issue = "none")]
10081008
#[rustc_intrinsic]
10091009
#[rustc_nounwind]
1010-
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
1010+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
10111011
pub const fn unlikely(b: bool) -> bool {
10121012
b
10131013
}
@@ -2483,7 +2483,7 @@ extern "rust-intrinsic" {
24832483
#[rustc_nounwind]
24842484
#[rustc_do_not_const_check]
24852485
#[inline]
2486-
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
2486+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
24872487
pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
24882488
(ptr == other) as u8
24892489
}
@@ -2748,7 +2748,7 @@ pub const fn ub_checks() -> bool {
27482748
#[unstable(feature = "core_intrinsics", issue = "none")]
27492749
#[rustc_nounwind]
27502750
#[rustc_intrinsic]
2751-
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
2751+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
27522752
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
27532753
// const eval overrides this function, but runtime code for now just returns null pointers.
27542754
// See <https://github.com/rust-lang/rust/issues/93935>.
@@ -2769,7 +2769,7 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
27692769
#[unstable(feature = "core_intrinsics", issue = "none")]
27702770
#[rustc_nounwind]
27712771
#[rustc_intrinsic]
2772-
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
2772+
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
27732773
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
27742774
// Runtime NOP
27752775
}

src/tools/miri/src/intrinsics/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4343
if this.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
4444
throw_unsup_format!("unimplemented intrinsic: `{intrinsic_name}`")
4545
}
46-
let intrinsic_fallback_checks_ub = Symbol::intern("intrinsic_fallback_checks_ub");
46+
let intrinsic_fallback_is_spec = Symbol::intern("intrinsic_fallback_is_spec");
4747
if this
4848
.tcx
4949
.get_attrs_by_path(
5050
instance.def_id(),
51-
&[sym::miri, intrinsic_fallback_checks_ub],
51+
&[sym::miri, intrinsic_fallback_is_spec],
5252
)
5353
.next()
5454
.is_none()
5555
{
5656
throw_unsup_format!(
57-
"miri can only use intrinsic fallback bodies that check UB. After verifying that `{intrinsic_name}` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that"
57+
"Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `{intrinsic_name}` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that"
5858
);
5959
}
6060
Ok(Some(ty::Instance {

src/tools/miri/tests/fail/intrinsic_fallback_checks_ub.stderr

-14
This file was deleted.

src/tools/miri/tests/fail/intrinsic_fallback_checks_ub.rs src/tools/miri/tests/fail/intrinsic_fallback_is_spec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
1010

1111
fn main() {
1212
ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
13-
//~^ ERROR: can only use intrinsic fallback bodies that check UB.
13+
//~^ ERROR: can only use intrinsic fallback bodies that exactly reflect the specification
1414
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unsupported operation: Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that
2+
--> $DIR/intrinsic_fallback_is_spec.rs:LL:CC
3+
|
4+
LL | ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that
6+
|
7+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
8+
= note: BACKTRACE:
9+
= note: inside `main` at $DIR/intrinsic_fallback_is_spec.rs:LL:CC
10+
11+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)