Closed
Description
Inspired by this question on discord:
no method named extend found for struct Map<std::iter::Chain<Map<Windows<'_, Point>, [closure@src\graphics\slider.rs:39:22: 47:18]>, std::iter::Once<Point>>, [closure@src\graphics\slider.rs:49:22: 49:60]> in the current scope
how does map not have .extend
fn main() {
let v = vec![1_i32, 2, 3];
v.iter().map(|x| x * x).extend(std::iter::once(100));
}
Error:
error[E0599]: no method named `extend` found for struct `Map<std::slice::Iter<'_, i32>, [closure@src/main.rs:3:18: 3:27]>` in the current scope
--> src/main.rs:3:29
|
3 | v.iter().map(|x| x * x).extend(std::iter::once(100));
| ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@src/main.rs:3:18: 3:27]>`
It would be nice if rustc could notice that Map<T>
never has extend
for any T
, and use that information to simplify the error message to just
error[E0599]: no method named `extend` found for struct `Map<_>` in the current scope
in order to focus the user better on the relevant part.
Can the name resolution engine do that? (It can for a generic parameter, of course, but then it's only looking at the known trait bounds, which is a little different.)