-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
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
Code
let a = [1, 2, 4, 5, 6];
for e in a {
println!("{}", e);
}Compiler error
error[E0277]: the trait bound `[{integer}; 5]: std::iter::Iterator` is not satisfied
--> <anon>:6:5
|
6 | for e in a {
| ^ trait `[{integer}; 5]: std::iter::Iterator` not satisfied
|
= note: `[{integer}; 5]` is not an iterator; maybe try calling `.iter()` or a similar method
= note: required by `std::iter::IntoIterator::into_iter`
error: aborting due to previous error
Suggestion
Instead of suggesting .iter(), it'd be cool if we cool if we could check if the borrowed type implements IntoIterator and then suggest prefixing with &. More concretely, in the example above, [T; 5] does not implement IntoIterator but &[T; 5] does.
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.