- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
In the following example, Rust 1.22.1 and nightly complain about T of Foobar not being iter::Iterator, which IterWrapper demands.
use std::iter;
struct IterWrapper<T:iter::Iterator> {
    iter: T
}
struct Foobar<T> {
    w: IterWrapper<T>
}The suggestion consider adding a "where T: std::iter::Iterator" bound is correct, the main suggestion maybe try calling ".iter()" or a similar method is not applicable to this situation, though.
error[E0277]: the trait bound `T: std::iter::Iterator` is not satisfied
 --> src/main.rs:8:5
  |
8 |     w: IterWrapper<T>
  |     ^^^^^^^^^^^^^^^^^ `T` is not an iterator; maybe try calling `.iter()` or a similar method
  |
  = help: the trait `std::iter::Iterator` is not implemented for `T`
  = help: consider adding a `where T: std::iter::Iterator` bound
  = note: required by `IterWrapper`
error: aborting due to previous error
Same problem for an impl<T> Foobar<T>: Rustc suggest to call .iter() on the type-parameter, which is nonsense.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.