-
Notifications
You must be signed in to change notification settings - Fork 347
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
Avoid duplicating error message in title #2015
Conversation
Thanks for the PR! This was to an extend deliberate since I figured the title might be easier to find/read than a message attached to the span. I take your point about redundancy and long messages though. @saethlin I wonder what you think about this, given you have been working on SB error messages recently? |
@@ -215,7 +215,7 @@ pub fn report_error<'tcx, 'mir>( | |||
report_msg( | |||
*ecx.tcx, | |||
DiagLevel::Error, | |||
&if let Some(title) = title { format!("{}: {}", title, msg) } else { msg.clone() }, |
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.
If the goal is to avoid redundancy, we should also do something about the title == None
case here.
The only errors that can trigger this are MultipleSymbolDefinitions { .. } | SymbolShimClashing { .. }
... so maybe we should just come up with a title for them? Any suggestions?
I think this PR is moving in a good direction. IMO the biggest problem with the SB errors is that they emit a lot of text, and most of it doesn't help the user fix the problem that's being reported. At the moment it basically emits the same text twice, then suggests a user may want to ignore the error or perhaps consult a piece of reference material. I think for this PR, it would be really nice if we could make better use of the top line. I don't know about other users, but my eyes jump to text in the span. I suspect I've been trained by rustc errors that all of the useful stuff is there. What if SB errors looked like this:
In this sketch, I'm focusing on moving boilerplate out of the middle of the output. I think we can rely on new users putting |
We use that
The primary goal of that text is to make the user even understand what the problem is. That's already hard enough. I haven't even started thinking about automatically helping people to fix the problem, that seems near impossible.^^ I think your proposed message removes too much context. People pick up Miri for various reasons, I would not expect that they even have a good understanding of Undefined Behavior, let alone have heard about Stacked Borrows. |
The failing test suite also shows that there is another reason why we have the error in the title: we need that for compile-fail tests. So I think if we want to do this, we first need to switch those to ui tests. That is something that has been loosely on my radar for a bit, but never rose to the top of my list. |
I agree that we should be helping people understand what the problem is. I'm just determined to pull this off with the error messages, not a URL to reference material. Perhaps I'm still suffering the optimism of youth, but I have quite a few more PRs to go yet. |
I think including URLs to external material is a great way to connect the little information we can provide here, to the greater context. I view this as akin to rustc's But this is steering rather off-topic for this PR. :D The question is whether we want to stop repeating ourselves in the error message. I agree redundancy is a waste of space. Then the question is which of the repeated messages to remove, and indeed the one in the title probably makes more sense as Rust often has the detailed info on the span (though I have also seen people argue that we should keep the "short" error output, which only prints the titles and not the span-labels, useful). I think we should always have a rather general title then (so, turn |
So, this is blocked on #2027. |
☔ The latest upstream changes (presumably #1971) made this pull request unmergeable. Please resolve the merge conflicts. |
#2027 has landed, so we can now match against notes attached to the span, not just the top-level errors. (And #2167 will make this work the way it should.) However, I am not sure if making the error text just 'Undefined Behavior' is truly what we want. Consider this error:
IMO a good way to avoid redundancy would be something like
Basically, the error title should probably still contain something slightly more specific than just 'Undefined Behavior'. This will require a change on the rustc side to enable getting both the 'title' and 'text' of an error message (or so). @ibraheemdev is that something that you would still like to work on? |
@ibraheemdev I haven't heard from you in a while, so I am going to close this PR. I'll open an issue to track reducing our redundancy here. If you want to pick this up some day, just let us know. :) However, anyone else reading this should also feel free to pick this up if they want to. |
Tracking this in #2200 |
@RalfJung sorry, I don't really have the motivation to work on this. Opened because it seemed like a quick fix :) |
That's totally fair; thanks for the inspiration! |
Error output currently repeats the full error message in the title as well as the span message:
This gets noisy because messages are often quite long. This PR changes the title to a constant
Undefined Behavior
: