Skip to content

Add filtering to rustc_on_unimplemented to avoid misleading suggestion #55000

Open

Description

After #54946, the code let x = [0..10]; for _ in x {} will cause the following output:

error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
  --> $DIR/array-of-ranges.rs:11:14
   |
LL |     for _ in array_of_range {}
   |              ^^^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets
   |
   = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
   = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
   = note: required by `std::iter::IntoIterator::into_iter`

Add a way to identify this case to rustc_on_unimplemented, in order to avoid giving this misleading/incorrect diagnostic.

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

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.F-on_unimplementedError messages that can be tackled with `#[rustc_on_unimplemented]`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