diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-07 20:49:41 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-07 20:49:41 +1000 |
| commit | 71f04692c32e181ab566c01942f1418dec8662d4 (patch) | |
| tree | e3968ffc6ac854258aba9981d527925acb03c1cc /library/core/src | |
| parent | 995ca3e532b48b689567533e6b736675e38b741e (diff) | |
| parent | 71add2f5f74c7b7f5d7cc77a763f12513e021b0d (diff) | |
| download | rust-71f04692c32e181ab566c01942f1418dec8662d4.tar.gz rust-71f04692c32e181ab566c01942f1418dec8662d4.zip | |
Rollup merge of #143906 - LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung
Miri: non-deterministic floating point operations in `foreign_items` Part of [rust-lang/miri/#3555](https://github.com/rust-lang/miri/issues/3555#issue-2278914000), this pr does the `foreign_items` work. Some things have changed since rust-lang/rust#138062 and rust-lang/rust#142514. I moved the "helpers" used for creating fixed outputs and clamping operations to their defined ranges to `math.rs`. These are now also extended to handle the floating-point operations in `foreign_items`. Tests in `miri/tests/float.rs` were changed/added. Failing tests in `std` were extracted, run under miri with `-Zmiri-many-seeds=0..1000` and changed accordingly. Double checked with `-Zmiri-many-seeds`. I noticed that the C standard doesn't specify the output ranges for all of its mathematical operations; it just specifies them as: ``` Returns The sinh functions return sinh x. ``` So I used [Wolfram|Alpha](https://www.wolframalpha.com/).
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/num/f32.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index f8344da79ad..6c7ba491971 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -1936,8 +1936,8 @@ pub mod math { /// let abs_difference_x = (f32::math::abs_sub(x, 1.0) - 2.0).abs(); /// let abs_difference_y = (f32::math::abs_sub(y, 1.0) - 0.0).abs(); /// - /// assert!(abs_difference_x <= f32::EPSILON); - /// assert!(abs_difference_y <= f32::EPSILON); + /// assert!(abs_difference_x <= 1e-6); + /// assert!(abs_difference_y <= 1e-6); /// ``` /// /// _This standalone function is for testing only. @@ -1982,7 +1982,7 @@ pub mod math { /// // x^(1/3) - 2 == 0 /// let abs_difference = (f32::math::cbrt(x) - 2.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` /// /// _This standalone function is for testing only. |
