Improve diagnostic for unknown --print request

This commit is contained in:
Urgau 2024-04-24 15:34:57 +02:00
parent b3e117044c
commit 153b1f0421
6 changed files with 11 additions and 10 deletions

View File

@ -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()
}
};

View File

@ -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

View File

@ -1,4 +0,0 @@
include ../tools.mk
all:
$(RUSTC) --print uwu 2>&1 | diff - valid-print-requests.stderr

View File

@ -1,2 +0,0 @@
error: unknown print request `uwu`. 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`

View File

@ -0,0 +1 @@
//@ compile-flags: --print yyyy

View File

@ -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`