Skip to content
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

Improve diagnostic for unknown --print request #124333

Merged
merged 1 commit into from
Apr 25, 2024
Merged
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
9 changes: 6 additions & 3 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
@@ -1888,9 +1888,12 @@ fn collect_print_requests(
let prints =
PRINT_KINDS.iter().map(|(name, _)| format!("`{name}`")).collect::<Vec<_>>();
let prints = prints.join(", ");
early_dcx.early_fatal(format!(
"unknown print request `{req}`. Valid print requests are: {prints}"
));

let mut diag =
early_dcx.early_struct_fatal(format!("unknown print request: `{req}`"));
#[allow(rustc::diagnostic_outside_of_impl)]
diag.help(format!("valid print requests are: {prints}"));
diag.emit()
}
};

1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -317,7 +317,6 @@ run-make/unstable-flag-required/Makefile
run-make/use-suggestions-rust-2018/Makefile
run-make/used-cdylib-macos/Makefile
run-make/used/Makefile
run-make/valid-print-requests/Makefile
run-make/volatile-intrinsics/Makefile
run-make/wasm-exceptions-nostd/Makefile
run-make/wasm-override-linker/Makefile
4 changes: 0 additions & 4 deletions tests/run-make/valid-print-requests/Makefile

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions tests/ui/invalid-compile-flags/print.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//@ compile-flags: --print yyyy
4 changes: 4 additions & 0 deletions tests/ui/invalid-compile-flags/print.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: unknown print request: `yyyy`
|
= help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models`

Loading