Open
Description
Code
struct Foo;
impl Foo {
fn foo(&self) {}
}
fn main() {
let thing: Vec<Foo> = vec![];
let foo = |i| {
thing[i].foo();
};
}
Current output
error[E0282]: type annotations needed
--> src/main.rs:11:9
|
11 | thing[i].foo();
| ^^^^^^^^ cannot infer type
Desired output
error[E0282]: type annotations needed
--> src/main.rs:11:9
|
11 | thing[i].foo();
| ^ cannot infer type
Rationale and extra context
Should also probably explain that the index op's output type depends on the input type, so it needs to know what input type it is at this point.
Other cases
No response
Rust Version
rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2
Compiler returned: 0
Anything else?
No response