Skip to content

Prefer new associated numeric consts in float error messages #78382

Closed
@bstrie

Description

@bstrie

This program:

fn main() {
    let _ =  3.40282357e+38_f32;
    let _ =  1.7976931348623159e+308_f64;
}

Produces this output:

error: literal out of range for `f32`
 --> src/main.rs:2:14
  |
2 |     let _ =  3.40282357e+38_f32;
  |              ^^^^^^^^^^^^^^^^^^
  |
  = note: `#[deny(overflowing_literals)]` on by default
  = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `std::f32::INFINITY`

error: literal out of range for `f64`
 --> src/main.rs:3:14
  |
3 |     let _ =  1.7976931348623159e+308_f64;
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `std::f64::INFINITY`

Note the references to std::{f32, 64}::INFINITY; these symbols have been superseded by associated consts at {f32,f64}::INFINITY (#68490).

  1. Update the error message to suggest the new symbols

  2. Determine if any of the other old symbols are contained in any error messages.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler 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