Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_middle: ImmTy's Display implementation adds a weird-looking suffix to special floating point values. #118221

Closed
eduardosm opened this issue Nov 23, 2023 · 1 comment · Fixed by #118271
Labels
A-floating-point Area: Floating point numbers and arithmetic A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eduardosm
Copy link
Contributor

When printing an ImmTy that contains an special floating point value such as infinity or NaN, it will add an f32 or f64 suffix, making it look like Inff32 or NaNf32, which does not look very pretty.

First observed in rust-lang/miri#3185 (comment).

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 23, 2023
@RalfJung
Copy link
Member

This should probably be Inf_f32 or so instead.

The code for that is here:

ty::Float(ty::FloatTy::F32) => {
p!(write("{}f32", Single::try_from(int).unwrap()))
}
ty::Float(ty::FloatTy::F64) => {
p!(write("{}f64", Double::try_from(int).unwrap()))
}

@bors bors closed this as completed in a663bb9 Nov 25, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 25, 2023
Rollup merge of rust-lang#118271 - compiler-errors:float, r=RalfJung

Separate `NaN`/`Inf` floats with `_`

r? RalfJung

Fixes rust-lang#118221

No test 🤷 unless you know a good way to print an `ImmTy` in a unit test?
@fmease fmease added A-pretty Area: Pretty printing (including `-Z unpretty`) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-floating-point Area: Floating point numbers and arithmetic and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-floating-point Area: Floating point numbers and arithmetic A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants