Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 153b1f0

Browse files
committedApr 24, 2024
Improve diagnostic for unknown --print request
1 parent b3e1170 commit 153b1f0

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed
 

‎compiler/rustc_session/src/config.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1888,9 +1888,12 @@ fn collect_print_requests(
18881888
let prints =
18891889
PRINT_KINDS.iter().map(|(name, _)| format!("`{name}`")).collect::<Vec<_>>();
18901890
let prints = prints.join(", ");
1891-
early_dcx.early_fatal(format!(
1892-
"unknown print request `{req}`. Valid print requests are: {prints}"
1893-
));
1891+
1892+
let mut diag =
1893+
early_dcx.early_struct_fatal(format!("unknown print request: `{req}`"));
1894+
#[allow(rustc::diagnostic_outside_of_impl)]
1895+
diag.help(format!("valid print requests are: {prints}"));
1896+
diag.emit()
18941897
}
18951898
};
18961899

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ run-make/unstable-flag-required/Makefile
317317
run-make/use-suggestions-rust-2018/Makefile
318318
run-make/used-cdylib-macos/Makefile
319319
run-make/used/Makefile
320-
run-make/valid-print-requests/Makefile
321320
run-make/volatile-intrinsics/Makefile
322321
run-make/wasm-exceptions-nostd/Makefile
323322
run-make/wasm-override-linker/Makefile

‎tests/run-make/valid-print-requests/Makefile

-4
This file was deleted.

‎tests/run-make/valid-print-requests/valid-print-requests.stderr

-2
This file was deleted.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//@ compile-flags: --print yyyy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: unknown print request: `yyyy`
2+
|
3+
= 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`
4+

0 commit comments

Comments
 (0)
Failed to load comments.