-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Default and expanded errors for rustc #1644
Conversation
…xpanded-rustc-errors.md
|
||
There are a few unresolved questions: | ||
* Editors that rely on pattern-matching the compiler output will need to be updated. It's an open question how best to transition to using the new errors. There is on-going discussion of standardizing the JSON output, which could also be used. | ||
* Can additional error notes be shown without the "rainbow problem" where too many colors and too much boldness cause errors to beocome less readable? |
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.
"beocome" -> "become"
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.
I am sure this is a subjective problem. Some people prefer the colorful approach, others not so much, so I think configurability is the key here.
@petrochenkov - thanks! That's actually a really cool analysis. It's totally natural to skip around and only read the parts you want to read. I don't talk about it much in this RFC, but I did a quick survey of how small number of expert Rust developers used the current error system. Many of them just looked at the line number (and possibly the start of the error message) and ignored the rest. They trusted their ability to debug with just the location in mind. Being able to be visually parsed as you described is definitely an improvement and to have that much coverage in a few seconds is very promising. Thanks again. |
I feel like there are two orthogonal RFCs here. We should be able to discuss the new error formatting independently of whether explain should be redesigned. |
I agree with @petrochenkov. A lot of it is not relevant at least 90% of the time, but it may be so for new beginners, so having different log-level-esque errors would be very cool. |
|
||
# Alternatives | ||
|
||
Rather than using the proposed error format format, we could only provide the verbose --explain style that is proposed in this RFC. Famous programmers like [John Carmack](https://twitter.com/ID_AA_Carmack/status/735197548034412546) have praised the Elm error format. |
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.
dybuk is an implementation of something like this.
@bstrie - possibly, though this lays out what should be default as well (vs say just making the Elm-style the only error output) |
I'm pretty excited to see this move forward, I've been using these errors messages on nightly and they're fantastic compared to the old system, and I can't wait to basically just get more of them. I also really like the idea of One part about removing the error code of My only other thought is that on the removal of "error: aborting due to 2 previous errors" I actually really like seeing the total number of errors that were emitted sometimes. If you do some invasive refactoring and fix everywhere you remembered, this gives a great "progress bar" of how far you have left to go. Maybe that cold be folded into some message elsewhere though? I do agree that the dedicated "error: " line is a bit overkill so I don't really have a preference as to where it shows up so long as it's at the end. |
Piggybacking on @alexcrichton's point, I know I've definitely appreciated the searchable error codes before. It makes it a lot easier to find explanations or people with similar situations, and a lot easier to help other people (they can say "I got this error code" and you have a solid sense of what went wrong, very quickly and succinctly). |
@alexcrichton @AndrewBrinker - Definitely agree that keeping it google-able is a good design feature. Rather than using the --explain EXXX pattern, we could just have the error code be part of the error message. Maybe something like: (and we could use a similar header for the --explain) |
I think just keeping the codes, without having them be particularly important to explain, makes a lot of sense. |
(Oh, and I see no reason we can't also tell you the total number of errors while we let you know about |
@bstrie Do you object to the idea of having For example, @jonathandturner and I spent a while debating whether |
@jonathandturner that looks really good to me! We could maybe toy around with other concepts like:
but that's all in the weeds of bike shedding :). My basic point was that we probably shouldn't jettison error codes even if @nikomatsakis yeah I also agree it should be trivial to keep the number of errors while we also explain |
Can we please get these as text? I don't know what's being proposed because the RFC only uses images, and images don't read with screen readers. Will this make errors shorter? I have to scroll the console somewhat often even with 4 or 5 errors. I'd love a nice one or two line output format, but that's probably not what this is. |
@camlorn I will transcribe them for you, two seconds. |
@camlorn The first image is the old error format, where the path is written in the start of every line. The second image is the new format:
The third example describes the long form:
The fourth image is the same as the first one. The 6th image is the same as the first one, but with the header (i.e., the error) highlighted. The 7th is the same image again with the line numbers highlighted. The 8th is the same image again with the code span highlighted. The 9th image is:
The 10th image is the same as the third one. The 11th example is another example of the new format. The last image is Elm's format:
That's all. |
Interesting. There has also been a discussion around a so-called "traditional" format which would (I think) be something highly condensed of the form
and maybe even no additional detail? This would be useful for older On Wed, Jun 08, 2016 at 12:14:45PM -0700, Austin Hicks wrote:
|
I wonder what we can do for people like @camlorn with respect to the error format. @camlorn, what would be your ideal error format? |
thanks for the transcription. As for what we can do generally? Convince Microsoft to let me set the font in the console even smaller. I don't need readable... More seriously... This is an opinion. I'm kind of unique in a lot of ways, not least that I'm one of the few blind people who considers C++ easy. My considerations may not be the considerations of a new blind programmer. Firstly, we don't need Prefixing with The underlines to show where the error is are useless completely. I don't think there's a particularly good solution unless we have a character which will be always reserved. If we did, we could surround the error with it in the same manner that you use parens. As it stands, I'd like to murder the underlines in the most painful way possible and not only for Rust. Surrounding the error's source with something might actually be helpful. I've never quite used the information on borrow scopes. I don't know why. I think that part of it is that reading code in the terminal is inconvenient. I also find that my C++ experience puts me in a good place to reason about lifetimes. Showing the surrounding code is not helpful. If I want to see the surrounding code, I'll use go to line in my editor. I think this one is a fundamental difference between blind and sighted people. There is no way for me to glance at anything, so the cost of reading the code in the terminal and then reading the code in the editor is about twice that of just using the editor. If I have to scroll to see it, it's more. If we can find a way to emphasize the error, showing the code for the error might be useful. If I had to make a suggestion, provide the line numbers of the borrow regions, possibly with the text of the line. This might be If we assume that this is a hypothetical terse error mode that you explicitly enable with an environment variable, you could have a switch to explicitly disable it. In that case, if I need the information in the expanded version, I can still get it. Sorry I can't speak more definitely. I started a large project in Rust, but the larger project in C++ took priority for now. This means that I don't have enough experience to have a workflow that's a procedure as such. With the C++ compiler, I could document exactly what I press because it's always the same. With Rust, it's not quite to the level of mechanical procedure yet. |
I like the direction of this RFC generally.
It's not clear to me what the fate of error codes is here. My impression is that you are proposing to remove them, but your images contain the current
John Carmack's fame doesn't really have any bearing on the validity of the proposal. Also, I don't think RFCs should be giving props to other contributors in the summary. When creating the RFC process we made an explicit decision not to include author information, to avoid making RFC authorship itself an incentive (I think). If authorship is something that should be included in RFCs then the process itself should be modified to include that metadata, including crediting the actual author, not just their collaborators. If giving credit in the RFC text is something we want to encourage, then I don't know that the summary is the place for it. The summary is for summarizing the content of the RFC. |
At the very least we should have a fully working json error output, which one could pass through an arbitrary filter of the form |
@camlorn @nagisa We should have a |
I think that it would be helpful for newbies to spend an entire sentence to introduce
It would be great to have an |
Be changed to notify users of this ability: | ||
|
||
``` | ||
note: compile failed due to 2 errors. You can compile again with `--explain errors` for more information |
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.
to clarify, this should only happen if in fact there is more information to show?
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.
Right, with the assumption that in the fullness of time, we have --explain errors cover most, if not all, errors.
re:lack of experience with the templated format, are you specifically referring to the style of the text? In this RFC, we introduce only using the user's code rather than writing our own examples. We already have a fair bit of experience writing --explain text. It's true, though, that we haven't implemented this version, so I think it'd be natural to also keep it behind a flag for a cycle, like @alexcrichton suggested. I can see it maturing at a different rate than the new default errors, so we may decide one or the other needs longer bake time and opting to stabilize one first then the other. You're right, though, it will need some iteration on the |
I was referring to the whole thing of templated explains. AIUI, we haven't implemented any version, or have I missed something? I thought the one cycle behind a flag was with the latest version of the extended errors, rather than extended explain, which presumably would need to be behind a flag or something until it stabilised (for some definition). The tone seems like something that can be evolved separately from the technical components, and it feels like the next RFC will deal with that? |
@nrc - right, I'm just pointing out that we went a little out of order with the revised default errors in that we had it behind a flag before the RFC rather than the other way around. :) Yeah, the expanded ones can be behind a flag. And yes, there will be a follow-up RFC on the tone. I mention it in this RFC in the last line of the summary. |
🔔 This RFC is now entering its final comment period 🔔 My own personal opinion is that I'm super excited to see this in the compiler and the new error format is great. Having any functionality behind a flag for at least a cycle makes me comfortable in terms of stability, and this is also an area where the specifics I at least believe are relatively loose as tools would primarily desire a JSON-like interface rather than parse the current format (which is in the works). |
Just to follow-up here, since nrc and I were chatting a bit offline. Basically, because of the different levels of maturity of the default and the extended errors, each will be behind a separate flag. Default will align with this rfc, stay behind flag for a cycle, then move to being on by default. Extended errors will finish experimentation, get a follow-up rfc with implementation details, and this will kick off its final cycle in moving out from under flag. |
@jonathandturner sounds good to me, could you ensure that the text of the RFC reflects that as well? |
@alexcrichton - updated! |
I'm happy with this, though I think the I agree with @nrc that in hindsight it would have been preferable for this RFC to be just about the new error format, and not deal with |
This RFC only specifies 1 feature name, but there are two stabilization cycles here, one for the new errors and one for the new explanations. Can a second feature be added? |
Can this RFC address the matter of editors parsing the new text? What's the story for rust-mode specifically? Is this parseable with a regex? The |
@brson - I'd be happy to explore deprecating --explain. Since we're already going to have another RFC cycle to move the expanded errors along, perhaps we can explore replacing --explain there? Not sure what you mean by "This RFC only specifies 1 feature name". Default errors and expanded errors are both explained here. Maybe I missed what you meant? I've reached out to IDE authors, and they're aware of the change. Some are talking about doing JSON support, some only have minimal support for errors and don't parse, and we're working with those who are parsing the text and need to update their parser (vim specifically). I think this is okay to be offline with those authors since it'll be different for different editors. The regex details here are more specific to the regex the editors use. There are updated techniques, eg @nikomatsakis has updated his emacs install to support the newer errors, so the knowledge there is growing. Before we turn it on by default, it'd be good to at least have editors moving to support it so that the support can be there when it's turned on in a stable release. |
Yes. Please make it an unresolved question here.
This line names a single feature, "default_and_expanded_errors_for_rustc". Presumably that one will apply to the new error format, and be attached to its tracking issue. What name will be attached to the tracking issue for enhanced
I don't think this addresses the concern that a single regex can pull out the error information from the text. In this example:
The word 'error' is one one line, and the file name and number are on another. It's not obvious to me that this can be reliably parsed as a single regex, which I suspect (bot don't know), is a requirement for less capable editors. |
"The word 'error' is one one line, and the file name and number are on another. It's not obvious to me that this can be reliably parsed as a single regex, which I suspect (bot don't know), is a requirement for less capable editors." <- this is why we are reaching out to the authors of those editors. We're also looking at things we can do on our end, like better buffering of the error. |
"What name will be attached to the tracking issue for enhanced --explain?" Does this need to be named in this RFC? I'm confused. |
The tools team got a chance to discuss this RFC the other day, and the decision was to merge! There were some key points brought up while discussing this that the tools team felt needed to be addressed before stabilization, but implementation on an unstable basis seemed fine. Specifically, we were thinking:
In the meantime, we'll continue to have an opt-in to using the new error format (currently an environment variable) which will allow users to test out the errors, editors to start to catch up, etc. Thanks again for all the discussion on this RFC everyone, and thanks @jonathandturner for pushing on this! Getting lots of people happy with a stylistic decision is no small feat! |
Tracking issue for default errors: rust-lang/rust#34826 Oh and one last point --
Ah as part of |
…jonathandturner Turn on new errors and json mode This PR is a big-switch, but on a well-worn path: * Turns on new errors by default (and removes old skool) * Moves json output from behind a flag The RFC for new errors [landed](rust-lang/rfcs#1644) and as part of that we wanted some bake time. It's now had a few weeks + all the time leading up to the RFC of people banging on it. We've also had [editors updating to the new format](https://github.com/saviorisdead/RustyCode/pull/159) and expect more to follow. We also have an [issue on old skool](#35330) that needs to be fixed as more errors are switched to the new style, but it seems silly to fix old skool errors when we fully intend to throw the switch in the near future. This makes it lean towards "why not just throw the switch now, rather than waiting a couple more weeks?" I only know of vim that wanted to try to parse the new format but were not sure how, and I think we can reach out to them and work out something in the 8 weeks before this would appear in a stable release. We've [hashed out](#35330) stabilizing JSON output, and it seems like people are relatively happy making what we have v1 and then likely adding to it in the future. The idea is that we'd maintain backward compatibility and just add new fields as needed. We'll also work on a separate output format that'd be better suited for interactive tools like IDES (since JSON message can get a little long depending on the error). This PR stabilizes JSON mode, allowing its use without `-Z unstable-options` Combined, this gives editors two ways to support errors going forward: parsing the new error format or using the JSON mode. By moving JSON to stable, we can also add support to Cargo, which plugin authors tell us does help simplify their support story. r? @nikomatsakis cc @rust-lang/tools Closes #34826
Proposed update to the Rust compiler error output format.
rendered (last updated: 6/27/2016 8:30am)