Skip to content

cargo doc should delete search-index.js before invoking rustdoc #15499

Open
@lolbinarycat

Description

@lolbinarycat

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 different cargo 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 by cargo 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-docS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions