Regression: `RUSTDOCFLAGS=--show-coverage cargo doc` deletes any existing docs

Open
#9,447 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
build-system, cli

Research direction

Start with the reproduction in the issue: run cargo doc, then RUSTDOCFLAGS=--show-coverage cargo doc, and check target/doc/crate_name. The bisected regression points to rustc commit 27bd3f51a90733aabee45a9019a3aa785eccfd05 and recent rustdoc changes; docs should remain after the second command, including for the docs.rs workflow.

Written by the indexing model from the issue text.

Description

C-bug Command-doc S-needs-design

Problem

I tried this code: cargo doc && RUSTDOCFLAGS='-Z unstable-options '--show-coverage cargo doc

I expected to see this happen: There is documentation in target/doc/crate_name

Instead, this happened: The docs get deleted.

searched nightlies: from nightly-2021-04-28 to nightly-2021-04-29
regressed nightly: nightly-2021-04-29
searched commits: from https://github.com/rust-lang/rust/commit/727d101561f9b1e81c6282943292d990288ca479 to https://github.com/rust-lang/rust/commit/ca075d268d2ce315964e1dd195cfe837b8a53f4d
regressed commit: https://github.com/rust-lang/rust/commit/27bd3f51a90733aabee45a9019a3aa785eccfd05

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --script ./docs-exist.sh --preserve --start 2021-04-28 --end 2021-04-29 

Looks like this is related to the recent rustdoc changes (rust-lang/cargo#9419 or rust-lang/cargo#9404).

Steps

  1. cargo doc
  2. RUSTDOCFLAGS=--show-coverage cargo doc
  3. [ -e ${CARGO_TARGET_DIR:-target}/doc/crate_name ]

Possible Solution(s)

Only delete the docs folder if the sources or toolchain changes, not the invocation.

Notes

For context, this causes problems for docs.rs because we always run coverage after the docs are generated. We can work around it for now by running coverage before instead, but it would be nice to fix this. In the meantime I've pinned docs.rs to an older toolchain.

Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/cargo

All issues in rust-lang/cargo

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.