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

"maybe try calling .iter()" on missing trait implementation #55159

Closed
TheSilvus opened this issue Oct 17, 2018 · 1 comment
Closed

"maybe try calling .iter()" on missing trait implementation #55159

TheSilvus opened this issue Oct 17, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@TheSilvus
Copy link

Implementing a trait that requires an iterator trait on a struct without implementing the iterator itself leads to an irrelevant error message.

fn main() {}

trait A: Iterator<Item=i32> {}

struct B {}
impl A for B {}

Error message:

error[E0277]: the trait bound `B: std::iter::Iterator` is not satisfied
 --> src/main.rs:6:6
  |
6 | impl A for B {}
  |      ^ `B` is not an iterator; maybe try calling `.iter()` or a similar method
  |
  = help: the trait `std::iter::Iterator` is not implemented for `B`

Actually implementing the iterator fixes the error.

I tried it on the Rust Playground, so I should have used the newest versions: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=a5a597c2a8d0fa4769ff30dca58443c0 . I ran it on all three channels.

@estebank
Copy link
Contributor

Fixed in #54946.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 17, 2018
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
Projects
None yet
Development

No branches or pull requests

2 participants