-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Poor error message from try! or ? and type-mismatch #36988
Comments
Yeah, the error about Carrier is even worse than before (which even then was not enough to get users all the way to "I need to change this function to return a Result"). Should we make Carrier a lang item so it can be special-cased here? |
This feels like a serious problem. This is an area where user confusion is common and it's a particular stumbling block for new users (the old message itself was a problem). I agree with @durka that it is probably worth special-casing here! |
Is the special case here that it expects () as the output but sees a Result? |
@jonathandturner we should be able to go further than that, since the message says "in this expansion of |
@durka - sounds good The macro backtrace should still be there for the |
If someone can give me a pointer on how to get the macro backtrace during error reporting, I can work on this. |
@durka - you can check Looks like E0308 is coming from |
Is this the same as #35946? |
@carols10cents yes. |
Close as a dupe of #35946 |
For
try!
we used to give a type mismatch message when the type of the value did not match the function type (see example below). We now give a message about theCarrier
trait, which the user should not know about, e.g.,error[E0277]: the trait bound
(): std::ops::Carrieris not satisfied
for the below example.I removed the following from doc/error-index.md
This code gives an error like this:
try!
returns aResult<T, E>
, and so the function must. Butmain()
has()
as its return type, hence the error.The text was updated successfully, but these errors were encountered: