Skip to content
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

Include rendered diagnostic in json #46052

Merged
merged 4 commits into from
Nov 21, 2017

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Nov 17, 2017

@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 17, 2017

This is the 4th box of #42823 (cc @nrc)

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 17, 2017
@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 17, 2017

Currently checking whether src/test/parse-fail/bad-char-literals.rs also fails on master. It does fail even if compiled manually without --error-format json, so it seems unrelated to this PR except in that parse-fail generates json, and now the json additionally generates regular diagnostics.

@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 17, 2017

Jup, happens on master but not on nightly...

edit: it happens with rustc built with debug-assertions. No idea how long we've had this issue, but it's fixed now.

// generate regular command line output and store it in the json

// A threadsafe buffer for writing.
#[derive(Default, Clone)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, this is needed only because the interface of EmitterWriter::new requires it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@@ -178,7 +200,7 @@ impl Diagnostic {
children: db.children.iter().map(|c| {
Diagnostic::from_sub_diagnostic(c, je)
}).chain(sugg).collect(),
rendered: None,
rendered: Some(output.to_owned()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary to_owned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jup, removed

let mut normalized = output.replace(&parent_dir_str, "$DIR");

if json {
normalized = normalized.replace("\\n", "\n"); // verbatim newline in json strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this in short? This text is going to be used as a whole without any preprocessing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just want this so the json looks readable if suggestions contain multilines. As a side effect error explanations also become readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment explaining what's going on

@petrochenkov
Copy link
Contributor

r=me with questions answered

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2017
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 20, 2017

📌 Commit 3864d89 has been approved by petrochenkov

@petrochenkov petrochenkov added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 20, 2017
@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 20, 2017

Sorry about that, the master branch has an empty line less in the error output with suggestions

@nikomatsakis
Copy link
Contributor

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Nov 20, 2017

📌 Commit e7b2702 has been approved by petrochenkov

kennytm added a commit to kennytm/rust that referenced this pull request Nov 21, 2017
…n, r=petrochenkov

Include rendered diagnostic in json

r? @petrochenkov
bors added a commit that referenced this pull request Nov 21, 2017
Rollup of 11 pull requests

- Successful merges: #45987, #46031, #46050, #46052, #46103, #46120, #46134, #46141, #46148, #46155, #46157
- Failed merges:
@bors bors merged commit e7b2702 into rust-lang:master Nov 21, 2017
bors added a commit that referenced this pull request Nov 24, 2017
Check //~ERROR comments in ui tests

r? @nikomatsakis

cc #44844 @Phlosioneer @estebank @petrochenkov

this depends on #46052 getting merged first (the commits are included in here)

The relevant changes of this PR are c2f0af7 and 979269b
bors added a commit that referenced this pull request Nov 24, 2017
Check //~ERROR comments in ui tests

r? @nikomatsakis

cc #44844 @Phlosioneer @estebank @petrochenkov

this depends on #46052 getting merged first (the commits are included in here)

The relevant changes of this PR are c2f0af7 and 979269b
@oli-obk oli-obk deleted the rendered_diagnostics_in_json branch December 8, 2017 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants