make the new intrinsics safe

This commit is contained in:
Ralf Jung 2025-02-22 14:12:55 +01:00
parent 04e7a10af6
commit d1b34acb3b
6 changed files with 16 additions and 12 deletions

View file

@ -137,6 +137,10 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
| sym::fmul_algebraic | sym::fmul_algebraic
| sym::fdiv_algebraic | sym::fdiv_algebraic
| sym::frem_algebraic | sym::frem_algebraic
| sym::round_ties_even_f16
| sym::round_ties_even_f32
| sym::round_ties_even_f64
| sym::round_ties_even_f128
| sym::const_eval_select => hir::Safety::Safe, | sym::const_eval_select => hir::Safety::Safe,
_ => hir::Safety::Unsafe, _ => hir::Safety::Unsafe,
}; };

View file

@ -2748,13 +2748,13 @@ pub unsafe fn truncf128(_x: f128) -> f128 {
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub unsafe fn round_ties_even_f16(_x: f16) -> f16 { pub fn round_ties_even_f16(_x: f16) -> f16 {
unreachable!() unreachable!()
} }
/// To be removed on next bootstrap bump. /// To be removed on next bootstrap bump.
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub unsafe fn round_ties_even_f16(x: f16) -> f16 { pub fn round_ties_even_f16(x: f16) -> f16 {
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
@ -2775,13 +2775,13 @@ pub unsafe fn round_ties_even_f16(x: f16) -> f16 {
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub unsafe fn round_ties_even_f32(_x: f32) -> f32 { pub fn round_ties_even_f32(_x: f32) -> f32 {
unreachable!() unreachable!()
} }
/// To be removed on next bootstrap bump. /// To be removed on next bootstrap bump.
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub unsafe fn round_ties_even_f32(x: f32) -> f32 { pub fn round_ties_even_f32(x: f32) -> f32 {
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
@ -2802,13 +2802,13 @@ pub unsafe fn round_ties_even_f32(x: f32) -> f32 {
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub unsafe fn round_ties_even_f64(_x: f64) -> f64 { pub fn round_ties_even_f64(_x: f64) -> f64 {
unreachable!() unreachable!()
} }
/// To be removed on next bootstrap bump. /// To be removed on next bootstrap bump.
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub unsafe fn round_ties_even_f64(x: f64) -> f64 { pub fn round_ties_even_f64(x: f64) -> f64 {
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
@ -2829,13 +2829,13 @@ pub unsafe fn round_ties_even_f64(x: f64) -> f64 {
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub unsafe fn round_ties_even_f128(_x: f128) -> f128 { pub fn round_ties_even_f128(_x: f128) -> f128 {
unreachable!() unreachable!()
} }
/// To be removed on next bootstrap bump. /// To be removed on next bootstrap bump.
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub unsafe fn round_ties_even_f128(x: f128) -> f128 { pub fn round_ties_even_f128(x: f128) -> f128 {
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind] #[rustc_nounwind]

View file

@ -129,7 +129,7 @@ impl f128 {
#[unstable(feature = "f128", issue = "116909")] #[unstable(feature = "f128", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"] #[must_use = "method returns a new number and does not mutate the original value"]
pub fn round_ties_even(self) -> f128 { pub fn round_ties_even(self) -> f128 {
unsafe { intrinsics::round_ties_even_f128(self) } intrinsics::round_ties_even_f128(self)
} }
/// Returns the integer part of `self`. /// Returns the integer part of `self`.

View file

@ -129,7 +129,7 @@ impl f16 {
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"] #[must_use = "method returns a new number and does not mutate the original value"]
pub fn round_ties_even(self) -> f16 { pub fn round_ties_even(self) -> f16 {
unsafe { intrinsics::round_ties_even_f16(self) } intrinsics::round_ties_even_f16(self)
} }
/// Returns the integer part of `self`. /// Returns the integer part of `self`.

View file

@ -125,7 +125,7 @@ impl f32 {
#[stable(feature = "round_ties_even", since = "1.77.0")] #[stable(feature = "round_ties_even", since = "1.77.0")]
#[inline] #[inline]
pub fn round_ties_even(self) -> f32 { pub fn round_ties_even(self) -> f32 {
unsafe { intrinsics::round_ties_even_f32(self) } intrinsics::round_ties_even_f32(self)
} }
/// Returns the integer part of `self`. /// Returns the integer part of `self`.

View file

@ -125,7 +125,7 @@ impl f64 {
#[stable(feature = "round_ties_even", since = "1.77.0")] #[stable(feature = "round_ties_even", since = "1.77.0")]
#[inline] #[inline]
pub fn round_ties_even(self) -> f64 { pub fn round_ties_even(self) -> f64 {
unsafe { intrinsics::round_ties_even_f64(self) } intrinsics::round_ties_even_f64(self)
} }
/// Returns the integer part of `self`. /// Returns the integer part of `self`.