Files
rust/compiler/rustc_driver_impl
Jonathan Brouwer 549f475a13 Rollup merge of #151618 - ShE3py:rustdoc-print, r=notriddle
rustdoc: add `--print` option

Context: `--print crate-root-lint-levels` (rust-lang/rust#139180) is only available for `rustc` and `clippy-driver`, while it would make sense for it to also be available for `rustdoc` (à la rust-lang/rust#83895.)

Not too sure about the stability of `rustdoc --print=any` or if this needs a MCP; strictly speaking, only `rustdoc +nightly -Z unstable-options --print=crate-root-lint-levels` would be required (and the `rustdoc --print` would be stabilized together with `crate-root-lint-levels`), but I guess that makes sense to have all the `--print`s for consistency.

For regression tests, not sure if ui or run-make is preferable, as run-make would need some sort of trait to avoid duplicating code between `rustc()` and `rustdoc()` (or just test `rustdoc` as it delegates to `rustc`):
021fc25b7a/tests/run-make/print-crate-root-lint-levels/rmake.rs (L82-L88)

@rustbot label +A-CLI +A-print-requests
2026-09-01 21:26:10 +02:00
..
2026-08-21 10:35:02 +02:00
…

The driver crate is effectively the "main" function for the rust compiler. It orchestrates the compilation process and "knits together" the code from the other crates within rustc. This crate itself does not contain any of the "main logic" of the compiler (though it does have some code related to pretty printing or other minor compiler options).

For more information about how the driver works, see the rustc dev guide.