Skip to content

Commit c298402

Browse files
committed
Make apply_random_float_error_ulp() a noop.
1 parent ecb0f1b commit c298402

File tree

3 files changed

+22
-34
lines changed

3 files changed

+22
-34
lines changed

library/std/tests/floats/f16.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -959,19 +959,11 @@ fn test_algebraic() {
959959
let a: f16 = 123.0;
960960
let b: f16 = 456.0;
961961

962-
if cfg!(miri) {
963-
assert_approx_eq!(a.algebraic_add(b), a + b, 1e1);
964-
assert_approx_eq!(a.algebraic_sub(b), a - b, 1e1);
965-
assert_approx_eq!(a.algebraic_mul(b), a * b, 1e3);
966-
assert_approx_eq!(a.algebraic_div(b), a / b, 1e-2);
967-
assert_approx_eq!(a.algebraic_rem(b), a % b, 1e1);
968-
} else {
969-
assert_approx_eq!(a.algebraic_add(b), a + b);
970-
assert_approx_eq!(a.algebraic_sub(b), a - b);
971-
assert_approx_eq!(a.algebraic_mul(b), a * b);
972-
assert_approx_eq!(a.algebraic_div(b), a / b);
973-
assert_approx_eq!(a.algebraic_rem(b), a % b);
974-
}
962+
assert_approx_eq!(a.algebraic_add(b), a + b);
963+
assert_approx_eq!(a.algebraic_sub(b), a - b);
964+
assert_approx_eq!(a.algebraic_mul(b), a * b);
965+
assert_approx_eq!(a.algebraic_div(b), a / b);
966+
assert_approx_eq!(a.algebraic_rem(b), a % b);
975967
}
976968

977969
#[test]

library/std/tests/floats/f32.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -921,17 +921,9 @@ fn test_algebraic() {
921921
let a: f32 = 123.0;
922922
let b: f32 = 456.0;
923923

924-
if cfg!(miri) {
925-
assert_approx_eq!(a.algebraic_add(b), a + b, 1e-2);
926-
assert_approx_eq!(a.algebraic_sub(b), a - b, 1e-2);
927-
assert_approx_eq!(a.algebraic_mul(b), a * b, 1e-1);
928-
assert_approx_eq!(a.algebraic_div(b), a / b, 1e-5);
929-
assert_approx_eq!(a.algebraic_rem(b), a % b, 1e-2);
930-
} else {
931-
assert_approx_eq!(a.algebraic_add(b), a + b);
932-
assert_approx_eq!(a.algebraic_sub(b), a - b);
933-
assert_approx_eq!(a.algebraic_mul(b), a * b);
934-
assert_approx_eq!(a.algebraic_div(b), a / b);
935-
assert_approx_eq!(a.algebraic_rem(b), a % b);
936-
}
924+
assert_approx_eq!(a.algebraic_add(b), a + b);
925+
assert_approx_eq!(a.algebraic_sub(b), a - b);
926+
assert_approx_eq!(a.algebraic_mul(b), a * b);
927+
assert_approx_eq!(a.algebraic_div(b), a / b);
928+
assert_approx_eq!(a.algebraic_rem(b), a % b);
937929
}

src/tools/miri/src/math.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ pub(crate) fn apply_random_float_error<F: rustc_apfloat::Float>(
3131
/// This function implements these instructions such that applying a 2^N ULP error is less error prone.
3232
/// So for a 2^N ULP error, you would pass N as the `ulp_exponent` argument.
3333
pub(crate) fn apply_random_float_error_ulp<F: rustc_apfloat::Float>(
34-
ecx: &mut crate::MiriInterpCx<'_>,
34+
_ecx: &mut crate::MiriInterpCx<'_>,
3535
val: F,
36-
ulp_exponent: u32,
36+
_ulp_exponent: u32,
3737
) -> F {
38-
let n = i32::try_from(ulp_exponent)
39-
.expect("`err_scale_for_ulp`: exponent is too large to create an error scale");
40-
// we know this fits
41-
let prec = i32::try_from(F::PRECISION).unwrap();
42-
let err_scale = -(prec - n - 1);
43-
apply_random_float_error(ecx, val, err_scale)
38+
val
39+
// TODO: Re-enable after reducing errors and updating tests. Background:
40+
// https://github.com/rust-lang/rust/pull/136457#discussion_r2019904691
41+
//
42+
// let n = i32::try_from(ulp_exponent)
43+
// .expect("`err_scale_for_ulp`: exponent is too large to create an error scale");
44+
// // we know this fits
45+
// let prec = i32::try_from(F::PRECISION).unwrap();
46+
// let err_scale = -(prec - n - 1);
47+
// apply_random_float_error(ecx, val, err_scale)
4448
}
4549

4650
pub(crate) fn sqrt<S: rustc_apfloat::ieee::Semantics>(x: IeeeFloat<S>) -> IeeeFloat<S> {

0 commit comments

Comments
 (0)