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

rustc book: Outdated parameters for --print #138698

Open
xizheyin opened this issue Mar 19, 2025 · 4 comments
Open

rustc book: Outdated parameters for --print #138698

xizheyin opened this issue Mar 19, 2025 · 4 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-print-requests Area: print requests (`--print=...`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@xizheyin
Copy link
Contributor

Location

https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information

Summary

When I use rustc ---print, it reports

       Usage:
           --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|deployment-target|file-names|host-tuple|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]

But some of them can not be found in the corresponding chapter in rustc book. And the order in which the parameters are arranged needs to be adjusted.

@xizheyin xizheyin added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Mar 19, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 19, 2025
@Urgau
Copy link
Member

Urgau commented Mar 19, 2025

But some of them can not be found in the corresponding chapter in rustc book

That's because some of them are unstable.

And the order in which the parameters are arranged needs to be adjusted.

What do you mean by "adjusted"?

@Urgau Urgau added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-print-requests Area: print requests (`--print=...`) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 19, 2025
@ChrisDenton
Copy link
Member

We should probably try to hide the unstable options on stable? Although that might be more difficult to do since I don't think stable/unstable is easy to query.

@xizheyin
Copy link
Contributor Author

What do you mean by "adjusted"?

Alphabetical order may be more beautiful.

We should probably try to hide the unstable options on stable?

I think so, too, otherwise it may cause confusion.Is it possible to mark as unstable?

@jieyouxu
Copy link
Member

jieyouxu commented Mar 19, 2025

It should be possible to hide the unstable options on stable due to how print requests are handed: see

let kind = if let Some((print_name, print_kind)) =
PRINT_KINDS.iter().find(|&&(name, _)| name == req)
{
check_print_request_stability(early_dcx, unstable_opts, (print_name, *print_kind));
*print_kind
} else {
emit_unknown_print_request_help(early_dcx, req)
};

Probably just pull out the "what is considered unstable print request" logic

fn check_print_request_stability(
early_dcx: &EarlyDiagCtxt,
unstable_opts: &UnstableOptions,
(print_name, print_kind): (&str, PrintKind),
) {
match print_kind {
PrintKind::AllTargetSpecsJson | PrintKind::CheckCfg | PrintKind::TargetSpecJson
if !unstable_opts.unstable_options =>
{
early_dcx.early_fatal(format!(
"the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \
print option"
));
}
_ => {}
}
}

(There might be a bit more nuance to this, I haven't tried implementing it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-print-requests Area: print requests (`--print=...`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants