You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bad error message when using try operator in a closure #46680
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.
error[E0282]: type annotations needed for `[closure@src/main.rs:3:13: 6:6]`
--> src/main.rs:4:9
|
3 | let x = || {
| - consider giving `x` the explicit type `[closure@src/main.rs:3:13: 6:6]`, with the type parameters specified
4 | Err(())?;
| ^^^^^^^^ cannot infer type
Activity
estebank commentedon Aug 12, 2019
Current output:
Rollup merge of rust-lang#63507 - estebank:type-inference-error, r=Ce…