Skip to content

feat: rustdoc depinfo rebuild detection via -Zrustdoc-depinfo #15359

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

Merged
merged 4 commits into from
Mar 31, 2025

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Mar 28, 2025

What does this PR try to resolve?

This leverages the unstable --emit=depinfo option from rustdoc,
so that rustdoc invocation rebuild can be better tracked
without traversing the entire directory.

Some design decisions made in the current implementation:

  • Rustdoc's depinfo doesn't and shouldn't emit to target/doc,
    as the directory is considered part of the final artifact directory.
    In regard to that, we specify the dep-info output path to
    the fingerprint directory of rustdoc invocation.
    It looks like this
    target/debug/.fingerprint/serde-12d29d32b3b8b38f/doc-lib-serde.d.
  • We also start supporting -Zchecksum-freshness as a side effect.
    Could make it a separate PR if desired.
  • -Zbinary-dep-depinfo is not enabled along with this,
    since doc generations don't really require any binary dependencies.

How should we test and review this PR?

The tests added has covered these cases:

  • target src outside package root, e.g., lib.path = "../lib.rs"
  • #[doc = include_str!("../outside/pkgroot")]
  • #[path = "../outside/pkgroot"]
  • env!

Additional information

Fixes #12266
Closes #15205

@rustbot
Copy link
Collaborator

rustbot commented Mar 28, 2025

r? @epage

rustbot has assigned @epage.
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-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation A-rebuild-detection Area: rebuild detection and fingerprinting A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 28, 2025
@weihanglo weihanglo added Command-doc and removed A-documenting-cargo-itself Area: Cargo's documentation labels Mar 28, 2025
This leverages the unstable `--emit=depinfo` option from rustdoc,
so that rustdoc invocation rebuild can be better tracked
without traversing the entire directory.

Some design decisions:

* Rustdoc's depinfo doesn't and shouldn't emit to `target/doc`,
  as the directory is considered part of the final artifact directory.
  In regard to that, we specify the dep-info output path to
  the fingerprint directory of rustdoc invocation.
  It looks like this
  `target/debug/.fingerprint/serde-12d29d32b3b8b38f/doc-lib-serde.d`.
* We also start supporting `-Zchecksum-freshness` as a side effect.
  Could make it a separate PR if desired.
* `-Zbinary-dep-depinfo` is not enabled along with this,
  since doc generations don't really require any binary dependencies.
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Mar 29, 2025
@epage epage added this pull request to the merge queue Mar 31, 2025
@epage
Copy link
Contributor

epage commented Mar 31, 2025

Thanks!

Merged via the queue into rust-lang:master with commit 7220445 Mar 31, 2025
21 checks passed
@weihanglo weihanglo deleted the rustdoc-depinfo branch March 31, 2025 17:17
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2025
Update cargo

17 commits in a6c604d1b8a2f2a8ff1f3ba6092f9fda42f4b7e9..0e93c5bf6a1d5ee7bc2af63d1afb16cd28793601
2025-03-26 18:11:00 +0000 to 2025-04-05 00:00:24 +0000
- chore(deps): bump openssl from 0.10.71 to 0.10.72 (rust-lang/cargo#15394)
- chore(ci): restore cargo-util semver check (rust-lang/cargo#15389)
- docs(changelog): polish changelog items (rust-lang/cargo#15379)
- chore(deps): update msrv (1 version) to v1.86 (rust-lang/cargo#15381)
- chore: add aarch64 linux runner (rust-lang/cargo#15077)
- Added `build_directory` field to cargo metadata output (rust-lang/cargo#15377)
- chore(deps): update rust crate rusqlite to 0.34.0 (rust-lang/cargo#15373)
- Prevent undeclared public network access (rust-lang/cargo#15368)
- rename the `author` field to be `authors` in book.toml (rust-lang/cargo#15362)
- move modules from kebab-case to snake_case (rust-lang/cargo#14439)
- chore: bump to 0.89.0; update changelog (rust-lang/cargo#15372)
- docs(unstable): update `-Zrustdoc-depinfo` tracking issue link (rust-lang/cargo#15371)
- fix(tree): Make output more deterministic (rust-lang/cargo#15369)
- feat: rustdoc depinfo rebuild detection via -Zrustdoc-depinfo (rust-lang/cargo#15359)
- Rename the gc config table (rust-lang/cargo#15367)
- Revert "Temporarily ignore cargo_test_doctest_xcompile_ignores" (rust-lang/cargo#15357)
- Don't canonicalize executable path in `cargo_exe` (rust-lang/cargo#15355)

r? ghost
@rustbot rustbot added this to the 1.88.0 milestone Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation A-rebuild-detection Area: rebuild detection and fingerprinting A-unstable Area: nightly unstable support Command-doc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo doc doesn't detect dirty sources from parent directories
3 participants