Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d5eabab7099a911f6bb9e93e9b7a0886
struct MyError;
fn foo(x: bool) -> Result<(), MyError> {
if x {
Err(MyError);
}
Ok(())
}
The current output is:
error[E0282]: type annotations needed
--> src/main.rs:5:9
|
5 | Err(MyError);
| ^^^ cannot infer type for type parameter `T` declared on the enum `Result`
Ideally the output should look like:
error[E0282]: type annotations needed
--> src/main.rs:5:9
|
5 | Err(MyError);
| ^^^ cannot infer type for type parameter `T` declared on the enum `Result`
help: try using `return` here:
|
5 | return Err(MyError);
| ^^^
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.