Skip to content

fix(doc): do not suggest cargo fix for rustdoc warnings - #17702

Merged
weihanglo merged 2 commits into
rust-lang:masterfrom
Niloyyy:fix-12277-no-doc-cargo-fix-suggestion
Nov 9, 2026
Merged

weihanglo merged 2 commits into
rust-lang:masterfrom
Niloyyy:fix-12277-no-doc-cargo-fix-suggestion

Conversation

@Niloyyy

@Niloyyy Niloyyy commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

Fixes #12277.

When cargo doc runs rustdoc on a local unit and rustdoc emits a warning with a machine-applicable suggestion (such as rustdoc::bare_urls on a bare URL in a doc comment), DrainState::report_warning_count in src/compiler/job_queue/mod.rs previously printed a suggestion to run cargo fix:

warning: `foo` (lib doc) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)

However, cargo fix only runs rustc (in check mode) and does not invoke rustdoc (tracked separately as a feature request in #13025), so running the suggested cargo fix command does not apply rustdoc lint suggestions.

This change updates DrainState::report_warning_count to also exclude rustdoc units (!unit.mode.is_doc() && !unit.mode.is_doc_scrape()), matching the condition used elsewhere in src/compiler/ to distinguish rustdoc invocations from rustc invocations.

Notes to reviewers

  • Commit 1 (test(doc): add test for rustdoc fixable warning summary) adds doc::doc_fixable_warning_no_fix_suggestion demonstrating the previous output.
  • Commit 2 (fix(doc): do not suggest cargo fix for rustdoc warnings) suppresses the cargo fix suggestion for Doc and Docscrape modes and updates the test snapshot.
  • Trade-off: rustdoc units will no longer display the run cargo fix ... hint until cargo fix gains support for rustdoc (cargo fix doesn't work for rustdoc lints #13025); rustc units (including local workspace dependencies checked via rustc during cargo doc) continue to suggest cargo fix as before.

cargo fix only runs rustc (in check mode) and cannot apply machine-applicable lint suggestions emitted by rustdoc, so suppress the cargo fix hint for Doc and Docscrape units.

Fixes rust-lang#12277
@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2026
@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

r? @Muscraft

rustbot has assigned @Muscraft.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Muscraft, @epage, @weihanglo
  • @Muscraft, @epage, @weihanglo expanded to Muscraft, epage, weihanglo
  • Random selection from Muscraft, epage, weihanglo

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We can track the overall rustdoc fix support in #13025

View changes since this review

@weihanglo
weihanglo added this pull request to the merge queue Nov 9, 2026
Merged via the queue into rust-lang:master with commit 7548a1c Nov 9, 2026
30 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 9, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Nov 11, 2026
Update cargo submodule

15 commits in c07ac2c4d12237effc4b94f4543769b421790045..ede6cefea9731cb595942338824c2f9a610b8189
2026-11-06 19:13:29 +0000 to 2026-11-11 12:33:16 +0000
- chore: bump to 0.103.0; update changelog (rust-lang/cargo#17709)
- Update documentation about adding new publishable crates (rust-lang/cargo#17711)
- test: Make cross compile test work with annotate-snippets whitespace changes (rust-lang/cargo#17707)
- feat(config): Expose config merging, reading, and schemas in a crate (rust-lang/cargo#17705)
- feat(schema): Expose SBOM types (rust-lang/cargo#17683)
- fix: strip host deps whose debuginfo was weakened already (rust-lang/cargo#17691)
- fix: dont strip if any transtive dep has debuginfo on  (rust-lang/cargo#17689)
- Reduce memory allocation in crate_type.rs (rust-lang/cargo#17706)
- fix(doc): do not suggest cargo fix for rustdoc warnings (rust-lang/cargo#17702)
- perf(parse): Trade remote manifest diagnostic quality for performance (rust-lang/cargo#17701)
- refactor(config): Pull deserialiation into the config layer (rust-lang/cargo#17699)
- Use trusted publishing for the home crate (rust-lang/cargo#17703)
- refactor(benchsuite): Port to divan (rust-lang/cargo#17700)
- fix(schema): Improve deserialization errors and performance (rust-lang/cargo#17697)
- fix(lockfile): sort unused patches in Cargo.lock (rust-lang/cargo#17698)
@rustbot rustbot added this to the 1.102.0 milestone Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo doc produces seemingly invalid suggestions to run cargo fix

4 participants