Skip to content

cargo doc doesn't detect dirty sources from parent directories #12266

Closed
@P1n3appl3

Description

@P1n3appl3

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 with cargo 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 empty lib.rs:

manifest
└── Cargo.toml
lib.rs
[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[lib]
path = "../lib.rs"

Running cargo doc --manifest-path=manifest/Cargo.toml -v should succeed. Now add a syntax error to lib.rs. Subsequent cargo doc runs will say that the crate is Fresh and exit without detecting the syntax error.

Removing manifest/target manually or by cargo cleaning will force a rebuild, but changes to lib.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.tomls 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 for cargo doc is broken for ANY sources that aren't in the same dir or subdirs of the manifest.

Version

Verified the behavior with both nightly `cargo 1.72.0-nightly (49b6d9e17 2023-06-09)` and stable `cargo 1.70.0 (ec8a8a0ca 2023-04-25)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rebuild-detectionArea: rebuild detection and fingerprintingC-bugCategory: bugCommand-docS-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fixZ-rustdoc-depinfoNightly: rustdoc-depinfo integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions