-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Type errors with for
and do
expressions could be cleverer
#3651
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
Comments
I assume this got handled in #4141. |
Looking closer, I think the first example could still do with mentioning that I should use I still feel a bit weird that |
I'll take a look at this. |
There are definitely a couple things to fix here. First, the error message itself verges on misleading. In my branch, I've improved it quite a bit. Second, there are multiple errors. This is a case where my work on suppressing derived errors wasn't doing the trick; I've extended it a bit, but the output still doesn't look as good as I'd hope. Third, the spans (which are what tell the pretty-printer where to put the squiggly lines) are wrong. (I have no idea why). I'm working on it! |
As per rust-lang#3651, print out a clearer error message when a `for` gets used with the wrong type of iterator. Also fix spans on `for` loop bodies, and suppress some more derived errors.
Print out a clearer error message when a `for` gets used with the wrong type of iterator. Also fix spans on `for` loop bodies, and suppress some more derived errors. r=brson Closes #3651
Fixed in 5b64c79 -- please start a new issue if you find other confusing error messages like this! I love improving error messages. |
Calling functions meant to be used in
for
/do
expressions in the respective other kind of expression gives type errors. While that's correct, it's not immediately clear where the error is (not even the squiggly lines under the code excerpts are very clear), and I think it should be yelling at me directly for using the wrong syntax sugar instead of outlining how it noticed that I screwed up. Here is some examples that I found a bit misleading:I'm returning a
bool
, what's the matter! I expect rustc is pointing at the type oftask::spawn
here even though my closure is underlined and the mismatch is really betweenfor
and the function type.Similarly, in the inverse case,
Well, okay then, let me just return
true
...Argh! Which is it! ;-)
The text was updated successfully, but these errors were encountered: