Skip to content

option to reverse the order of compile error messages #32650

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

Closed
fdietze opened this issue Mar 31, 2016 · 14 comments
Closed

option to reverse the order of compile error messages #32650

fdietze opened this issue Mar 31, 2016 · 14 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fdietze
Copy link

fdietze commented Mar 31, 2016

I just had this idea while scrolling upwards in my terminal to find the first compile error:
It would be nice to have the option to print the compile errors in reverse order, then one sees the most relevant error at a first glance. This would be especially helpful when using cargo-watch.

(I'm posting this here, because this is not a language RFC, was that correct?)

@brson
Copy link
Contributor

brson commented Mar 31, 2016

That could be a nice simple solution to this problem. We've also discussed outputing to a pager of some kind to help you scroll through the errors.

@steveklabnik steveklabnik added the A-frontend Area: Compiler frontend (errors, parsing and HIR) label Apr 1, 2016
@brson brson added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. I-nominated labels Aug 10, 2016
@brson
Copy link
Contributor

brson commented Aug 10, 2016

Nominating for discussion. @rust-lang/compiler @jonathandturner @GuillaumeGomez this is conceptually quite simple to do. Do we want to write up the tasks and ask for contributions?

@nrc
Copy link
Member

nrc commented Aug 10, 2016

cc @rust-lang/tools too

I'm a little wary about this, although it is small in itself, I can imagine we then end up adding paging options or other error display stuff to the compiler and end up with a pile of command line options, etc.

I'd prefer that the compiler just offers a single best-effort error message presentation style, and if you want something else, you run the compiler through an external tool (command-line or otherwise) that takes JSON errors as input and outputs errors in whatever format you like.

@vadimcn
Copy link
Contributor

vadimcn commented Aug 10, 2016

My feelings on this are close to @nrc's.
However, as a practical matter:

  • Does Linux have any standard tools that can parse and page JSON record-by-record?
  • Even the above exists, you still need a tool that will take JSON output and convert it into human-readable format.

Perhaps we could settle on adding rustc parameter to suppress errors beyond the first N?

@telotortium
Copy link
Contributor

You could do what Git does and automatically send output longer than the number of rows on the terminal to $PAGER.

@sophiajt
Copy link
Contributor

To pile on a "me too" to @nrc and @vadimcn - it'd be much better to use a second tool to turn the output from the compiler into what you want. There some precedence, like tools like dybuk do their own parsing and recreating the errors. I can imagine a tool that reads in the errors and then replays them backward as another one.

@sophiajt
Copy link
Contributor

Worth mentioning, too, that the errors are streamed rather than buffered. That's to give feedback sooner rather than forcing the programmer to wait.

As we add more error recovery to the compiler, it will likely mean longer wait times before you see an error if you buffer until the compile finishes because the compiler will be able to recover and go for longer in the presence of errors.

@nikomatsakis
Copy link
Contributor

I'm much more in favor of using a pager; but I guess that doesn't help with cargo watch. Still, cargo watch could capture the output and reverse the order itself, which seems better. (I'll note that we added the "easy presentation" info to JSON that I've been talking about, this would be a great use-case for it. =)

@nagisa
Copy link
Member

nagisa commented Aug 11, 2016

I’m very against using any sort of pager. Any proper terminal emulator is already as functional or more functional than your average pager, why cripple that? Perhaps a simpler solution is to not use rustc in getty?

@nikomatsakis
Copy link
Contributor

@nagisa presumably you could control it in whatever way e.g. git lets you control it. But a pager has a lot of advantages. For example, you see the first error... first. If you have to page-up as in a "proper" terminal emulator, that's annoying, because you can easily page up into older errors. If your terminal emulator is so fancy as to somehow jump to the top of the current rustc run, that's great, but many people are just using Terminal.app or whatever.

@nikomatsakis
Copy link
Contributor

We discussed this in the @rust-lang/compiler meeting, so I'm removing the nominated tag -- there was not a lot of enthusiasm, for the reasons that have been presented on the thread already (e.g. by @nrc).

@brson
Copy link
Contributor

brson commented Aug 12, 2016

Since there's little change of this enhancement happening I'm just closing.

@brson brson closed this as completed Aug 12, 2016
@fdietze
Copy link
Author

fdietze commented Aug 12, 2016

So what is the recommended way of dealing with this problem now?

Off Topic:
I tried to model this discussion as a graph.
http://lanzarote.informatik.rwth-aachen.de:9001/focus/HJ_DHGmLQeaSciC0j_haSQ/graph
Although there were some things that I couldn't express in the graph, I think It's easier to grasp than reading this thread.

@nrc
Copy link
Member

nrc commented Aug 14, 2016

@fdietze I recommend running the output of the compiler through a tool to get the output you want. Exactly which tool depends on what you want - but something as simple as less might be enough. Or maybe a more sophisticated pager?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants