Skip to content
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

Mention function return type explictly in errors #39909

Closed
ChrisJefferson opened this issue Feb 17, 2017 · 1 comment
Closed

Mention function return type explictly in errors #39909

ChrisJefferson opened this issue Feb 17, 2017 · 1 comment

Comments

@ChrisJefferson
Copy link
Contributor

I, like many other rust beginners, hit the "no try! in main problem". I'm not saying it should be fixed, but the error message should be more helpful. Could it explictly mention the fact this is to do with return values? It is currently:

 --> test.rs:13:5
   |
13 |     try!(io::stdin().read_line(&mut guess));
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result`
   |
   = note: expected type `()`
              found type `std::result::Result<_, _>`
   = help: here are some functions which might fulfill your needs:
           - .unwrap()
           - .unwrap_err()
           - .unwrap_or_default()
   = note: this error originates in a macro outside of the current crate

Perhaps the error could change to something like: return type of main is (), trying to return enum std::result::Result (obviously don't hard-wire for main). This makes it more clear why we expected ().

I suspected this would already be reported somewhere, but I can't find it.

@steveklabnik
Copy link
Member

This is a duplicate of #35946 and many other linked issues. We agree it's a big deal! I'm going to close it so we can keep discussion all in one place, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants