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

Possible Rust error format updates and IDE support #146

Open
jonathandturner opened this Issue Jun 9, 2016 · 11 comments

Comments

Projects
None yet
5 participants
@jonathandturner
Copy link

jonathandturner commented Jun 9, 2016

Hi all,

Sorry for using the issue as a message box, but I wanted to let you know that we're working on an RFC that updates the error messages output format: rust-lang/rfcs#1644 If RustyCode is currently parsing the output from the compiler may be impacted.

That said, we're also talking about standardizing a JSON format to help give IDEs more information from compiler output.

Would love to chat about the VSCode support (which I use pretty much everyday :) ), and get your thoughts.

@saviorisdead

This comment has been minimized.

Copy link
Owner

saviorisdead commented Jun 26, 2016

Hello!
Idea of standardizing a JSON format of errors sounds really good to me, because now we rely on some not so robust plain text parsing and changes in error format will of course have impact on RustyCode.

As I see it, some simple JSON would be more convenient, for example something like this:

{
    "lineFrom": 0,
    "lineTo": 10,
    "characterFrom": 0,
    "characterTo": 6,
    "severity": "error" | "warning",
    "message": "",
}

But maybe other guys have other ideas.

@draivin

This comment has been minimized.

Copy link
Contributor

draivin commented Jun 26, 2016

Rustc does have support for emitting json logs, and it is really easy to use, my only issue with it is that we can't get the usual log along with it, so our output window won't show the same stuff it would if we were building on the terminal.

@wycats

This comment has been minimized.

Copy link

wycats commented Jul 14, 2016

@jonathandturner maybe we could include the "text" version of the message inside of the JSON?

@jonathandturner

This comment has been minimized.

Copy link
Author

jonathandturner commented Jul 14, 2016

@wycats - thanks for the reminder! I started a thread on the Rust internals list about stabilizing the json format, which includes adding a field for the fully rendered compiler message:

https://internals.rust-lang.org/t/stabilizing-json-compiler-message-output/3691

@trixnz

This comment has been minimized.

Copy link
Contributor

trixnz commented Jul 28, 2016

I took a look at implementing this. I don't think it will be difficult at all, but there are a few potential annoyances:

To implement this on all cargo tasks, we could use the RUSTFLAGS env var, although this causes issues for people like myself who prefer to do the building and running from a terminal. A change to RUSTFLAGS will trigger a rebuild when you build from the terminal as one will expect the human readable compiler output. Likewise, having built from the terminal, VSCode will then have to rebuild when it builds/lints again.

The other option is to pass in the -Z unstable-options --error-format=json args ourselves, but that is a problem for the build/run tasks as they don't support custom rustc arguments.

A hybrid approach might be desirable where linters (cargo check/cargo clippy/etc) take the arguments on the command line, but build/run/bench/test take the environment variable. This would allow people who use the IDE for linting/formatting to be unimpeded by constant rebuilds as they switch between the terminal and IDE.

@jonathandturner Do you have any ideas?

@jonathandturner

This comment has been minimized.

Copy link
Author

jonathandturner commented Jul 29, 2016

If you put the flag in RUSTFLAGS, you're only doing it the one time, right? If so, wouldn't that be a single rebuild?

@trixnz

This comment has been minimized.

Copy link
Contributor

trixnz commented Jul 29, 2016

From the IDE's point of view, yes. If, however, you decide to build it from a terminal then RUSTFLAGS is empty which triggers a rebuild as it is stored in the compilation settings somewhere. Likewise, if you then return to the IDE, you'll get a rebuild again as RUSTFLAGS has changed since the last build.

I understand the reasoning behind it as you definitely want a rebuild if you change optimization settings or what have you, but the error output shouldn't (in my opinion) have such an impact.

@trixnz

This comment has been minimized.

Copy link
Contributor

trixnz commented Jul 29, 2016

I've created a feature request at rust-lang/rfcs#1693 for an environment variable that only affects the error format. Suggest we continue discussions there.

@trixnz

This comment has been minimized.

Copy link
Contributor

trixnz commented Aug 2, 2016

#159 adds support for JSON errors and I'll look into adding support for the new error format during the week 👍

@jonathandturner

This comment has been minimized.

Copy link
Author

jonathandturner commented Aug 8, 2016

Sounds like this is in-progress, but I wanted to give you all a heads up that we're currently discussing turning the new error format on: rust-lang/rust#35401

If there are any issues, please let us know. Making the switch will only affect nightly, and there will still be some weeks before this goes into stable, which gives us some time to make changes if need be.

@trixnz

This comment has been minimized.

Copy link
Contributor

trixnz commented Aug 8, 2016

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.