-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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
Given the following code: play
trait MyIterator : Iterator {}
fn main() {
let _ = MyIterator::next;
//let _ = MyIterator<Item=()>::next;
}
The current output is:
error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified
--> src/main.rs:4:13
|
4 | let _ = MyIterator::next;
| ^^^^^^^^^^ help: specify the associated type: `MyIterator<Item = Type>`
But when when I write let _ = MyIterator<Item=()>::next;
, it gets interpreted as comparison expressions like (MyIterator < Item) = (() > ::next)
and it fails to compile with a lot of "cannot find value Item
in this scope" and "cannot find crate next
in the list of imported crates". The suggestion is confusing because it is unclear how to apply it.
The error goes away if you use Iterator
directly: let _ = Iterator::next;
produces the error one would expect:
error[E0283]: type annotations needed for `for<'r> fn(&'r mut Self) -> Option<<Self as Iterator>::Item>`
--> src/main.rs:2:13
|
2 | let _ = Iterator::next;
| - ^^^^^^^^^^^^^^ cannot infer type
| |
| consider giving this pattern the explicit type `for<'r> fn(&'r mut Self) -> Option<<Self as Iterator>::Item>`, with the type parameters specified
|
= note: cannot satisfy `_: Iterator`
note: required by `std::iter::Iterator::next`
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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.