Skip to content

Specify --print info=file syntax in --help #139799

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 1 commit into from
Apr 15, 2025
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
14 changes: 4 additions & 10 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,9 +1560,10 @@ The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE
)
});

static PRINT_KINDS_STRING: LazyLock<String> = LazyLock::new(|| {
static PRINT_HELP: LazyLock<String> = LazyLock::new(|| {
format!(
"[{}]",
"Compiler information to print on stdout (or to a file)\n\
INFO may be one of ({}).",
PRINT_KINDS.iter().map(|(name, _)| format!("{name}")).collect::<Vec<_>>().join("|")
)
});
Expand Down Expand Up @@ -1621,14 +1622,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"Comma separated list of types of output for the compiler to emit",
"[asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]",
),
opt(
Stable,
Multi,
"",
"print",
"Compiler information to print on stdout",
&PRINT_KINDS_STRING,
),
opt(Stable, Multi, "", "print", &PRINT_HELP, "INFO[=FILE]"),
opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""),
opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""),
opt(Stable, Opt, "o", "", "Write output to <filename>", "FILENAME"),
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/rustc-help/help-v.diff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -51,10 +51,27 @@
@@ -53,10 +53,27 @@
Set a codegen option
-V, --version Print version info and exit
-v, --verbose Use verbose output
Expand Down
6 changes: 4 additions & 2 deletions tests/run-make/rustc-help/help-v.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ Options:
--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]
Comma separated list of types of output for the
compiler to emit
--print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models]
Compiler information to print on stdout
--print INFO[=FILE]
Compiler information to print on stdout (or to a file)
INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).
-g Equivalent to -C debuginfo=2
-O Equivalent to -C opt-level=3
-o FILENAME Write output to <filename>
Expand Down
6 changes: 4 additions & 2 deletions tests/run-make/rustc-help/help.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ Options:
--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]
Comma separated list of types of output for the
compiler to emit
--print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models]
Compiler information to print on stdout
--print INFO[=FILE]
Compiler information to print on stdout (or to a file)
Comment on lines +32 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: for consistency reasons, - (as in stdout) is also accepted in the =FILE position, i.e. the following is a valid construct

$ rustc --print=target-cpus=-

and prints to stdout.

INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).
-g Equivalent to -C debuginfo=2
-O Equivalent to -C opt-level=3
-o FILENAME Write output to <filename>
Expand Down
5 changes: 3 additions & 2 deletions tests/ui/invalid-compile-flags/print-without-arg.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
error: Argument to option 'print' missing
Usage:
--print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models]
Compiler information to print on stdout
--print INFO[=FILE] Compiler information to print on stdout (or to a file)
INFO may be one of
(all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models).

Loading