Skip to content

Extend invalid floating point literal suffix suggestion #100527

Closed
@Rageking8

Description

@Rageking8

Given the following code: link

fn main() {
    let a = 12.f;
    let b = 34.F;
    let c = 56.l;
    let d = 78.L;
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0610]](https://doc.rust-lang.org/nightly/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
 --> src/main.rs:2:16
  |
2 |     let a = 12.f;
  |                ^

error[[E0610]](https://doc.rust-lang.org/nightly/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
 --> src/main.rs:3:16
  |
3 |     let b = 34.F;
  |                ^

error[[E0610]](https://doc.rust-lang.org/nightly/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
 --> src/main.rs:4:16
  |
4 |     let c = 56.l;
  |                ^

error[[E0610]](https://doc.rust-lang.org/nightly/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
 --> src/main.rs:5:16
  |
5 |     let d = 78.L;
  |                ^

For more information about this error, try `rustc --explain E0610`.
error: could not compile `playground` due to 4 previous errors

Ideally for all the above invalid ways to writing a floating point literal, the complier should highlight that there are only 2 valid floating point literal suffix "f32" and "f64". Additionally, it may also include a note informing the user that a trailing '0' must be present in floating point literals.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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