-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add --check for rustdoc #8859
Add --check for rustdoc #8859
Conversation
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.
The decision of whether to run rustc
or rustdoc
is done here, so it looks like the is_doc
method needs to be updated.
src/cargo/core/compiler/mod.rs
Outdated
@@ -596,6 +598,10 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> { | |||
let pkg_id = unit.pkg.package_id(); | |||
let script_metadata = cx.find_build_script_metadata(unit.clone()); | |||
|
|||
if unit.mode.is_check() { | |||
rustdoc.arg("--test"); |
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.
Is this intended to be --check
?
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.
It is! Good catch.
@@ -55,5 +57,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { | |||
let compile_opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?; | |||
|
|||
ops::compile(&ws, &compile_opts)?; | |||
|
|||
if features::nightly_features_allowed() { |
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.
This will probably need an explicit opt-in.
Also, I'm a little concerned about the performance impact of adding this to the default set. Have you checked to see how slow it is on medium-to-large libraries?
Is it possible that rustdoc could generate duplicate warnings from rustc? I believe missing_docs
would be duplicated, are there other warnings that could cause that?
Related to the two above issues, if this is to be included in the default set, then the logic would go in filter_default_targets
. Running the build logic twice would be a pretty big performance hit, and would cause cached warnings to be replayed twice, among other issues. Unfortunately I think it could make the "duplicate errors" problem even more apparent, which makes me more concerned about having it in the default set.
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 didn't think about lint duplicates, but it's a good point. We can always allow the ones impacted to prevent this duplication. As for the compilation duplication, normally, rustdoc doesn't recompile anything. Or did I miss something?
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.
Personally I think this should be an opt-in with cargo check --doc
or cargo check --all-targets
.
Is it possible that rustdoc could generate duplicate warnings from rustc? I believe missing_docs would be duplicated, are there other warnings that could cause that?
The only warnings rustdoc emits are here: https://github.com/rust-lang/rust/blob/a1a13b2bc4fa6370b9501135d97c5fe0bc401894/src/librustdoc/core.rs#L336-L350
I think of those renamed_and_removed_lints
is the only one run in rustc
other than missing_docs
. I find the code around lints really hard to follow though, so I could be wrong. -A missing_docs -A renamed_and_removed_lints
to rustdoc seems like a good idea.
Have you checked to see how slow it is on medium-to-large libraries?
Slow. rust-lang/rust#78761
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.
Since rust-lang/rust#80527 I think cargo can solve the duplicate lint problem generally by passing -A warnings -W rustdoc::all
.
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 guess that's subtly different because it also warns about lints that are allowed by default. So -A missing_docs -A renamed_and_removed_lints -A unknown_lints
is probably better. https://github.com/rust-lang/rust/blob/8fd946c63a6c3aae9788bd459d278cb2efa77099/src/librustdoc/core.rs#L261-L267
07660f2
to
991eb2d
Compare
So, it's now working as expected. Remains the one question: should we disable the |
I think initially, we probably shouldn't worry too much about From a high level, some changes that I think should be made:
|
What is the process in cargo? Do you prefer to wait for the option to become stable in rustdoc first?
When running it, it didn't recompile anything there, or did I miss something?
👍 |
Usually just add a
It's not about recompiling, but re-running the resolver and other steps which can be expensive. It also causes some messages to be displayed multiple times (such as the |
@ehuss Wouldn't it be better to just run it by default if you're on nightly? |
@GuillaumeGomez I really don't like unstable features being on by default in nightly, that gave people a lot of trouble when we did it for intra-doc-links: rust-lang/rust#63305 |
The problem is that if it requires action from users, well, it will never be used... |
Ping @GuillaumeGomez: do you think you'll be able to address the concerns noted above? I recognize that when unstable features are gated behind an explicit opt-in that it is difficult to get users to test it, but that is the procedure that we use. |
I'll try to get back to it. |
☔ The latest upstream changes (presumably #9022) made this pull request unmergeable. Please resolve the merge conflicts. |
Missing this broke tooling for me a bit: I guess this could be solved on |
I'm gonna close this due to inactivity. Feel free to reopen or create a new PR when you've got time to work on this again. Thanks! |
Since rust-lang/rust#78984 has landed, it'd be nice to integrate it into cargo nightly.
Currently, the code seems to be running the checks, but doesn't run
rustdoc
. Any help to help me figure out what's missing would be very appreciated. :)r? @ehuss