about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-22 14:35:46 +0000
committerbors <bors@rust-lang.org>2025-09-22 14:35:46 +0000
commitce4beebecb77821734079cff47d8af08f9f27f11 (patch)
tree209e2abf1633a20054a52c567ed8b2bf1ba51ae1 /src
parent29005cb128e6d447e6bd9c110c9a684665f95985 (diff)
parent055e05a338af00751ffccc992feeda227b8436b1 (diff)
downloadrust-ce4beebecb77821734079cff47d8af08f9f27f11.tar.gz
rust-ce4beebecb77821734079cff47d8af08f9f27f11.zip
Auto merge of #146683 - clarfonthey:safe-intrinsics, r=RalfJung,Amanieu
Mark float intrinsics with no preconditions as safe

Note: for ease of reviewing, the list of safe intrinsics is sorted in the first commit, and then safe intrinsics are added in the second commit.

All *recently added* float intrinsics have been correctly marked as safe to call due to the fact that they have no preconditions. This adds the remaining float intrinsics which are safe to call to the safe intrinsic list, and removes the unsafe blocks around their calls.

---

Side note: this may want a try run before being added to the queue, since I'm not sure if there's any tier-2 code that uses these intrinsics that might not be tested on the usual PR flow. We've already uncovered a few places in subtrees that do this, and it's worth double-checking before clogging up the queue.
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/tests/pass/float.rs4
-rw-r--r--src/tools/miri/tests/pass/intrinsics/fmuladd_nondeterministic.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/tools/miri/tests/pass/float.rs b/src/tools/miri/tests/pass/float.rs
index 3ce5ea8356b..3a764329f9b 100644
--- a/src/tools/miri/tests/pass/float.rs
+++ b/src/tools/miri/tests/pass/float.rs
@@ -1415,12 +1415,12 @@ fn test_fmuladd() {
 
     #[inline(never)]
     pub fn test_operations_f32(a: f32, b: f32, c: f32) {
-        assert_approx_eq!(unsafe { fmuladdf32(a, b, c) }, a * b + c);
+        assert_approx_eq!(fmuladdf32(a, b, c), a * b + c);
     }
 
     #[inline(never)]
     pub fn test_operations_f64(a: f64, b: f64, c: f64) {
-        assert_approx_eq!(unsafe { fmuladdf64(a, b, c) }, a * b + c);
+        assert_approx_eq!(fmuladdf64(a, b, c), a * b + c);
     }
 
     test_operations_f32(0.1, 0.2, 0.3);
diff --git a/src/tools/miri/tests/pass/intrinsics/fmuladd_nondeterministic.rs b/src/tools/miri/tests/pass/intrinsics/fmuladd_nondeterministic.rs
index b688405c4b1..4d3e91c4cba 100644
--- a/src/tools/miri/tests/pass/intrinsics/fmuladd_nondeterministic.rs
+++ b/src/tools/miri/tests/pass/intrinsics/fmuladd_nondeterministic.rs
@@ -28,7 +28,7 @@ fn main() {
             let c = std::hint::black_box(-a * b);
             // It is unspecified whether the following operation is fused or not. The
             // following evaluates to 0.0 if unfused, and nonzero (-1.66e-18) if fused.
-            let x = unsafe { fmuladdf64(a, b, c) };
+            let x = fmuladdf64(a, b, c);
             x == 0.0
         }),
         "`fmuladdf64` failed to be evaluated as both fused and unfused"
@@ -41,7 +41,7 @@ fn main() {
             let c = std::hint::black_box(-a * b);
             // It is unspecified whether the following operation is fused or not. The
             // following evaluates to 0.0 if unfused, and nonzero (-8.1956386e-10) if fused.
-            let x = unsafe { fmuladdf32(a, b, c) };
+            let x = fmuladdf32(a, b, c);
             x == 0.0
         }),
         "`fmuladdf32` failed to be evaluated as both fused and unfused"