-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
When writing floating point numbers, some people try to include the dot and and exponent notation. Rust sees this as a field access on an integral value. It should suggest adding a 0
after the dot.
Given the following code: Playpen
fn main() {
let n = 2.e1;
}
The current output is:
Compiling playground v0.0.1 (/playground)
error[[E0610]](https://doc.rust-lang.org/stable/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
--> src/main.rs:2:15
|
2 | let n = 2.e1;
| ^^
For more information about this error, try `rustc --explain E0610`.
error: could not compile `playground` due to previous error
Ideally the output should suggest adding a zero, like as follows:
Compiling playground v0.0.1 (/playground)
error[[E0610]](https://doc.rust-lang.org/stable/error-index.html#E0610): `{integer}` is a primitive type and therefore doesn't have fields
--> src/main.rs:2:15
|
2 | let n = 2.e1;
| ^^
For more information about this error, try `rustc --explain E0610`.
error: could not compile `playground` due to previous error
help: If the number is meant to be a floating point number, add a `0` after the period.
--> src/main.rs:2:15
|
2 | let n = 2.0e1;
| ^
It might also be good to squelch the E0610 message altogether too.
SvetlinZarev, leonardo-m, jdahlstrom, joseph-gio, hearues-zueke-github and 1 more
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.