-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Turn on new errors and json mode #35401
Conversation
👍 |
all: $(DOTEST) | ||
|
||
dotest: | ||
# check that we don't ICE on unicode input, issue #11178 |
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.
How come this test was removed? Seems like some pieces may still be relevant?
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.
It's redundant with the UI unicode test (which tests the same thing in a much better way)
That said, there's something odd with how unicode is handled by both new and old mode, so that's worth exploring, though that exploration shouldn't block this but rather be something on our todo list
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.
Ok, so long as it's still being tested sounds good to me
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.
Actually, I'm just going to file "write more unicode tests" and put it on myself. We need more than 1 or 2 anyways, which is all we really had before.
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.
Put #35442 on myself to add a few more tests in the future.
|
ce79a22
to
c350ec7
Compare
@jonathandturner I'm in favor of throwing the switch, but I do have a question -- I haven't looked at your new "errors" crate, how hard do you think it would be to avoid flushing output in the middle of a message (or at least in the middle of the two line header?). I think that would make emacs integration much nicer and it seems like it may help VI too, though that's more speculative. |
@nikomatsakis - is there a way to test the current version to see how much is buffering? Here's how I emit to the destination: for line in rendered_buffer {
for part in line {
dst.apply_style(lvl.clone(), part.style)?;
write!(dst, "{}", part.text)?;
dst.reset_attrs()?;
}
write!(dst, "\n")?;
} ...so I'm not flushing manually. I don't know if |
That unfortunately won't buffer an entire error because the default behavior is to only buffer as much that's seen until a newline, so that'd flush after each line. Also note that it's only possible to line-buffer on Unix because on Windows the current way we implement color is as a state of the console, not a property of the output stream. All that's basically to say though that it's nontrivial and probably shouldn't happen in this PR at any rate, and otherwise we can track it over at #32486. I think it's also ok to move forward as @nrc has been in favor on other threads (I believe) and @vadimcn's main concern was proving out editor support which @jonathandturner indicates is well underway. As a result, I'll... |
Thanks! Where can I see examples of this new format? We already have a test for it, but it was added around this discussion. Has anything changed since then? And just some general info about how IntelliJ Rust consumes compiler/cargo output:
|
@matklad - You can see what the look like in the RFC. You can also play with them, if you have a build of the nightly compiler, by running the compiler with RUST_NEW_ERROR_FORMAT=true.
You can also set it in the environment. The new format is very similar to the last time we discussed it, though with minor changes like the column separator |
Sorry, I showed my approval with a GitHub emoji, it seems that is not reliable as an indicator. Anyway, I strongly approve! |
I remembered later that I had come to the conclusion that the idea of buffering was kind of too much of a hack, useful as it may be, and it'd probably be better to pursue trying to make JSON convenient. |
⌛ Testing commit c350ec7 with merge beb9d61... |
💔 Test failed - auto-win-msvc-64-cargotest |
From the point of view of RustDT, the end goal is to parse the JSON output itself, as that allows much better control of how to understand the error model and display it (particularly display it in a graphical way, in the editor itself). When I next work on this, I'd rather start supporting the JSON output straight away, not much point spending time working on parsing this next textual non-JSON output. If RustDT doesn't get there before the new output goes live, there will still be an option to display the old format, right? |
This PR removes that code, actually. |
Agreed, that sounds like a good goal. The hope is that by enabling JSON with this PR, and giving plugin authors ~8 weeks to update to it, that there will be enough time to update before people see it in stable. |
I think a big problem for JSON is the fact that cargo can't emit JSON output. That is, if I were going to integrate cargo support into emacs, I would want to parse the full cargo output. But I guess one could get started by passing RUSTFLAGS to cargo and then dealing with the mix of JSON etc that will come out. |
@nikomatsakis - I was talking to @alexcrichton about the JSON output, and he says he's very much for cargo emitting JSON once it is stabilized. I'm going to meet with him today to see if we can switch things over. |
@bors r+ p=1 |
📌 Commit 9b510ba has been approved by |
Added a reference to #34826 which this closes |
⌛ Testing commit 9b510ba with merge 576f766... |
…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
💔 Test failed - auto-linux-64-debug-opt |
@bors retry |
@bors force |
@bors force (at Niko's request, though I don't think bors likes me anymore) |
This PR is a big-switch, but on a well-worn path:
New errors by default
The RFC for new errors landed 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 and expect more to follow.
We also have an issue on old skool 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.
JSON mode enabled
We've hashed out 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