Code
fn usage() -> Result<(), ()> {
"".parse().unwrap()?;
Ok(())
}
Current output
error[E0284]: type annotations needed
--> src/lib.rs:2:8
|
2 | "".parse().unwrap()?;
| ^^^^^ cannot infer type of the type parameter `F` declared on the method `parse`
|
= note: cannot satisfy `<_ as FromStr>::Err == _`
help: consider specifying the generic argument
|
2 | "".parse::<F>().unwrap()?;
| +++++
Desired output
error[E0284]: type annotations needed
--> src/lib.rs:2:8
|
2 | "".parse().unwrap()?;
| ^^^^^ cannot infer type of the type parameter `F` declared on the method `parse`
|
= note: cannot satisfy `<_ as FromStr>::Err == _`
help: consider specifying a concrete type for the generic type `F`
|
2 | "".parse::<SomeConcreteType>().unwrap()?;
| ++++++++++++++++++++
I'm not tied to any specific wording here, just something to indicate that F is a generic type and that (except in very rare cases!) using F in the turbofish isn't going to be the right type.
Rust Version
rustc 1.92.0-nightly (5c7ae0c7e 2025-10-02)
binary: rustc
commit-hash: 5c7ae0c7ed184c603e5224604a9f33ca0e8e0b36
commit-date: 2025-10-02
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.2
Anything else?
Discovered while giving training to newcomers to Rust.
May be related to #128585.
Code
Current output
Desired output
I'm not tied to any specific wording here, just something to indicate that
Fis a generic type and that (except in very rare cases!) usingFin the turbofish isn't going to be the right type.Rust Version
Anything else?
Discovered while giving training to newcomers to Rust.
May be related to #128585.