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

Suggest missing . for typo in ranges #101883

Open
Rageking8 opened this issue Sep 16, 2022 · 2 comments
Open

Suggest missing . for typo in ranges #101883

Rageking8 opened this issue Sep 16, 2022 · 2 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Rageking8
Copy link
Contributor

Given the following code: link

fn main() {
    for i in 0.10 {

    }
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0277]](https://doc.rust-lang.org/nightly/error-index.html#E0277): `{float}` is not an iterator
 --> src/main.rs:2:14
  |
2 |     for i in 0.10 {
  |              ^^^^ `{float}` is not an iterator
  |
  = help: the trait `Iterator` is not implemented for `{float}`
  = note: required for `{float}` to implement `IntoIterator`

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

Ideally the output should suggest adding a . due to the typo. Thanks.

@Rageking8 Rageking8 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 16, 2022
@TaKO8Ki TaKO8Ki self-assigned this Sep 16, 2022
@estebank estebank added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. labels Sep 16, 2022
@estebank
Copy link
Contributor

We might also want to handle the opposite case: let _: f64 = 0..10;

@leonardo-m
Copy link

Avoiding stuff like "in 0.10 {" is why I suggested that ".." is an operator, so the standard rustfmt formatting should have spaces around it, as in "in 0 .. 20 {".

Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…ry-dot, r=fee1-dead

Suggest removing unnecessary `.` to use a floating point literal

Fixes a part of rust-lang#101883
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…ry-dot, r=fee1-dead

Suggest removing unnecessary `.` to use a floating point literal

Fixes a part of rust-lang#101883
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…ry-dot, r=fee1-dead

Suggest removing unnecessary `.` to use a floating point literal

Fixes a part of rust-lang#101883
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 12, 2022
…ry-dot, r=fee1-dead

Suggest removing unnecessary `.` to use a floating point literal

Fixes a part of rust-lang#101883
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 12, 2022
…ry-dot, r=fee1-dead

Suggest removing unnecessary `.` to use a floating point literal

Fixes a part of rust-lang#101883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants