-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Minimal reproduction:
|| {
Err(())?;
Ok(())
}
Leads to an error message like:
error[E0282]: type annotations needed
--> src/main.rs:3:9
|
3 | Err(())?;
| --------
| |
| cannot infer type for `_`
| in this macro invocation
error: aborting due to previous error
Because ?
uses Into
and it's ambiguous which type you're converting this error into. Even as a relatively-veteran Rust programmer it still took me some time and playing around before I worked out what was causing this error, I can't imagine how it must be for a new recruit. I think the ideal solution would be to have it default to Into<Self>
as long as the error types of all of the expressions ?
is used on match, but that would require an RFC and at the bare minimum a more explicit error message could be written for this case.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.