Skip to content

When encountering .iter() on an impl Iterator, suggest removing the method call #153667

@estebank

Description

@estebank

When encountering .iter() on an impl Iterator, suggest removing the method call:

serror[E0599]: no method named `iter` found for opaque type `impl std::iter::Iterator<Item = &AssocItem> + '_` in the current scope
    --> compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:3130:67
     |
3130 |                 if !self.tcx.provided_trait_methods(trait_def_id).iter().any(|method| {
     |                                                                   ^^^^
     |
help: there is a method `filter` with a similar name, but with different arguments
    --> /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/iter/traits/iterator.rs:911:4

This can likely be done generally by looking at every method with that name and seeing if their return type matches the impl Trait we already have.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-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