rust-lang / rust-lang/rust

Better float casting tests are needed in `coretests`

Open
#152,592 6 comments 0 reactions 1 assignee View on GitHub

@eggyal is already working on this.

Since Feb 14, 2026.

A-floating-point E-help-wanted E-medium T-libs
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

In https://github.com/rust-lang/rust/pull/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.