-
Notifications
You must be signed in to change notification settings - Fork 2.6k
cargo doc
doesn't detect dirty sources from parent directories
#12266
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
Comments
Thanks for the report. I believe this is a known issue around the current fingerprint system (recompile detection). Cargo depends on file mtime to track whether it need to re-compile or not. For normal For resolving this, the long-term fix is having Footnotes |
triage: I think it is blocked on external ( Edited: linked to #9931 which is largely relevant, and rust-lang/rust#91982 which is where this is blocked. @rustbot label -S-triage +S-blocked-external +Command-doc +A-rebuild-detection |
The compiler has the capability to only emit a depinfo file. Would it be possible for cargo to invoke |
The Cargo compilation model is that each invocation Some concerns with this hack:
I've updated #12266 (comment) to include relevant issues btw. |
An easy short-term fix would be to consider the directory that contains the library crate root of the package (as specified by |
It doesn't work for |
FYI rustdoc dep info support is being worked on in rust-lang/rust#137684 |
### 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
See the tracking issue #15370. |
Problem
When sources aren't in a subdirectory of the cargo manifest,
cargo doc
fails to detect changes to those sources. The issue only occurs withcargo doc
(not check or build). It isn't affected by the working directory (using--manifest-path
), and using an absolute vs. relative path for the source makes no difference.Steps
Use the following directory structure and
Cargo.toml
with an emptylib.rs
:Running
cargo doc --manifest-path=manifest/Cargo.toml -v
should succeed. Now add a syntax error tolib.rs
. Subsequentcargo doc
runs will say that the crate isFresh
and exit without detecting the syntax error.Removing
manifest/target
manually or bycargo clean
ing will force a rebuild, but changes tolib.rs
seem to never cause rebuilds.Possible Solution(s)
No response
Notes
This behavior was encountered on Fuchsia, where we primarily use a different build system (GN+ninja) but have experimental support for generating cargo manifests for rust targets. The
Cargo.toml
s are generated in an out directory and contain absolute paths pointing to the source root for each crate. We initially thought the issue had to do with the absolute paths or our use of symlinks, but it appears that change detection forcargo doc
is broken for ANY sources that aren't in the same dir or subdirs of the manifest.Version
The text was updated successfully, but these errors were encountered: