-
Notifications
You must be signed in to change notification settings - Fork 2.6k
cargo doc should delete search-index.js before invoking rustdoc #15499
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
Somewhat related: #8487 |
As |
Agreed with @epage: if you remove the search index, you need to rebuild the doc of the current crate and of all its dependencies. |
@GuillaumeGomez but, if we're already going to do that, then perhaps cargo should delete things? it feels quite difficult to fix these problems in rustdoc without support from cargo. maybe we could add |
I's not something we can fix in rustdoc. We could exit with a specific error or provide information in a specific way to cargo so it knows it needs to rebuild all docs. |
what about the case of duplicating crates in the search index? how can we fix that without breaking the case where there actually are multiple crates with the same name? |
Seems very unlikely to happen, no? |
which is unlikely, duplicating search index entries or a situation where multiple crates with the same name coexist in a dependancy tree? the former is the cause of rust-lang/rust#133544, while the latter is easily caused by transitively depending on multiple semver-incompatible versions of the same crate. |
Problem
Unlike the vast majority of build artifacts,
search-index.js
is both read and written by rustdoc, in order to append to it in a structured way.This has the unfortunate side effect of persisting some state across
cargo doc
runs, as rustdoc will be able to see the output of the previous invocation.This cannot be easily addressed within rustdoc, as it has no way to tell the difference between two invocations of rustdoc within one larger
cargo doc
invocation, and two different invocations of rustdoc across two differentcargo doc
invocations.The weird read+write behavior of rustdoc is required because it does not have any equivalent to the "linking" step that rustc does, in which it can do one-time finalization and collection.
see rust-lang/rust#140698 and rust-lang/rust#133544 for some of the issues this causes
Proposed Solution
target/doc/search-index.js
should be deleted bycargo doc
before doing a full documentation rebuild (such as when the command-line arguments have changed, like in--document-private-items
).Notes
I believe
crates.js
also has a similar behavior.The text was updated successfully, but these errors were encountered: