-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Put back ui json check #48684
Put back ui json check #48684
Conversation
src/tools/compiletest/src/runtest.rs
Outdated
.iter() | ||
.any(|s| s.starts_with("--error-format")) | ||
{ | ||
rustc.args(&["--error-format", "json"]); |
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.
-Zui-testing
was lost during revert.
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.
It doesn't work at all. Whatever I try to do, I always end with empty stderr so I'll keep my code for the moment.
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.
Ah nevermind, I didn't update correctly...
@GuillaumeGomez I think I got the restoration of |
src/librustc_errors/emitter.rs
Outdated
@@ -31,6 +31,11 @@ const ANONYMIZED_LINE_NUM: &str = "LL"; | |||
pub trait Emitter { | |||
/// Emit a structured diagnostic. | |||
fn emit(&mut self, db: &DiagnosticBuilder); | |||
|
|||
/// Shows explanation about "rustc --explain" | |||
fn show_explain(&mut self) -> Vec<String> { |
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.
While this does successfully implement #48041, it seems rather ad hoc to make a show_explain
method be part of the contract of the Emitter
trait. (In contrast to how it makes sense for all Emitter
s to have an emit
method, because that's what being an Emitter
is all about.) Can we implement this in a more generalizable way?
Two potential alternatives that come to mind:
- Make the
Emitter
trait have adestination
method that exposes something we can write arbitrary lines to, and use it to write the--explain
usage message inabort_if_errors
.JsonEmitter
'sdst
field is of typeBox<Write + Send>
, andEmitterWriter
'sDestination
implementsWrite
and the field of all three of its variants implementSend
(visible in the source in the case ofBufferedTerminal
andRaw
, and theterm
docs say thatStderrTerminal
isSend
), so I think the types should check out.
- Implement the
--explain
message as aDiagnostic
, adding a plainer formatting mode toDiagnostic
if necessary.
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.
@GuillaumeGomez can you comment on this?
src/libsyntax/json.rs
Outdated
@@ -41,6 +42,7 @@ pub struct JsonEmitter { | |||
/// Whether "approximate suggestions" are enabled in the config | |||
approximate_suggestions: bool, | |||
ui_testing: bool, | |||
error_codes: HashSet<String>, |
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.
As I mentioned in passing at the end of a previous comment, Handler
already knows what what codes we've emitted; JsonEmitter
shouldn't have to know this.
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.
Oh indeed. I'll remove this add.
src/librustc_errors/emitter.rs
Outdated
error_codes[..limit].join(", "), | ||
if error_codes.len() > 9 { "..." } else { "" }), | ||
format!("If you want more information on an error, try using \ | ||
\"rustc --explain {}\"", |
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.
(If we end up needing to regenerate the UI test expectations anyway in the course of this PR, then we might as well also update the language (and use backticks) at the same time; but if not, then we can continue leave those tasks to #48559.)
☔ The latest upstream changes (presumably #48586) made this pull request unmergeable. Please resolve the merge conflicts. |
@petrochenkov: Reverting seems like way too much troubles... |
d61877f
to
1975eb4
Compare
This new way of handling things will certainly please you more. :) |
1975eb4
to
4c5adcf
Compare
☔ The latest upstream changes (presumably #48125) made this pull request unmergeable. Please resolve the merge conflicts. |
7c371ad
to
8a6f0a2
Compare
☔ The latest upstream changes (presumably #47832) made this pull request unmergeable. Please resolve the merge conflicts. |
bcf99f3
to
ef6dbb1
Compare
46dc072
to
5a48d31
Compare
@petrochenkov: Tests (finally) passed. |
Some errors occurred: E0191, E0221. | ||
|
||
For more information about an error, try `rustc --explain E0191`. | ||
|
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.
Last thing: removing this trailing empty line and the empty line after "Some errors occurred...", then we'll land this with higher priority.
5a48d31
to
c203cbb
Compare
@petrochenkov: Done as well, but let's wait for CI confirmation first. |
43bda9a
to
6c673ef
Compare
6c673ef
to
2e104a7
Compare
@petrochenkov: New tests are being added all the time. T_T |
@bors r+ p=1 |
📌 Commit 2e104a7 has been approved by |
…chenkov Put back ui json check r? @petrochenkov
☀️ Test successful - status-appveyor, status-travis |
r? @petrochenkov