miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec
This commit is contained in:
parent
1fef1524f2
commit
75f57670b0
@ -987,7 +987,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
|||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
|
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
|
||||||
pub const fn likely(b: bool) -> bool {
|
pub const fn likely(b: bool) -> bool {
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
@ -1007,7 +1007,7 @@ pub const fn likely(b: bool) -> bool {
|
|||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
|
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
|
||||||
pub const fn unlikely(b: bool) -> bool {
|
pub const fn unlikely(b: bool) -> bool {
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
@ -2471,7 +2471,7 @@ pub const fn unlikely(b: bool) -> bool {
|
|||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[rustc_do_not_const_check]
|
#[rustc_do_not_const_check]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
|
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
|
||||||
pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
|
pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
|
||||||
(ptr == other) as u8
|
(ptr == other) as u8
|
||||||
}
|
}
|
||||||
@ -2736,7 +2736,7 @@ pub const fn ub_checks() -> bool {
|
|||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
|
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
|
||||||
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
|
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
|
||||||
// const eval overrides this function, but runtime code for now just returns null pointers.
|
// const eval overrides this function, but runtime code for now just returns null pointers.
|
||||||
// See <https://github.com/rust-lang/rust/issues/93935>.
|
// See <https://github.com/rust-lang/rust/issues/93935>.
|
||||||
@ -2757,7 +2757,7 @@ pub const fn ub_checks() -> bool {
|
|||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
|
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
|
||||||
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
|
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
|
||||||
// Runtime NOP
|
// Runtime NOP
|
||||||
}
|
}
|
||||||
|
@ -43,18 +43,18 @@ fn call_intrinsic(
|
|||||||
if this.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
|
if this.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
|
||||||
throw_unsup_format!("unimplemented intrinsic: `{intrinsic_name}`")
|
throw_unsup_format!("unimplemented intrinsic: `{intrinsic_name}`")
|
||||||
}
|
}
|
||||||
let intrinsic_fallback_checks_ub = Symbol::intern("intrinsic_fallback_checks_ub");
|
let intrinsic_fallback_is_spec = Symbol::intern("intrinsic_fallback_is_spec");
|
||||||
if this
|
if this
|
||||||
.tcx
|
.tcx
|
||||||
.get_attrs_by_path(
|
.get_attrs_by_path(
|
||||||
instance.def_id(),
|
instance.def_id(),
|
||||||
&[sym::miri, intrinsic_fallback_checks_ub],
|
&[sym::miri, intrinsic_fallback_is_spec],
|
||||||
)
|
)
|
||||||
.next()
|
.next()
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
throw_unsup_format!(
|
throw_unsup_format!(
|
||||||
"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"
|
"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"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(Some(ty::Instance {
|
Ok(Some(ty::Instance {
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
error: unsupported operation: miri can only use intrinsic fallback bodies that check UB. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that
|
|
||||||
--> $DIR/intrinsic_fallback_checks_ub.rs:LL:CC
|
|
||||||
|
|
|
||||||
LL | ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ miri can only use intrinsic fallback bodies that check UB. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that
|
|
||||||
|
|
|
||||||
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
|
|
||||||
= note: BACKTRACE:
|
|
||||||
= note: inside `main` at $DIR/intrinsic_fallback_checks_ub.rs:LL:CC
|
|
||||||
|
|
||||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
|
||||||
|
|
@ -10,5 +10,5 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
|
ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
|
||||||
//~^ ERROR: can only use intrinsic fallback bodies that check UB.
|
//~^ ERROR: can only use intrinsic fallback bodies that exactly reflect the specification
|
||||||
}
|
}
|
14
src/tools/miri/tests/fail/intrinsic_fallback_is_spec.stderr
Normal file
14
src/tools/miri/tests/fail/intrinsic_fallback_is_spec.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
||||||
|
--> $DIR/intrinsic_fallback_is_spec.rs:LL:CC
|
||||||
|
|
|
||||||
|
LL | ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
||||||
|
|
|
||||||
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
|
||||||
|
= note: BACKTRACE:
|
||||||
|
= note: inside `main` at $DIR/intrinsic_fallback_is_spec.rs:LL:CC
|
||||||
|
|
||||||
|
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user