Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upOverhaul borrowck error messages and compiler error formatting generally #32756
Conversation
rust-highfive
assigned
nrc
Apr 5, 2016
This comment has been minimized.
This comment has been minimized.
|
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/compiler @rust-lang/tools @mitaa |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm super excited about this! Those snippets are really looking great to me. One point is that in the past we've had mixed experience with lots of words colored differently than the default. In Cargo we recently switched from errors as all-red to just the word "error" in red. In the snippets you've pasted, this just applies to:
Altogether I guess I'm just saying we probably shouldn't go too crazy in terms of colorizing words. I might revert back to today's behavior for the filename + error indicator, but the help messages I'd probably leave pretty similar to the way they are in your snippets. |
This comment has been minimized.
This comment has been minimized.
|
Oh, cc @brson, with whom I've talked about this a plenty. |
This comment has been minimized.
This comment has been minimized.
|
Looks better to me. A big change but it'll probably just take time to adapt.
|
This comment has been minimized.
This comment has been minimized.
|
I noticed the carrots |
This comment has been minimized.
This comment has been minimized.
|
Very nice.
|
This comment has been minimized.
This comment has been minimized.
|
This is very cool. It will essentially make dybuk outdated. |
This comment has been minimized.
This comment has been minimized.
|
On a seperate note, it should be possible to configure the style of the error messages. |
This comment has been minimized.
This comment has been minimized.
I was wondering about this. Do we have one-line errors? Most errors include at least a span, and usually more text. |
This comment has been minimized.
This comment has been minimized.
|
I'm torn about the colors on the filename. I agree that coloring the filename red doesn't look as good as it does in emacs, and I also agree it is less necessary if we remove the redundant filenames. For reference, here is an image comparing what I see in emacs (which applies its own colors) vs what the compiler does today http://imgur.com/GZKJ4Pg. Somehow the emacs one looks nice to me, but the imitation thereof in this PR looks a little plodding. It might be that the column numbers are highlighted differently. At the same time, the emacs column numbers have quite a lot of colors, maybe a bit more than is needed. In any case, @brson's observions, combined with @alexcrichton's suggestion that we minimize color, are making think that perhaps we can find a new balance. That said, the current colors arose out of a lot of experimentation -- it's surprisingly hard to find a combination that looks good and achieves a wide variety of goals:
Of course, you might not agree that the current colors achieve that balance. In any case, I don't consider the current choices optimal, and I definitely think there is room to play around more here. (Does anyone know a good "ANSI editor", btw? It'd be helpful to be able to do mock-ups. I guess I can do it in emacs, maybe. Or maybe just write some custom program using |
This comment has been minimized.
This comment has been minimized.
|
Also, can we rely on unicode being available? Or auto-detect it? I don't want to have too many modes...but using unicode box-drawing characters would be cool. I remember @kmcallister (I think) had a PR on this that never quite landed. |
This comment has been minimized.
This comment has been minimized.
|
For comparison This PR: |
This comment has been minimized.
This comment has been minimized.
|
I would be surprised if you could detect unicode support, @nikomatsakis, as it depends on the font being used (or available fallbacks, I guess.) |
This comment has been minimized.
This comment has been minimized.
|
Why not just have a variable, |
This comment has been minimized.
This comment has been minimized.
|
That's awesome! However, like others already said, why not replacing "~" by "^"? Also, why not setting a different color for error lines? I think that having the filename with its own and unique color would improve the display and help to understand what we're reading more quickly. |
This comment has been minimized.
This comment has been minimized.
I'd much rather make it opt-out. I think the real question is what scheme we want to use for controlling rustc's "skin". We have some compile flags for using colors, which is an obvious precedent, but also doesn't seem that great; this is something that a user would want to decide, and probably uniformly. Maybe we should look for |
This comment has been minimized.
This comment has been minimized.
|
@ticki yeah, I was thinking that maybe the thing to do is to put the error underneath the filename/line-number. In general I think it's probably a win to use more vertical space when formatting errors. As long as emacs can still take me to the next error, I'm happy with that. =) |
This comment has been minimized.
This comment has been minimized.
For reference, here's the pull request: #21406. EDIT: And the follow-up issue: #24387. EDITEDIT: Another relevant issue: #28902. |
This comment has been minimized.
This comment has been minimized.
|
I like the general appearance, here’s some notes:
The box drawing symbols exist since Unicode 1.1. Rust does not support systems with non-utf-8 locales anyway… the only problem is the Windows’ The cmd doesn’t use ANSI and thus must be reliably detected and worked around anyway, so…
Axe-actly! In my experience barely any default and non-trivial colouring works well with solarized, so we should probably either restrict ourselves to the most barebones escape codes and colours like colours 1-to-6 and inverse or allow configuration of them. looks hard to figure out which spans relate to which messages. What happens when these spans overlap?
Using |
This comment has been minimized.
This comment has been minimized.
You're looking at it. The two labels there are attached to the same span. |
This comment has been minimized.
This comment has been minimized.
|
One more inevitable thing is that a lot of docs are going to be showing old errors. Not a showstopper for this PR, mind you, but something that needs to be considered to some degree. |
This comment has been minimized.
This comment has been minimized.
To me it looks like that’s two notes attached to two adjacent spans of length 1. One span on
|
This comment has been minimized.
This comment has been minimized.
I wonder if there's any way to automate the inclusion of errors. |
This comment has been minimized.
This comment has been minimized.
Yeah, that's actually true in this particular case, I didn't look closely enough. In any case, what the PR currently does is to union all |
This comment has been minimized.
This comment has been minimized.
|
So what do people think about using unicode except for when running on windows, since apparently cmd doesn't support unicode? |
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 2, 2016
This comment has been minimized.
This comment has been minimized.
|
|
bors
added a commit
that referenced
this pull request
May 2, 2016
This comment has been minimized.
This comment has been minimized.
|
|
bors
added a commit
that referenced
this pull request
May 3, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 3, 2016
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
May 3, 2016
bors
merged commit 9355a91
into
rust-lang:master
May 3, 2016
This was referenced May 3, 2016
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
deleted the
nikomatsakis:borrowck-snippet
branch
May 3, 2016
nikomatsakis
referenced this pull request
May 3, 2016
Merged
degrade gracefully with empty spans #33369
This comment has been minimized.
This comment has been minimized.
|
I really like the new approach posted by @jonathandturner in #32756 (comment) , particularly the method of highlighting the primary error. Two remaining issues with it, one minor, one major:
|
This comment has been minimized.
This comment has been minimized.
This is really a sticking point. I'm not really sure what's the best fix here. I think that the current format with the
OTOH, I really want to enable "low-tech" editor integration. One thing we've debated about is having a "third mode". For example, perhaps we DO use an environment variable (
in front of the error. This is intended for your editor to match on, basically. (The downside of this is that the message would appear twice, which is a shame.) The reason I've come to favor an env var for this purpose is that one can easily set it in the editor's setup and have it "propagate down" to compilations executed by the editor, but not affect compilations done by hand on the console. But I guess the other question is how easy it will be to adjust editor modes to the new format as it exists today. For example, I opened this PR on the emacs mode rust-lang/rust-mode#154. If we can just get editors to either use JSON or else use the default format, that might be best. |
This comment has been minimized.
This comment has been minimized.
|
I think that this form of integration is hacky. IDEs should prefer JSON. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I absolutely agree that this format is more usable by humans, just not by existing editors. I don't think it's reasonable to require an environment variable for this; error message parsing and handling should work out of the box. Right now, I have no Rust support in vim (because the Vim mode for Rust isn't packaged in Debian), and I regularly use Having an environment variable and command-line option for explicit handling, or for IDEs/editors that want to implement special support for Rust, seems like a good idea. However, I would suggest that the default should be "auto", which would imply "normal" if stderr is a TTY, or "header" if it isn't. @ticki Current generation IDEs with specifically designed support for Rust might, but we can't write off decades of programmer's editors and the conventions they expect. The standard error message format is |
This comment has been minimized.
This comment has been minimized.
It is only a de facto convention, not standard. There’s a bunch of things that do not honour the convention as well. |
This comment has been minimized.
This comment has been minimized.
Yeah, most compilers use that, so it wouldn't make sense to drop it. I simply think that for Rust-specific IDEs, there should be more emphasis on JSON, since it is strictly less ambigious and spec-able |
This comment has been minimized.
This comment has been minimized.
|
@ticki Absolutely agreed; anything doing more than the most basic parsing should use the JSON format. @nagisa Half the world runs smoothly because of de-facto conventions. The default configuration shouldn't break people's preferred editors. Again, we're not talking about changing the default format for terminal use; we're talking about automatically detecting when output goes to a log and adding a line to simplify parsing. @nikomatsakis One other aspect of the "header" format: it needs to not include the |
This comment has been minimized.
This comment has been minimized.
|
Rather than discussing this "header format" on this closed PR, I propose we move the conversation here: http://internals.rust-lang.org/t/editor-compatibility-and-the-new-error-format/3435 I tried to summarize the salient points. |
bors
added a commit
that referenced
this pull request
May 8, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 8, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 8, 2016
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 8, 2016
killercup
referenced this pull request
May 8, 2016
Closed
Clippy vs. RUST_NEW_ERROR_FORMAT=true #907
This comment has been minimized.
This comment has been minimized.
|
.... so.... what is this testing now? |







nikomatsakis commentedApr 5, 2016
•
edited
This is a major overhaul of how the compiler reports errors. The primary goal is to be able to give many spans within the same overall context, such as this:
However, in the process we made a number of other changes:
This PR is not quite ready to land, but we thought it made sense to stop here and get some feedback from people at large. It'd be great if people can check out the branch and play with it. We'd be especially interested in hearing about cases that don't look good with the new formatting (I suspect they exist).
Here is a checklist of some pending work items for this PR. Some of them may be best left for follow-up PRs:
MultiSpan(this should be easy)Moved numerous follow-ups to: #33240
Joint work with @jonathandturner.
Fixes #3533