Skip to content

Commit

Permalink
Rollup merge of rust-lang#113127 - jieyouxu:fix-error-color-summary, …
Browse files Browse the repository at this point in the history
…r=davidtwco

Set error handler output format as soon as possible

Should fix rust-lang#112692 (comment).
  • Loading branch information
matthiaskrgr authored Jun 29, 2023
2 parents fe2cdfb + 1805d44 commit 4d3a456
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,8 @@ pub fn build_session_options(

let error_format = parse_error_format(handler, matches, color, json_rendered);

handler.abort_if_error_and_set_error_format(error_format);

let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
handler.early_error("`--diagnostic-width` must be an positive integer");
});
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-1.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --cfg a(b=c)
// compile-flags: --error-format=human --cfg a(b=c)
// error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --cfg a{b}
// compile-flags: --error-format=human --cfg a{b}
// error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-4.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --cfg a(b)
// compile-flags: --error-format=human --cfg a(b)
// error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-6.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --cfg a{
// compile-flags: --error-format=human --cfg a{
// error-pattern: invalid `--cfg` argument: `a{` (expected `key` or `key="value"`)
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-8.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --cfg )
// compile-flags: --error-format=human --cfg )
// error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`)
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-arg-invalid-9.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Test for missing quotes around value, issue #66450.
// compile-flags: --cfg key=value
// compile-flags: --error-format=human --cfg key=value
// error-pattern: invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-empty-codemap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Tests that empty source_maps don't ICE (#23301)

// compile-flags: --cfg ""
// compile-flags: --error-format=human --cfg ""

// error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`)

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/diagnostic-flags/colored-session-opt-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// check-pass
// compile-flags: -Cremark=foo --error-format=human --color always
fn main() {}
2 changes: 2 additions & 0 deletions tests/ui/diagnostic-flags/colored-session-opt-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
warning: -C remark requires "-C debuginfo=n" to show source locations

0 comments on commit 4d3a456

Please sign in to comment.