Skip to content

Suggest missing . for typo in ranges #101883

Open
@Rageking8

Description

@Rageking8
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.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Sep 16, 2022
self-assigned this
on Sep 16, 2022
added
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-papercutDiagnostics: An error or lint that needs small tweaks.
on Sep 16, 2022
estebank

estebank commented on Sep 16, 2022

@estebank
Contributor

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

leonardo-m

leonardo-m commented on Nov 8, 2022

@leonardo-m

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 {".

added 3 commits that reference this issue on Nov 11, 2022

Rollup merge of rust-lang#104144 - TaKO8Ki:suggest-removing-unnecessa…

c2b4744

Rollup merge of rust-lang#104144 - TaKO8Ki:suggest-removing-unnecessa…

081cc38

Rollup merge of rust-lang#104144 - TaKO8Ki:suggest-removing-unnecessa…

e944a06
added 2 commits that reference this issue on Nov 12, 2022

Rollup merge of rust-lang#104144 - TaKO8Ki:suggest-removing-unnecessa…

02ef4f2

Rollup merge of rust-lang#104144 - TaKO8Ki:suggest-removing-unnecessa…

55ae651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.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

      Participants

      @estebank@leonardo-m@TaKO8Ki@Rageking8

      Issue actions

        Suggest missing `.` for typo in ranges · Issue #101883 · rust-lang/rust