Skip to content

Commit 02d1ee4

Browse files
committed
Auto merge of rust-lang#113127 - jieyouxu:fix-error-color-summary, r=davidtwco
Set error handler output format as soon as possible Should fix rust-lang#112692 (comment).
2 parents 70d7283 + 1faa95d commit 02d1ee4

10 files changed

+15
-7
lines changed

compiler/rustc_session/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,8 @@ pub fn build_session_options(
25242524

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

2527+
handler.abort_if_error_and_set_error_format(error_format);
2528+
25272529
let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
25282530
handler.early_error("`--diagnostic-width` must be an positive integer");
25292531
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --cfg a(b=c)
1+
// compile-flags: --error-format=human --cfg a(b=c)
22
// 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\")
33
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --cfg a{b}
1+
// compile-flags: --error-format=human --cfg a{b}
22
// error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
33
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --cfg a(b)
1+
// compile-flags: --error-format=human --cfg a(b)
22
// error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
33
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --cfg a{
1+
// compile-flags: --error-format=human --cfg a{
22
// error-pattern: invalid `--cfg` argument: `a{` (expected `key` or `key="value"`)
33
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: --cfg )
1+
// compile-flags: --error-format=human --cfg )
22
// error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`)
33
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Test for missing quotes around value, issue #66450.
2-
// compile-flags: --cfg key=value
2+
// compile-flags: --error-format=human --cfg key=value
33
// 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\")
44
fn main() {}

tests/ui/conditional-compilation/cfg-empty-codemap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Tests that empty source_maps don't ICE (#23301)
22

3-
// compile-flags: --cfg ""
3+
// compile-flags: --error-format=human --cfg ""
44

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// check-pass
2+
// ignore-windows
3+
// compile-flags: -Cremark=foo --error-format=human --color always
4+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
warning: -C remark requires "-C debuginfo=n" to show source locations
2+

0 commit comments

Comments
 (0)