-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add short error message-format #44636
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
r? @nrc |
1b3f2be
to
9ad8252
Compare
Rather than adding a new emitter, could you have the human-readable emitter take an argument for detail level - either short or verbose? It seems that we'd save a lot of code dup (and a macro) that way. Could you put this behind a feature gate? |
Yes and yes. I was just thinking that we'd want to fully split both of the features but if not... |
8468a5f
to
a58becd
Compare
Ok, now just remain to put it behind a feature flag. |
Is it possible to make each error only occupy one line, similar to Mock up:
|
@kenny |
@eddyb That sample is referring to the UI test in this PR https://github.com/GuillaumeGomez/rust/blob/a58becd60d7d7a965ed246cf8e290e2bd94043b9/src/test/ui/short-error-format.stderr:
Improving E0308 could happen independent of this PR. |
Oh yeah, in that case, I agree, the example output in #44636 (comment) is a subset of the lines I have from my
|
So which output do you want? So I can do it once and for all. :) |
d598684
to
30128d6
Compare
I feel if the idea is to use as little vertical space the output should be closer to:
Beyond that, I wonder wether it'd be worth it to try to keep in the diagnostic machinery space for custom single line error messages that would work better for short output (and for text editors). May be I'll just go ahead and introduce it for while and see how much of a pain it becomes. If it is too much, we can rip it out. I do feel strongly against improving things for text editors in detriment of cli output. |
30128d6
to
bec51da
Compare
New output available! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/librustc/session/config.rs
Outdated
|
||
None => ErrorOutputType::HumanReadable(color), | ||
|
||
Some(arg) => { | ||
early_error(ErrorOutputType::HumanReadable(color), | ||
&format!("argument for --error-format must be human or json (instead \ | ||
was `{}`)", | ||
&format!("argument for --error-format must be `human` or `json` or \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
human
, json
or short
src/librustc/session/mod.rs
Outdated
@@ -833,9 +841,13 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { | |||
let emitter: Box<Emitter> = match output { | |||
config::ErrorOutputType::HumanReadable(color_config) => { | |||
Box::new(EmitterWriter::stderr(color_config, | |||
None)) | |||
None, | |||
false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fits in single line?
src/librustc/session/mod.rs
Outdated
@@ -846,9 +858,13 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) { | |||
let emitter: Box<Emitter> = match output { | |||
config::ErrorOutputType::HumanReadable(color_config) => { | |||
Box::new(EmitterWriter::stderr(color_config, | |||
None)) | |||
None, | |||
false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fits in single line?
src/librustc/session/mod.rs
Outdated
} | ||
(config::ErrorOutputType::HumanReadable(_), Some(dst)) => { | ||
Box::new(EmitterWriter::new(dst, | ||
Some(codemap.clone()))) | ||
Some(codemap.clone()), | ||
false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fits in single line?
bec51da
to
a4b28f2
Compare
The branch has been created on |
We now have the following error:
Anyone has an idea? |
@GuillaumeGomez Could you please use |
fff79bd
to
3f68f78
Compare
Ok, let's hope it'll be the good one this time. :) |
New error and it doesn't get any better:
Anyone has an idea? |
3f68f78
to
b46c014
Compare
Fixed. |
@bors r+ |
📌 Commit b46c014 has been approved by |
…ister Add short error message-format Fixes #42653.
☀️ Test successful - status-appveyor, status-travis |
@nrc @GuillaumeGomez this landed without a feature flag, was that intentional? I assume not given #44636 (comment)? |
I suppose this should be behind Thanks for noticing @alexcrichton ! |
Hum indeed, it should had have a feature flag. I'll add it as soon as possible. |
❤️ Thanks for fixing the bug I reported, looking forward to using this when it becomes available! |
On this comment my preference would be something like:
It's all in one line but that's probably okay. That's just, like, my opinion though man. |
…r-format, r=oli-obk Stabilize short error format r? @oli-obk Added in rust-lang#44636
Fixes #42653.