Skip to content

Conversation

@ShE3py
Copy link
Contributor

@ShE3py ShE3py commented Jan 24, 2026

Context: --print crate-root-lint-levels (#139180) is only available for rustc and clippy-driver, while it would make sense for it to also be available for rustdoc (à la #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 --prints 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):

fn check(CrateRootLintLevels { args, contains }: CrateRootLintLevels) {
let output = rustc()
.input("lib.rs")
.arg("-Zunstable-options")
.print("crate-root-lint-levels")
.args(args)
.run();

@rustbot label +A-CLI +A-print-requests

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2026

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-CLI Area: Command-line interface (CLI) to the compiler A-print-requests Area: print requests (`--print=...`) labels Jan 24, 2026
@rust-log-analyzer

This comment has been minimized.

@Urgau
Copy link
Member

Urgau commented Jan 24, 2026

I could indeed see the --print being useful in rustdoc, but I'm still a bit curious what your use-case.
Would you be able describe it?

return;
}

if rustc_driver::print_crate_info(&*compiler.codegen_backend, sess, true)
Copy link
Member

Choose a reason for hiding this comment

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

Note: IINM, this won't be run if the input file is *.md or if --test is passed. Not sure what the consequences of that are.

Copy link
Member

Choose a reason for hiding this comment

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

Moreover, --print=crate-name doesn't really make sense for *.md inputs I feel like?

}
};

let prints =
Copy link
Member

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-args to rustdoc under your PR. Contrary to most other rustc print request that make rustc stop compilation early, link-args actually 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-libs that seems to require sth. similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

E.g., I'm curious what will happen if you pass --print=link-args to rustdoc under your PR. Contrary to most other rustc print request that make rustc stop compilation early, link-args actually requires full analysis+codegen IINM … which rustdoc obv doesn't do. I guess it just doesn't print anything?

Yup, print_crate_info is a no-op for them as it's codegen_ssa that 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).

@ShE3py
Copy link
Contributor Author

ShE3py commented Jan 25, 2026

I could indeed see the --print being useful in rustdoc, but I'm still a bit curious what your use-case. Would you be able describe it?

I'd like to diff the default lint-levels of two Rust versions in order to simplify updating the lints when I come back after a while (e.g. remove -W foo if foo was promoted to warn-by-default).

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jan 28, 2026
@rust-log-analyzer

This comment has been minimized.

Comment on lines -1376 to +1375
(option_env!("CFG_COMPILER_HOST_TRIPLE")).expect("CFG_COMPILER_HOST_TRIPLE")
env!("CFG_COMPILER_HOST_TRIPLE")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was changed from env! to option_env! in the first commit of #13724, but not sure why this change was made or if it's still relevant as CI is green.

(Was looking looking for a #[expect] reason as removing the extra parentheses triggers deny-by-default clippy::option_env_unwrap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: Command-line interface (CLI) to the compiler A-print-requests Area: print requests (`--print=...`) A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants