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 upStyle changes to compiler messages #29989
Conversation
rust-highfive
assigned
pnkfelix
Nov 22, 2015
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
|
@Manishearth A lot of things need to be clarified! Feel free to burn it down :) |
wafflespeanut
reviewed
Nov 22, 2015
| @@ -799,7 +799,7 @@ impl CodeMap { | |||
|
|
|||
| let lo = self.lookup_char_pos_adj(sp.lo); | |||
| let hi = self.lookup_char_pos_adj(sp.hi); | |||
| return (format!("{}:{}:{}: {}:{}", | |||
| return (format!("{}: {}:{} -> {}:{}", | |||
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Nov 22, 2015
Author
Contributor
The space is added only to separate the span from the file name (for visibility).
The colon has been replaced with an arrow, because we already use it to separate the line number from the character number.
This comment has been minimized.
This comment has been minimized.
Manishearth
Nov 23, 2015
Member
I think the first space shouldn't be there. Many editors let you say open foo.rs:1:2 on the command line and will open focused on that line. It's easier to copy-paste if there is no space.
This comment has been minimized.
This comment has been minimized.
nrc
Nov 23, 2015
Member
I would not use -> since we use it for function types/signatures. I'd use to or ... or keep the :
wafflespeanut
reviewed
Nov 22, 2015
| Fatal | Error => "error".fmt(f), | ||
| Warning => "warning".fmt(f), | ||
| Fatal | Error => "\n error".fmt(f), | ||
| Warning => "\n warning".fmt(f), |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Nov 22, 2015
Author
Contributor
I've put this here only for a preview. If we're gonna avoid the file path (in a similar fashion) for the other messages too, then we can put it directly into the function.
But, if we're going for relative paths, then this won't look nice, and this should be reverted back. So, what's the plan?
This comment has been minimized.
This comment has been minimized.
steveklabnik
Nov 22, 2015
Member
I really like the relative paths because printing the full path leaks paths that don't exist, ie, to the buildbot that the stdlib was built on. This is annoying both because it is a nonexistant path, but because it includes "slave", which is really awkward.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Nov 23, 2015
Member
One slight issue with relative paths is that when cargo spits out errors for multiple deps it's confusing which dep is being talked about. Though I'm not sure if this will still be an issue.
This comment has been minimized.
This comment has been minimized.
nrc
Nov 23, 2015
Member
I like absolute paths when building locally - I know I can always copy and paste and it will work - with relative paths I have to be in the right place, which with a complex build system doesn't always happen.
This comment has been minimized.
This comment has been minimized.
Manishearth
Nov 23, 2015
Member
(Also, I think the /slave/foo thing only happens in assertions, not in compiler errors. In compiler errors that only turns up when a Rust PR fails buildbot which is okay)
wafflespeanut
reviewed
Nov 22, 2015
| digits += 1; | ||
| } | ||
|
|
||
| assert!(display_line_strings.len() > 0); |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Nov 22, 2015
Author
Contributor
Since our idea is to drop displaying file paths for the latter part of the span, we'd be reverting the patches made for #11715 and some of its sub-issues. Is that okay?
This comment has been minimized.
This comment has been minimized.
Manishearth
Nov 23, 2015
Member
We'll be preserving the old behavior via a command line flag, so this stays in the old-behavior method?
This comment has been minimized.
This comment has been minimized.
|
Now, a single-line error message looks like, (yeah, it's funny)
... and a multi-line warning looks like,
Thoughts? |
This comment has been minimized.
This comment has been minimized.
|
Oh no. Look at the travis log! |
This comment has been minimized.
This comment has been minimized.
|
That's compiletest not being able to handle the new formatting. We can either add a flag to preserve the old formatting (which we need to do anyway, simple fix) and have compiletest use that, or we can fix up compiletest to handle the new formatting. |
This comment has been minimized.
This comment has been minimized.
|
bikeshed:
|
This comment has been minimized.
This comment has been minimized.
|
@Manishearth not sure how this relates to @wafflespeanut's example above, so I may be misunderstanding, but...
What does an error message with a macro expansion trace look like? |
This comment has been minimized.
This comment has been minimized.
|
The reason I think it should be indented is to visually separate code from error. We already do that with colors, but I think this would be clearer -- easier to see errors when scanning the log |
This comment has been minimized.
This comment has been minimized.
|
If the error is indented, then being not indented would give visual separation (in theory, you'd have to have a big example to check). |
This comment has been minimized.
This comment has been minimized.
|
@nrc Here's macro expansion
|
This comment has been minimized.
This comment has been minimized.
Um, we only have a few lines of code. Others are replaced with the ellipsis anyway, right?
The first line in any compiler message shows the entire span where something bad has occurred. Only the other few lines don't have the line numbers. Should we really need the line numbers for all the lines? |
This comment has been minimized.
This comment has been minimized.
|
For what it’s worth, there is a GNU standard for source locations in diagnostic messages, which some tools (Emacs?) support out of the box for jumping to and highlighting locations:
It extends easily:
Also, re. relative vs. absolute paths, errors could follow the behaviour of Make’s |
bstrie
added
the
T-tools
label
Nov 24, 2015
This comment has been minimized.
This comment has been minimized.
|
Tagging with T-Tools as I figure it's worth having the Tools team meet to discuss this. |
This comment has been minimized.
This comment has been minimized.
|
Personally I feel like rather than have a switch for "legacy error message mode", we should just move forward with nicely-formatted and deliberately-unstable human-readable error messages, with an optional switch to produce machine-readable error messages. That way we can support tools nicely (nicer than the current error messages) while also allowing us to evolve the typical error messages without feeling like everything has to be perfect immediately. For example, I like Elm's use of color in error message to direct the reader's eye (https://www.reddit.com/r/rust/comments/3ti20g/not_rust_specific_compilers_as_assistants_elm_016/), but that's not something that we need to bikeshed immediately. For now just removing the redundant filename to fix #3533 would be a win on its own. |
This comment has been minimized.
This comment has been minimized.
|
@evincarofautumn: GNU paths are very handy. One of the small things that annoys me about Elm's errors is the lack of those paths. They don't need to be repeated constantly like rustc currently does, but it would be a shame to lose them in the interests of going too far towards hiding complexity. I guess with machine-readable errors in the future, it might become easier to make 'beginner' and 'advanced' front-ends for error formatting (that may not be desirable though). |
This comment has been minimized.
This comment has been minimized.
|
Ugh - your right @bstrie, this is not really the place for bikeshedding this stuff. Sorry! |
This comment has been minimized.
This comment has been minimized.
|
@wafflespeanut, I tend to agree with those advocating the GNU style for formatting the file/line/column readout, if only because it's a widely-used precedent and we could spend forever bikeshedding alternatives. For now I think it's still a huge win to just remove the redundant info on every single line and at last put #3533 to bed. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
I'd like to see an example of serious spew after this change. It's hard to judge the true effect of this from tiny snippets. Adding another line to every error with a span will decrease the overall number of errors per screen. |
This comment has been minimized.
This comment has been minimized.
|
I think this is more a @rust-lang/compiler bug than @rust-lang/tools |
brson
added
the
T-compiler
label
Dec 2, 2015
This comment has been minimized.
This comment has been minimized.
|
The error message already splits to multiple lines because the pathname is so long. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, the addition of new lines, whilst a valid concern, is offset by the fact that many of us have to make our terminals super wide to accommodate the long paths. |
ticki
referenced this pull request
Dec 8, 2015
Open
Indicate compilation progress in a form useful to end users #24335
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated Nominating for discussion at compiler team meeting. (Basically, even if I reviewed this patch and were 100% happy with its effects, I would not feel comfortable introducing these changes without first discussing with the rest of the compiler team.) |
rust-highfive
added
the
I-nominated
label
Dec 11, 2015
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix Agreed. Also, (for reference), there were a lot of suggestions at /r/rust. |
This comment has been minimized.
This comment has been minimized.
|
@wafflespeanut could you provide an example with lots of errors please? (as requested by @brson above). |
This comment has been minimized.
This comment has been minimized.
|
I definitely think we should try to follow a standard of some kind for indicating the file/line-number etc :) I was under the impression that we already did, or at least I've seen similar formatting from a number of tools and emacs seems to recognize it "out of the box". I also think we should not be afraid to change the precise formatting of our messages. I consider it unstable and targeting humans, not tools. But I guess no reason to change willy nilly either. |
This comment has been minimized.
This comment has been minimized.
|
@wafflespeanut just so this does not get lost in the shuffle: we need a legacy output flag; it was previously described as "a flag to preserve the old formatting", but it might be easier to think of as an output format that is:
|
This comment has been minimized.
This comment has been minimized.
Yeah, the standard is
Agreed. Though for tools in the long run I think we should provide structured (JSON) output or something. /me idly proposes "spanhandler plugins" |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
Well, there are probably many fixed standards. The one that was cited earlier by @evincarofautumn is this GNU page, which proposes:
Interestingly, we don't seem to do any of those today, and yet emacs correctly highlights regions for me, so it must understand some superset of those formats. Also, that web page is a bit weird, since it seems to indicate that |
This comment has been minimized.
This comment has been minimized.
|
@brson @nrc "spew of errors" ...
(Note that there are some off-by-one errors while displaying the span, which can be fixed. Also, this applies only to errors - I haven't added newline to the help & note) And, I agree that we need the legacy output flag. I'll update this soon :) |
This comment has been minimized.
This comment has been minimized.
|
@wafflespeanut AFAICT this just breaks error listing completely in at least the editors I use. Already type errors are almost useless since the actual type mismatch isn't part of the error message. Maybe the "nicer" multi-line output forms should be restricted to terminal stdout? |
This comment has been minimized.
This comment has been minimized.
|
Most editors can be fed a per-language regex for how to decode more complex data from error messages. |
This comment has been minimized.
This comment has been minimized.
|
@Manishearth how many of those work with multiple lines per error message? |
This comment has been minimized.
This comment has been minimized.
|
No idea. I don't use shortform error listings much. I think here you should just configure your editor to use the legacy output. Editor-friendly output is more often than not human-unfriendly; and one of the core issues this PR was trying to address was that having everything on one line is incredibly ugly and hard for humans to read on split terminals. We should still ensure that things like jump-to-line on a full error listing work on the new system, though. (Since that's easy to get right without impacting readability) |
This comment has been minimized.
This comment has been minimized.
ISTR that I implemented the range output, and specifically did not follow the standards because the thing that we currently implement worked correctly with emacs whereas others I tried did not. |
pnkfelix
added
I-needs-decision
and removed
I-nominated
labels
Jan 7, 2016
nrc
assigned
nrc
and unassigned
pnkfelix
Jan 7, 2016
This comment has been minimized.
This comment has been minimized.
|
I think I am r+ on the intention here but r- on the specific details of this PR. I think we should evolve it more before we land. What I think I would really like to see (some of which is in this PR):
That said, I find the exact output here to have some shortcomings and be not quite ready to land. For example, it seems somewhat inconsistent to have error messages begin on a new line and TL;DR we should iterate on this more, but it's going in a good direction -- and we should take care to ensure that editors continue to work well. :) |
This comment has been minimized.
This comment has been minimized.
|
We discussed this at the compiler meeting, conclusions:
|
nrc
closed this
Jan 7, 2016
wafflespeanut
deleted the
wafflespeanut:multiline
branch
Jan 8, 2016
This comment has been minimized.
This comment has been minimized.
|
Awesome! Thanks :) |
wafflespeanut commentedNov 22, 2015
fixes #3533