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

Emit ansi color codes in the rendered field of json diagnostics #59128

Merged
merged 12 commits into from
Apr 17, 2019

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 12, 2019

cc @ljedrz

Implemented for #56595 (comment) (x.py clippy)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:255143e2:start=1552392589641132664,finish=1552392681630903073,duration=91989770409
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[00:54:38]    Compiling parking_lot_core v0.4.0
[00:54:42]    Compiling tempfile v3.0.5
[00:54:43]    Compiling parking_lot v0.7.1
[00:54:44]    Compiling rustdoc v0.0.0 (/checkout/src/librustdoc)
[00:54:45] error[E0423]: expected function, found struct variant `ErrorOutputType::Json`
[00:54:45]     |
[00:54:45]     |
[00:54:45] 259 |             Some("json") => ErrorOutputType::Json(false),
[00:54:45]     |                             ^^^^^^^^^^^^^^^^^^^^^ did you mean `ErrorOutputType::Json { /* fields */ }`?
[00:54:45] 
[00:54:45] error[E0423]: expected function, found struct variant `ErrorOutputType::Json`
[00:54:45]     |
[00:54:45]     |
[00:54:45] 260 |             Some("pretty-json") => ErrorOutputType::Json(true),
[00:54:45]     |                                    ^^^^^^^^^^^^^^^^^^^^^ did you mean `ErrorOutputType::Json { /* fields */ }`?
[00:54:45] 
[00:54:45] error[E0532]: expected tuple struct/variant, found struct variant `ErrorOutputType::Json`
[00:54:45]     |
[00:54:45]     |
[00:54:45] 302 |         ErrorOutputType::Json(pretty) => {
[00:54:45]     |         ^^^^^^^^^^^^^^^^^^^^^ did you mean `ErrorOutputType::Json { /* fields */ }`?
[00:54:48] error[E0061]: this function takes 4 parameters but 3 parameters were supplied
[00:54:48]    --> src/librustdoc/core.rs:306:17
[00:54:48]     |
[00:54:48] 306 | /                 JsonEmitter::stderr(
[00:54:48] 306 | /                 JsonEmitter::stderr(
[00:54:48] 307 | |                     None,
[00:54:48] 308 | |                     source_map,
[00:54:48] 309 | |                     pretty,
[00:54:48] 310 | |                 ).ui_testing(ui_testing)
[00:54:48] 
[00:54:49] error[E0061]: this function takes 5 parameters but 4 parameters were supplied
[00:54:49]    --> src/librustdoc/test.rs:385:23
[00:54:49]     |
[00:54:49]     |
[00:54:49] 385 |         let emitter = EmitterWriter::new(box io::sink(), None, false, false);
[00:54:49] 
[00:54:50] error: aborting due to 5 previous errors
[00:54:50] 
[00:54:50] Some errors occurred: E0061, E0423, E0532.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@ehuss
Copy link
Contributor

ehuss commented Mar 12, 2019

I've been looking at doing something similar to this. I'm considering using JSON output only for Cargo for a few reasons. Do you happen to know if the "rendered" field is fully consistent with the normal output?

@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 12, 2019

Do you happen to know if the "rendered" field is fully consistent with the normal output?

Yes it's identical. It's actually generated by invoking the regular diagnostic renderer and just recording the output.

@eddyb
Copy link
Member

eddyb commented Mar 12, 2019

@oli-obk Can we get compiletest to use rendered stuff, too? Right now it's dumping JSON out, which is pretty bad, but it would be even worse after this.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 12, 2019

Oh yea, totally forgot about this. I've been meaning to fix that in forever.

I'll do that in this PR as to not regress the status quo even further.

@mark-i-m
Copy link
Member

My email is telling me I was r?-ed, but I can't see myself in this thread... am I missing something?

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 12, 2019

the r? didn't work, so I deleted the comment.

Copy link
Member

@mark-i-m mark-i-m left a comment

Choose a reason for hiding this comment

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

LGTM, even though I don't have r? permissions :)

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 12, 2019

Right now it's dumping JSON out, which is pretty bad, but it would be even worse after this.

Note that this would not have changed the rendered output (because that would severely screw with .stderr and .stdout files). But I fixed the problem anyway.

r? @eddyb

@rust-highfive

This comment has been minimized.

"failed to decode compiler output as json: \
`{}`\nline: {}\noutput: {}",
error, line, output
)));
);
panic!()
Copy link
Member

@eddyb eddyb Mar 13, 2019

Choose a reason for hiding this comment

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

Does this panic! match what proc_res.fatal would do?

Nevermind, it avoids fatal trying to print the rendered field from JSON (and failing).

self.status, self.cmdline, self.stdout, self.stderr
self.status, self.cmdline,
json::extract_rendered(&self.stdout),
json::extract_rendered(&self.stderr),
Copy link
Member

@eddyb eddyb Mar 13, 2019

Choose a reason for hiding this comment

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

I assume this is the main compiletest change? 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jop

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 13, 2019

@bors r=mark-i-m,eddyb

@bors
Copy link
Contributor

bors commented Mar 13, 2019

📌 Commit 8f1d62befd2db8bfbe0eef0cd163945fafde2bf4 has been approved by mark-i-m,eddyb

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 13, 2019
@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 13, 2019

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 13, 2019
@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 14, 2019

@bors r=mark-i-m,eddyb

@bors
Copy link
Contributor

bors commented Mar 14, 2019

📌 Commit b5fc2c41b39c666fce1c275690a79bdc9cdc33d0 has been approved by mark-i-m,eddyb

@bors bors 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 Mar 14, 2019
@@ -1,5 +1,5 @@
// ignore-cloudabi
// compile-flags: --error-format pretty-json -Zunstable-options
// compile-flags: --error-format pretty-json -Zunstable-options --colorful-json=true
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a test for the current output here :-/

Also, although I see the immediate benefit of this, I would like for us to tackle a more "general" solution at some point where we can also produce HTML, for example.

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 do have other --error-format pretty-json ui tests.

So you're imagining something like --json-rendered=(plain|termcolor|html)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ping @estebank

Copy link
Contributor

Choose a reason for hiding this comment

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

In my mind something like --json-rendered=extended where the textual output would be the same and we'd have extra json fields annotating those with extra information:

{"text": "path `std::string::String`", "annotations": [{"start": 6, "end": 25, "highlight_type": "highlighted"}]}

That way any tool can consume these and turn them into whatever their needs may be.

That being said, having specific support for both terminal and html output make sense to me, given they probably cover 80% of all likely use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The --json-rendered list can be extended in the future to support schemes like the one you proposed. I will change the PR to only support plain and termcolor for now.

@bors
Copy link
Contributor

bors commented Apr 9, 2019

🌲 The tree is currently closed for pull requests below priority 15, this pull request will be tested once the tree is reopened

@bors
Copy link
Contributor

bors commented Apr 11, 2019

⌛ Testing commit 325936a with merge 1d700581f3bce5188c75e2e789d93ea6b97acfed...

@bors
Copy link
Contributor

bors commented Apr 11, 2019

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 11, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 11, 2019

I guess color codes differ between windows and linux?

@kennytm kennytm 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 Apr 14, 2019
@Centril
Copy link
Contributor

Centril commented Apr 14, 2019

@bors r-

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 16, 2019

@bors r=mark-i-m,eddyb

@bors
Copy link
Contributor

bors commented Apr 16, 2019

📌 Commit 55534e41dda3847c605f56a32b6e7d5b1ea483c5 has been approved by mark-i-m,eddyb

@bors bors 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 Apr 16, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0f17bc4a:start=1555423813710473250,finish=1555423942546770971,duration=128836297721
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:07:37] .................................................................................................... 2900/5541
[01:07:41] .................................................................................................... 3000/5541
[01:07:45] .................................................................................................... 3100/5541
[01:07:48] .................................................................................................... 3200/5541
[01:07:53] ............................................................................F....................... 3300/5541
[01:08:00] .................................................................................................... 3500/5541
[01:08:04] ...........ii...i..ii............................................................................... 3600/5541
[01:08:08] .................................................................................................... 3700/5541
[01:08:12] .................................................................................................... 3800/5541
---
[01:09:21] diff of stderr:
[01:09:21] 
[01:09:21] 73   "spans": [
[01:09:21] 74     {
[01:09:21] 75       "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -       "byte_start": 466,
[01:09:21] -       "byte_end": 470,
[01:09:21] -       "line_start": 11,
[01:09:21] -       "line_end": 11,
[01:09:21] +       "byte_start": 484,
[01:09:21] +       "byte_end": 488,
[01:09:21] +       "line_start": 12,
[01:09:21] +       "line_end": 12,
[01:09:21] 80       "column_start": 12,
[01:09:21] 81       "column_end": 16,
[01:09:21] 82       "is_primary": true,
[01:09:21] 101       "spans": [
[01:09:21] 102         {
[01:09:21] 102         {
[01:09:21] 103           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 108           "column_start": 1,
[01:09:21] 109           "column_end": 1,
[01:09:21] 110           "is_primary": true,
[01:09:21] 124         },
[01:09:21] 125         {
[01:09:21] 125         {
[01:09:21] 126           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 131           "column_start": 1,
[01:09:21] 132           "column_end": 1,
[01:09:21] 133           "is_primary": true,
[01:09:21] 147         },
[01:09:21] 148         {
[01:09:21] 148         {
[01:09:21] 149           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 154           "column_start": 1,
[01:09:21] 155           "column_end": 1,
[01:09:21] 156           "is_primary": true,
[01:09:21] 170         },
[01:09:21] 171         {
[01:09:21] 171         {
[01:09:21] 172           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 177           "column_start": 1,
[01:09:21] 178           "column_end": 1,
[01:09:21] 179           "is_primary": true,
[01:09:21] 193         },
[01:09:21] 194         {
[01:09:21] 194         {
[01:09:21] 195           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 200           "column_start": 1,
[01:09:21] 201           "column_end": 1,
[01:09:21] 202           "is_primary": true,
[01:09:21] 216         },
[01:09:21] 217         {
[01:09:21] 217         {
[01:09:21] 218           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 223           "column_start": 1,
[01:09:21] 224           "column_end": 1,
[01:09:21] 225           "is_primary": true,
[01:09:21] 239         },
[01:09:21] 240         {
[01:09:21] 240         {
[01:09:21] 241           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 246           "column_start": 1,
[01:09:21] 247           "column_end": 1,
[01:09:21] 248           "is_primary": true,
[01:09:21] 262         },
[01:09:21] 263         {
[01:09:21] 263         {
[01:09:21] 264           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 269           "column_start": 1,
[01:09:21] 270           "column_end": 1,
[01:09:21] 271           "is_primary": true,
[01:09:21] 285         },
[01:09:21] 286         {
[01:09:21] 286         {
[01:09:21] 287           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 292           "column_start": 1,
[01:09:21] 293           "column_end": 1,
[01:09:21] 294           "is_primary": true,
[01:09:21] 308         },
[01:09:21] 309         {
[01:09:21] 309         {
[01:09:21] 310           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 315           "column_start": 1,
[01:09:21] 316           "column_end": 1,
[01:09:21] 317           "is_primary": true,
[01:09:21] 331         },
[01:09:21] 332         {
[01:09:21] 332         {
[01:09:21] 333           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 338           "column_start": 1,
[01:09:21] 339           "column_end": 1,
[01:09:21] 340           "is_primary": true,
[01:09:21] 354         },
[01:09:21] 355         {
[01:09:21] 355         {
[01:09:21] 356           "file_name": "$DIR/use_suggestion_json.rs",
[01:09:21] -           "byte_start": 443,
[01:09:21] -           "byte_end": 443,
[01:09:21] -           "line_start": 10,
[01:09:21] -           "line_end": 10,
[01:09:21] +           "byte_start": 461,
[01:09:21] +           "byte_end": 461,
[01:09:21] +           "line_start": 11,
[01:09:21] +           "line_end": 11,
[01:09:21] 361           "column_start": 1,
[01:09:21] 362           "column_end": 1,
[01:09:21] 363           "is_primary": true,
[01:09:21] 381     }
[01:09:21] 382   ],
[01:09:21] 382   ],
[01:09:21] 383   "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0412]\u001b[0m\u001b[0m\u001b[1m: cannot find type `Iter` in this scope\u001b[0m
[01:09:21] - \u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m$DIR/use_suggestion_json.rs:11:12\u001b[0m
[01:09:21] + \u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m$DIR/use_suggestion_json.rs:12:12\u001b[0m
[01:09:21] 385 \u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
[01:09:21] 386 \u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m    let x: Iter;\u001b[0m
[01:09:21] 387 \u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m           \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m
[01:09:21] 
[01:09:21] The actual stderr differed from the expected stderr.
[01:09:21] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/use_suggestion_json/use_suggestion_json.stderr
[01:09:21] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/use_suggestion_json/use_suggestion_json.stderr
[01:09:21] To update references, rerun the tests and pass the `--bless` flag
[01:09:21] To only update this specific test, also pass `--test-args lint/use_suggestion_json.rs`
[01:09:21] error: 1 errors occurred comparing output.
[01:09:21] error: 1 errors occurred comparing output.
[01:09:21] failed to decode compiler output as json: `EOF while parsing an object at line 1 column 1`
[01:09:21] line: {
[01:09:21] output: {
[01:09:21]   "message": "cannot find type `Iter` in this scope",
[01:09:21]   "code": {
[01:09:21]     "code": "E0412",
[01:09:21]     "explanation": "\nThe type name used is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n    fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n    type N;\n\n    fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n    fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n    // either\n    use super::File;\n    // or\n    // use std::fs::File;\n    fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"
[01:09:21]   },
[01:09:21]   "level": "error",
[01:09:21]   "spans": [
[01:09:21]       "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]       "byte_start": 484,
[01:09:21]       "byte_end": 488,
[01:09:21]       "line_start": 12,
[01:09:21]       "line_start": 12,
[01:09:21]       "line_end": 12,
[01:09:21]       "column_start": 12,
[01:09:21]       "column_end": 16,
[01:09:21]       "is_primary": true,
[01:09:21]       "text": [
[01:09:21]         {
[01:09:21]           "text": "    let x: Iter;",
[01:09:21]           "highlight_start": 12,
[01:09:21]           "highlight_end": 16
[01:09:21]       ],
[01:09:21]       "label": "not found in this scope",
[01:09:21]       "suggested_replacement": null,
[01:09:21]       "suggestion_applicability": null,
[01:09:21]       "suggestion_applicability": null,
[01:09:21]       "expansion": null
[01:09:21]     }
[01:09:21]   ],
[01:09:21]   "children": [
[01:09:21]     {
[01:09:21]       "message": "possible candidates are found in other modules, you can import them into scope",
[01:09:21]       "code": null,
[01:09:21]       "level": "help",
[01:09:21]       "spans": [
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collectio:21]             }
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collections::btree_set::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collections::hash_map::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collections::hash_set::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collections::linked_list::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::collections::vec_deque::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::option::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::path::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::result::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::slice::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]         {
[01:09:21]           "file_name": "/checkout/src/test/ui/lint/use_suggestion_json.rs",
[01:09:21]           "byte_start": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "byte_end": 461,
[01:09:21]           "line_start": 11,
[01:09:21]           "line_end": 11,
[01:09:21]           "column_start": 1,
[01:09:21]           "column_end": 1,
[01:09:21]           "is_primary": true,
[01:09:21]           "text": [
[01:09:21]             {
[01:09:21]               "text": "fn main() {",
[01:09:21]               "highlight_start": 1,
[01:09:21]               "highlight_end": 1
[01:09:21]           ],
[01:09:21]           "label": null,
[01:09:21]           "label": null,
[01:09:21]           "suggested_replacement": "use std::sync::mpsc::Iter;\n\n",
[01:09:21]           "suggestion_applicability": "Unspecified",
[01:09:21]           "expansion": null
[01:09:21]       ],
[01:09:21]       "children": [],
[01:09:21]       "rendered": null
[01:09:21]     }
[01:09:21]     }
[01:09:21]   ],
[01:09:21]   "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0412]\u001b[0m\u001b[0m\u001b[1m: cannot find type `Iter` in this scope\u001b[0m\n\u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/checkout/src/test/ui/lint/use_suggestion_json.rs:12:12\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m    let x: Iter;\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m           \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: possible candidates are found in other modules, you can import them into scope\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::binary_heap::Iter;\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::btree_map::Iter;\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::btree_set::Iter;\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::hash_map::Iter;\u001b[0m\n\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0mand 8 other candidates\u001b[0m\n\n"
[01:09:21] }
[01:09:21] {
[01:09:21]   "message": "aborting due to previous error",
[01:09:21]   "code": null,
[01:09:21]   "level": "error",
[01:09:21]   "spans": [],
[01:09:21]   "children": [],
[01:09:21]   "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"
[01:09:21] }
[01:09:21]   "message": "For more information about this error, try `rustc --explain E0412`.",
[01:09:21]   "code": null,
[01:09:21]   "code": null,
[01:09:21]   "level": "",
[01:09:21]   "spans": [],
[01:09:21]   "children": [],
[01:09:21]   "rendered": "\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0412`.\u001b[0m\n"
[01:09:21] }
[01:09:21] thread '[ui] ui/lint/use_suggestion_json.rs' panicked at 'explicit panic', src/tools/compiletest/src/json.rs:78:25
[01:09:21] 
[01:09:21] 
[01:09:21] failures:
[01:09:21]     [ui] ui/lint/use_suggestion_json.rs
[01:09:21]     [ui] ui/lint/use_suggestion_json.rs
[01:09:21] 
[01:09:21] test result: FAILED. 5519 passed; 1 failed; 21 ignored; 0 measured; 0 filtered out
[01:09:21] 
[01:09:21] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:517:22
[01:09:21] 
[01:09:21] 
[01:09:21] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
---
travis_time:end:089d3bda:start=1555428119083873417,finish=1555428119088878731,duration=5005314
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:1aaae500
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:16cf2c20
travis_time:start:16cf2c20
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:04b485e8
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 16, 2019

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 16, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 17, 2019

@bors r=mark-i-m,eddyb

@bors
Copy link
Contributor

bors commented Apr 17, 2019

📌 Commit 5c6a43a has been approved by mark-i-m,eddyb

@bors bors 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 Apr 17, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 17, 2019
…ddyb

Emit ansi color codes in the `rendered` field of json diagnostics

cc @ljedrz

Implemented for rust-lang#56595 (comment) (x.py clippy)
bors added a commit that referenced this pull request Apr 17, 2019
Rollup of 5 pull requests

Successful merges:

 - #59128 (Emit ansi color codes in the `rendered` field of json diagnostics)
 - #59646 (const fn: Improve wording)
 - #59986 (Miri: refactor new allocation tagging)
 - #60003 (LLD is not supported on Darwin)
 - #60018 (Miri now supports entropy, but is still slow)

Failed merges:

r? @ghost
@bors bors merged commit 5c6a43a into rust-lang:master Apr 17, 2019
@oli-obk oli-obk deleted the colorful_json branch May 21, 2019 11:22
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.

9 participants