-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
give a specific error message for the wrong return type #28953
Comments
We have decided, generally, to assume that when reading API docs, you already know Rust. If you click the link to show the example in the playpen, it will insert the stuff needed to make it compile. That said, E0308 could use a specific call-out of this situation. And yes, there's an RFC repo issue about main and Result. |
Yes, I wasn't suggesting doing this in the E0308 says "This error occurs when the compiler was unable to infer the concrete type of a variable", but there's no variable involved here, at least at the user-visible level. Could we have a more specific error code for 'returning X in a function declared to return Y'? Or, otherwise, mention in the documentation for E0308 that it covers that case too? |
/cc #27112 |
Given #27112 exists, I think the real heart remaining part of this is https://doc.rust-lang.org/error-index.html#E0308 says "wrong type for a variable" but it would be clearer with "wrong return type." |
yay, thanks!
|
This can be confusing for people new to rust and perhaps trying to copy some example code from https://doc.rust-lang.org/std/fs/struct.File.html:
https://play.rust-lang.org/?gist=2201429be6f0833e2161&version=stable
At the moment this produces
https://doc.rust-lang.org/error-index.html#E0308 is OK but may be hard to see how it applies.
Perhaps the friendliest thing would be to suggest using
unwrap()
rather thantry!
, though perhaps that is too specialized.I think there was another bug about
main
returning a Result?The text was updated successfully, but these errors were encountered: