Auto merge of #113127 - jieyouxu:fix-error-color-summary, r=davidtwco

Set error handler output format as soon as possible

Should fix https://github.com/rust-lang/rust/pull/112692#issuecomment-1611585904.
This commit is contained in:
bors 2023-07-10 00:10:53 +00:00
commit 02d1ee4834
10 changed files with 15 additions and 7 deletions

View File

@ -2524,6 +2524,8 @@ pub fn build_session_options(
let error_format = parse_error_format(handler, matches, color, json_rendered); 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(|_| { let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
handler.early_error("`--diagnostic-width` must be an positive integer"); handler.early_error("`--diagnostic-width` must be an positive integer");
}); });

View File

@ -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\") // 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() {} fn main() {}

View File

@ -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"`) // error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
fn main() {} fn main() {}

View File

@ -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"`) // error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
fn main() {} fn main() {}

View File

@ -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"`) // error-pattern: invalid `--cfg` argument: `a{` (expected `key` or `key="value"`)
fn main() {} fn main() {}

View File

@ -1,3 +1,3 @@
// compile-flags: --cfg ) // compile-flags: --error-format=human --cfg )
// error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`) // error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`)
fn main() {} fn main() {}

View File

@ -1,4 +1,4 @@
// Test for missing quotes around value, issue #66450. // 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\") // 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() {} fn main() {}

View File

@ -1,6 +1,6 @@
// Tests that empty source_maps don't ICE (#23301) // 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"`) // error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`)

View File

@ -0,0 +1,4 @@
// check-pass
// ignore-windows
// compile-flags: -Cremark=foo --error-format=human --color always
fn main() {}

View File

@ -0,0 +1,2 @@
warning: -C remark requires "-C debuginfo=n" to show source locations