Give the assume
intrinsic a fallback body
This commit is contained in:
parent
ae9d7b0c64
commit
6a671bdbf1
2 changed files with 24 additions and 14 deletions
|
@ -407,7 +407,7 @@ pub fn check_intrinsic_type(
|
||||||
}
|
}
|
||||||
sym::float_to_int_unchecked => (2, 0, vec![param(0)], param(1)),
|
sym::float_to_int_unchecked => (2, 0, vec![param(0)], param(1)),
|
||||||
|
|
||||||
sym::assume => (0, 0, vec![tcx.types.bool], Ty::new_unit(tcx)),
|
sym::assume => (0, 1, vec![tcx.types.bool], Ty::new_unit(tcx)),
|
||||||
sym::likely => (0, 0, vec![tcx.types.bool], tcx.types.bool),
|
sym::likely => (0, 0, vec![tcx.types.bool], tcx.types.bool),
|
||||||
sym::unlikely => (0, 0, vec![tcx.types.bool], tcx.types.bool),
|
sym::unlikely => (0, 0, vec![tcx.types.bool], tcx.types.bool),
|
||||||
|
|
||||||
|
|
|
@ -937,6 +937,8 @@ extern "rust-intrinsic" {
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
pub fn unreachable() -> !;
|
pub fn unreachable() -> !;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Informs the optimizer that a condition is always true.
|
/// Informs the optimizer that a condition is always true.
|
||||||
/// If the condition is false, the behavior is undefined.
|
/// If the condition is false, the behavior is undefined.
|
||||||
///
|
///
|
||||||
|
@ -949,8 +951,16 @@ extern "rust-intrinsic" {
|
||||||
/// This intrinsic does not have a stable counterpart.
|
/// This intrinsic does not have a stable counterpart.
|
||||||
#[rustc_const_stable(feature = "const_assume", since = "1.77.0")]
|
#[rustc_const_stable(feature = "const_assume", since = "1.77.0")]
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
pub fn assume(b: bool);
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
|
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
|
||||||
|
pub const unsafe fn assume(b: bool) {
|
||||||
|
if !b {
|
||||||
|
// SAFETY: the caller must guarantee the argument is never `false`
|
||||||
|
unsafe { unreachable() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "rust-intrinsic" {
|
||||||
/// Hints to the compiler that branch condition is likely to be true.
|
/// Hints to the compiler that branch condition is likely to be true.
|
||||||
/// Returns the value passed to it.
|
/// Returns the value passed to it.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue