-
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
infer: remove distinction for "simple type errors" #33367
Conversation
Previously, the second "expected X, found Y" in parens was omitted for simple errors because it added no information. Now that this is always omitted, there is no need for a distinction anymore. This change restores the "expected, found" message for such errors. Fixes: rust-lang#33366
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
if !is_simple_error { | ||
err = err.note_expected_found(&"type", &expected, &found); | ||
} | ||
err = err.note_expected_found(&"type", &expected, &found); | ||
|
||
err = err.span_label(trace.origin.span(), &terr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm surprised we're not seeing the span_label actually, even in old mode output.
@birkenfeld so actually I see the problem now. I think we give special treatment to labels attached to the primary span, which we ignore (for...reasonably good reasons). After some discussion with @jonathandturner I think the easiest fix is to make the // this would replace line 561
if check_old_skool() {
err.note(&format("{}", terr));
} else {
err.span_label(trace.origin.span(), &terr);
} Basically the problem here is that we don't have QUITE enough info to know whether to convert the "span label" into a note or not. We could augment the |
Right, if you are confident that the backwards compatibility mode will be removed soon, I agree that this can be ignored. While at it, are you aware that the new error format breaks default editor/IDE "go to error" mechanics (because the file/line is not at BOL, but after a |
Indeed, this is the primary reason that the new format is not yet the default. I plan to submit a PR for emacs rust-mode in a bit, at least (I have a local fix, or at least a mostly fix). We have to work with other editors. (Which editor are you using?) |
I didn't meant to suggest we should ignore it, I want the "default output" to be good to be sure. I was just suggesting we might fix this a different way. Basically, in old mode, we can move the content of the "span_label" call into the main message (this isn't quite what I wrote before, which suggested we should add a new note, but now I think that's probably wrong, or at least not what we did before). |
I'm also using Emacs (and used to customizing it), so personally I'm fine, just wanted to make sure you're aware.
Sure. Should I try to make this change here, or do you want to fix it while you work on the new errors anyway? |
@birkenfeld yeah should be fair game if there are parts of the old-style errors that got worse with the recent PR. I was poking around a bit. If we started with this PR, but changed your: if !is_simple_error { to: if !is_simple_error || check_old_skool() { And then plumb through check_old_skool. I think that gets the old behavior you want to turn back on, while leaving it off in the new style errors where we use labels. |
closing in favor of #33367 |
Previously, the second "expected X, found Y" in parens was omitted for simple errors because it added no information.
Now that this is always omitted, there is no need for a distinction anymore. This change restores the "expected, found" message for such errors.
Fixes: #33366