Merged
Conversation
Contributor
|
Nice, this annoyed me too. |
petrochenkov
reviewed
Nov 3, 2017
src/librustc/session/config.rs
Outdated
| "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], |
Contributor
There was a problem hiding this comment.
Is it necessary to add a new option? can -Z unstable_options be reused?
Contributor
Author
There was a problem hiding this comment.
oh right, that works :D
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit e5c1d51 has been approved by |
Member
|
@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
} |
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit 6d6fb2e has been approved by |
Collaborator
bors
added a commit
that referenced
this pull request
Nov 6, 2017
Pretty print json in ui tests I found the json output in one line to not be useful for reviewing r? @petrochenkov
Collaborator
|
☀️ Test successful - status-appveyor, status-travis |
nnethercote
added a commit
to nnethercote/rust
that referenced
this pull request
Jan 5, 2024
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 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found the json output in one line to not be useful for reviewing
r? @petrochenkov