-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Description
In #152512 we noticed that f128->int casts weren't working correctly in one of the codegen backends, which was surprising to find there because it meant the operations weren't previously tested anywhere in core. Miri has rather good tests for this at https://github.com/rust-lang/miri/blob/1a0186be3e011748b90ed6077a303e2a72992c2c/tests/pass/float.rs, it would be nice to port these to the standard library test suite.
There can just be a new casts.rs module under https://github.com/rust-lang/rust/blob/d7daac06d87e1252d10eaa44960164faac46beff/library/coretests/tests/floats/mod.rs and the relevant functions (casts, more_casts, and nan_casts) and their support macros can be copied there from Miri, turning functions into #[test] functions.
Note that we do have a number of these tests already at https://github.com/rust-lang/rust/blob/d7daac06d87e1252d10eaa44960164faac46beff/tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs, but those tend not to get run with all backends and can't be run on non-host targets.
Labeling easy since this should be pretty mechanical.
Cc @RalfJung, more float testing