Skip to content

Set error handler output format as soon as possible #113127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 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,4 @@
// check-pass
// ignore-windows
// 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