Open progval opened 2 months ago
Similar to #124802?
Here is a slightly smaller reproduction that only uses core
and has a more egregious error message (“impl Iterator
is not an iterator”). Reduced from a case found by @zakarumych.
trait Missing {}
trait HasMethod {
fn foo(self);
}
impl<T: Iterator + Missing> HasMethod for T {
fn foo(self) {}
}
fn get_iter() -> impl Iterator {
// any Iterator impl will do
core::iter::once(())
}
fn main() {
get_iter().foo();
}
error[E0599]: no method named `foo` found for opaque type `impl Iterator` in the current scope
--> src/main.rs:15:16
|
15 | get_iter().foo();
| ^^^ `impl Iterator` is not an iterator
|
help: call `.into_iter()` first
|
15 | get_iter().into_iter().foo();
| ++++++++++++
Code
(inspired by rayon's
ParallelBridge
)playground
Current output
Desired output
The same error there is when removing the
.map()
Rationale and extra context
The error indicated the type does not implement
Iterator
, even though it does andSend
is the one that is missing.Other cases
No response
Rust Version
Anything else?
No response