Skip to content
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

Merged
merged 3 commits into from Aug 10, 2016

Conversation

sophiajt
Copy link
Contributor

@sophiajt sophiajt commented Aug 5, 2016

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

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

@sophiajt sophiajt changed the title Turn on new errors, json mode. Remove duplicate unicode test Turn on new errors and json mode Aug 5, 2016
@GuillaumeGomez
Copy link
Member

👍

all: $(DOTEST)

dotest:
# check that we don't ICE on unicode input, issue #11178
Copy link
Member

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?

Copy link
Contributor Author

@sophiajt sophiajt Aug 7, 2016

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@alexcrichton
Copy link
Member

I'm in favor! In terms of a timeline this will move into Beta on 2016-08-18, two weeks from the past Friday. That gives around 8 weeks to revert this decision (if we need to), but also just more time to detect bugs.

cc @nrc and @vadimcn specifically as well

@arielb1
Copy link
Contributor

arielb1 commented Aug 7, 2016

error[E0433]: failed to resolve. Could not find `FormatMode` in `errors::snippet`

    --> src/libsyntax/parse/lexer/mod.rs:1690:49

     |

1690 |                                                 errors::snippet::FormatMode::EnvironmentSelected);

     |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@nikomatsakis
Copy link
Contributor

@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
Copy link
Contributor

r=me, do we want to wait to hear from anyone else? @nrc / @vadimcn ?

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 8, 2016

@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 write! flushes on carriage return, though.

@alexcrichton
Copy link
Member

@jonathandturner

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...

@bors: r=nikomatsakis c350ec7

@matklad
Copy link
Member

matklad commented Aug 8, 2016

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:

  • at the moment we show compiler's text output to the user and hyperlink error messages to the locations in the file (the user can cycle through this error much like `C-x ``)
  • we don't show compiler errors directly in the editor, so we don't have a plan to use JSON format at the moment.

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 8, 2016

@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.

RUST_NEW_ERROR_FORMAT=true rustc <my file>

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|> now becoming |.

@nrc
Copy link
Member

nrc commented Aug 8, 2016

Sorry, I showed my approval with a GitHub emoji, it seems that is not reliable as an indicator. Anyway, I strongly approve!

@nikomatsakis
Copy link
Contributor

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.

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.

@bors
Copy link
Contributor

bors commented Aug 9, 2016

⌛ Testing commit c350ec7 with merge beb9d61...

@bors
Copy link
Contributor

bors commented Aug 9, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@bruno-medeiros
Copy link

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?

@nikomatsakis
Copy link
Contributor

@bruno-medeiros

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.

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 9, 2016

I'd rather start supporting the JSON output straight away, not much point spending time working on parsing this next textual non-JSON output.

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.

@nikomatsakis
Copy link
Contributor

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.

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 9, 2016

@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.

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 9, 2016

@bors r+ p=1

@bors
Copy link
Contributor

bors commented Aug 9, 2016

📌 Commit 9b510ba has been approved by jonathandturner

@alexcrichton
Copy link
Member

Added a reference to #34826 which this closes

@bors
Copy link
Contributor

bors commented Aug 9, 2016

⌛ Testing commit 9b510ba with merge 576f766...

bors added a commit that referenced this pull request Aug 9, 2016
…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
@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label Aug 9, 2016
@bors
Copy link
Contributor

bors commented Aug 9, 2016

💔 Test failed - auto-linux-64-debug-opt

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 9, 2016

@bors retry

@sophiajt
Copy link
Contributor Author

sophiajt commented Aug 9, 2016

@bors force

@sophiajt
Copy link
Contributor Author

@bors force

(at Niko's request, though I don't think bors likes me anymore)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for enabling new error format by default
10 participants