-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
rustdoc: add --print option
#151618
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
base: main
Are you sure you want to change the base?
rustdoc: add --print option
#151618
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -542,6 +542,14 @@ fn opts() -> Vec<RustcOptGroup> { | |
| "Comma separated list of types of output for rustdoc to emit", | ||
| "[toolchain-shared-resources,invocation-specific,dep-info]", | ||
| ), | ||
| opt( | ||
| Stable, | ||
|
ShE3py marked this conversation as resolved.
Outdated
|
||
| Multi, | ||
| "", | ||
| "print", | ||
| "Rustdoc information to print on stdout (or to a file)", | ||
| "<INFO>[=<FILE>]", | ||
| ), | ||
| opt(Unstable, FlagMulti, "", "no-run", "Compile doctests without running them", ""), | ||
| opt( | ||
| Unstable, | ||
|
|
@@ -885,6 +893,12 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) { | |
| return; | ||
| } | ||
|
|
||
| if rustc_driver::print_crate_info(&*compiler.codegen_backend, sess, true) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: IINM, this won't be run if the input file is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreover, |
||
| == rustc_driver::Compilation::Stop | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| let krate = rustc_interface::passes::parse(sess); | ||
| rustc_interface::create_and_enter_global_ctxt(compiler, krate, |tcx| { | ||
| if sess.dcx().has_errors().is_some() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sense that there are certain rustc print requests which I don't think rustdoc can support.
E.g., I'm curious what will happen if you pass
--print=link-argstorustdocunder your PR. Contrary to most other rustc print request that make rustc stop compilation early,link-argsactually requires full analysis+codegen IINM … which rustdoc obv doesn't do. I guess it just doesn't print anything?If so, that would be an example of a rustc print request that shouldn't be a legal rustdoc one.
There's also
--print=native-static-libsthat seems to require sth. similar.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup,
print_crate_infois a no-op for them as it'scodegen_ssathat print them, and since the codegen isn't called, they don't print anything.I'll filter the prints depending on if they make sense depending on the file type (.rs / .md / both) and action (doc / doctest / any).