Skip to content

Better float casting tests are needed in coretests #152592

@tgross35

Description

@tgross35

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

Metadata

Metadata

Assignees

Labels

A-floating-pointArea: Floating point numbers and arithmeticE-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions