-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Pretty print json in ui tests #45737
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Nice, this annoyed me too. |
src/librustc/session/config.rs
Outdated
@@ -1104,6 +1104,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, | |||
"enable ThinLTO when possible"), | |||
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED], | |||
"control whether #[inline] functions are in all cgus"), | |||
pretty_json_error_format: bool = (false, parse_bool, [UNTRACKED], |
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.
Is it necessary to add a new option? can -Z unstable_options
be reused?
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 right, that works :D
@bors r+ |
📌 Commit e5c1d51 has been approved by |
@bors r- The two JSON UI tests failed in the CI:
ui/lint/unused_parens_json_suggestion.rs diff {
"message": "unnecessary parentheses around assigned value",
"code": {
"code": "unused_parens",
"explanation": null
},
"level": "warning",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
- "byte_start": 1035,
- "byte_end": 1048,
+ "byte_start": 1027,
+ "byte_end": 1040,
"line_start": 24,
"line_end": 24,
"column_start": 14,
"column_end": 27,
"is_primary": true,
"text": [
{
"text": " let _a = (1 / (2 + 3));",
"highlight_start": 14,
"highlight_end": 27
}
],
"label": null,
"suggested_replacement": null,
"expansion": null
}
],
"children": [
{
"message": "lint level defined here",
"code": null,
"level": "note",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
- "byte_start": 881,
- "byte_end": 894,
+ "byte_start": 873,
+ "byte_end": 886,
"line_start": 19,
"line_end": 19,
"column_start": 9,
"column_end": 22,
"is_primary": true,
"text": [
{
"text": "#![warn(unused_parens)]",
"highlight_start": 9,
"highlight_end": 22
}
],
"label": null,
"suggested_replacement": null,
"expansion": null
}
],
"children": [],
"rendered": null
},
{
"message": "remove these parentheses",
"code": null,
"level": "help",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
- "byte_start": 1035,
- "byte_end": 1048,
+ "byte_start": 1027,
+ "byte_end": 1040,
"line_start": 24,
"line_end": 24,
"column_start": 14,
"column_end": 27,
"is_primary": true,
"text": [
{
"text": " let _a = (1 / (2 + 3));",
"highlight_start": 14,
"highlight_end": 27
}
],
"label": null,
"suggested_replacement": "1 / (2 + 3)",
"expansion": null
}
],
"children": [],
"rendered": null
}
],
"rendered": null
} ui/lint/use_suggestion_json.rs {
"message": "cannot find type `Iter` in this scope",
"code": {
"code": "E0412",
"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"
},
"level": "error",
"spans": [
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 896,
- "byte_end": 900,
+ "byte_start": 888,
+ "byte_end": 892,
"line_start": 20,
"line_end": 20,
"column_start": 12,
"column_end": 16,
"is_primary": true,
"text": [
{
"text": " let x: Iter;",
"highlight_start": 12,
"highlight_end": 16
}
],
"label": "not found in this scope",
"suggested_replacement": null,
"expansion": null
}
],
"children": [
{
"message": "possible candidates are found in other modules, you can import them into scope",
"code": null,
"level": "help",
"spans": [
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::binary_heap::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::btree_map::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::btree_set::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::hash_map::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::hash_set::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::linked_list::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::collections::vec_deque::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::option::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::path::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::result::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::slice::Iter;/n/n",
"expansion": null
},
{
"file_name": "$DIR/use_suggestion_json.rs",
- "byte_start": 873,
- "byte_end": 873,
+ "byte_start": 865,
+ "byte_end": 865,
"line_start": 19,
"line_end": 19,
"column_start": 1,
"column_end": 1,
"is_primary": true,
"text": [
{
"text": "fn main() {",
"highlight_start": 1,
"highlight_end": 1
}
],
"label": null,
"suggested_replacement": "use std::sync::mpsc::Iter;/n/n",
"expansion": null
}
],
"children": [],
"rendered": null
}
],
"rendered": null
}
{
"message": "aborting due to previous error",
"code": null,
"level": "error",
"spans": [],
"children": [],
"rendered": null
} |
@bors r+ |
📌 Commit 6d6fb2e has been approved by |
Pretty print json in ui tests I found the json output in one line to not be useful for reviewing r? @petrochenkov
☀️ Test successful - status-appveyor, status-travis |
Currently for these two errors we go to the effort of switching to a standard JSON emitter, for no obvious reason, and unlike any other errors. This behaviour was added for `pretty-json` in rust-lang#45737, and then `human-annotate-rs` copied it some time later when it was added. This commit changes things to just using the requested emitter, which is simpler and consistent with other errors. Old output: ``` $ rustc --error-format pretty-json {"$message_type":"diagnostic","message":"`--error-format=pretty-json` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=pretty-json` is unstable\n\n"} $ rustc --error-format human-annotate-rs {"$message_type":"diagnostic","message":"`--error-format=human-annotate-rs` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=human-annotate-rs` is unstable\n\n"} ``` New output: ``` $ rustc --error-format pretty-json { "$message_type": "diagnostic", "message": "`--error-format=pretty-json` is unstable", "code": null, "level": "error", "spans": [], "children": [], "rendered": "error: `--error-format=pretty-json` is unstable\n\n" } $ rustc --error-format human-annotate-rs error: `--error-format=human-annotate-rs` is unstable ```
I found the json output in one line to not be useful for reviewing
r? @petrochenkov