-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Error message for missing return value with Result type is unclear #24889
Comments
Code example: fn foo() -> Result<u8, u64> {
Ok(1);
}
fn main() {} |
Perhaps this should trigger |
An ideal error message would be like the one generated here: fn thing() -> u32 {
7u32;
}
fn main() {}
|
Triage: here's today's error, no real change:
|
Going to go ahead and mark this as E-needstest since it feels easy to regress on and medium-level bad if we do. In particular, I think adding to the existing UI test
|
…lacrum Add test for rust-lang#24889 Fixes rust-lang#24889. r? @Mark-Simulacrum (Thanks for the instructions).
…lacrum Add test for rust-lang#24889 Fixes rust-lang#24889. r? @Mark-Simulacrum (Thanks for the instructions).
The error message that I get looks like this:
The highlight is on the leading
Ok
, which is misleading. The actual fix was to either precede the statement withreturn
, or to drop the trailing;
. It would be great if the compiler were to suggest this as well, as the current error message alone is cryptic.The text was updated successfully, but these errors were encountered: