Skip to content

Support target.'cfg(..)'.rustdocflags analogously to rustflags#16846

Merged
weihanglo merged 2 commits intorust-lang:masterfrom
ArshLabs:fix/16761-cfg-rustdocflags
Apr 8, 2026
Merged

Support target.'cfg(..)'.rustdocflags analogously to rustflags#16846
weihanglo merged 2 commits intorust-lang:masterfrom
ArshLabs:fix/16761-cfg-rustdocflags

Conversation

@ArshLabs
Copy link
Copy Markdown
Contributor

@ArshLabs ArshLabs commented Apr 7, 2026

What does this PR try to resolve?

Resolves #16761 by supporting target.'cfg(..)'.rustdocflags with behavior analogous to target.'cfg(..)'.rustflags.

Before this change, target.'cfg(..)'.rustdocflags was ignored and warned as an unused key. This PR brings cfg-based rustdocflags support to parity with existing cfg-based rustflags behavior.

This PR is intentionally split into two atomic commits:

  • test: cover ignored target cfg rustdocflags behavior
    • Adds tests that document the prior behavior first (C-TEST).
  • fix: support target cfg rustdocflags
    • Implements cfg-based rustdocflags support.
    • Updates the new tests to the new expected behavior.
    • Updates config reference docs for precedence and target.<cfg>.rustdocflags.

How to test and review this PR?

Suggested review order by commit:

  1. test: cover ignored target cfg rustdocflags behavior
  2. fix: support target cfg rustdocflags

Focused tests:

cargo test -p cargo --test testsuite -- rustdocflags::target_cfg_rustdocflags -- --test-threads=1

Full rustdocflags module:

cargo test -p cargo --test testsuite -- rustdocflags:: -- --test-threads=1

Local validation run for this branch included:

  • cargo build
  • cargo clippy -- -D warnings
  • cargo test -p cargo --test testsuite -- rustdocflags:: -- --test-threads=1

@rustbot rustbot added A-cfg-expr Area: Platform cfg expressions A-documenting-cargo-itself Area: Cargo's documentation labels Apr 7, 2026
@ArshLabs ArshLabs marked this pull request as ready for review April 7, 2026 19:50
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 7, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 7, 2026

r? @epage

rustbot has assigned @epage.
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: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Looks good!

Let me know if you want to work on the other missing part -Zhost-config support: #16761 (comment)

View changes since this review

@ArshLabs
Copy link
Copy Markdown
Contributor Author

ArshLabs commented Apr 8, 2026

Looks good!

Let me know if you want to work on the other missing part -Zhost-config support: #16761 (comment)

View changes since this review

Addressed the remaining host config parity point now.

Changes included:

  • Added host rustdocflags support for host artifacts behind -Zhost-config (with -Ztarget-applies-to-host)
  • Added a regression test: host_rustdocflags_for_proc_macro
  • Updated the unstable host-config docs example to include rustdocflags

Local validation passed:

  • cargo fmt --check
  • cargo test -p cargo --test testsuite -- rustdocflags:: -- --test-threads=1
  • cargo test -p cargo --test testsuite -- rustflags::target_applies_to_host_rustdocflags_works -- --test-threads=1
  • cargo test -p cargo --test testsuite -- rustflags::host_config_rustflags_with_target -- --test-threads=1

@ArshLabs ArshLabs force-pushed the fix/16761-cfg-rustdocflags branch from d6d2734 to 65ace47 Compare April 8, 2026 19:51
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ArshLabs
Copy link
Copy Markdown
Contributor Author

ArshLabs commented Apr 8, 2026

Thanks for catching this @weihanglo and no worries!

just dropped the host.rustdocflags change and force-pushed, I also folded the cfg(true) cleanup into the first commit as requested..

also re ran local validation on the rewritten branch:

  • cargo fmt --check
  • cargo test -p cargo --test testsuite -- rustdocflags::target_cfg_rustdocflags -- --test-threads=1
  • cargo test -p cargo --test testsuite -- rustdocflags:: -- --test-threads=1

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

@weihanglo weihanglo enabled auto-merge April 8, 2026 20:14
@weihanglo weihanglo added this pull request to the merge queue Apr 8, 2026
Merged via the queue into rust-lang:master with commit 40c3d9c Apr 8, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 9, 2026
Update cargo submodule

5 commits in 101549dddbd2b08e806f50154e3aa4cb3374cc21..eb94155a9a60943bd7b1cb04abec42f5d0de6ddc
2026-04-08 12:51:20 +0000 to 2026-04-09 13:10:20 +0000
- Revert "GitHub fast path uses `http_async`" (rust-lang/cargo#16861)
- Correct spelling in cargo info man page (rust-lang/cargo#16863)
- chore: Update annotate-snippets to 0.12.15 (rust-lang/cargo#16859)
- fix(test): strip RUSTUP_TOOLCHAIN_SOURCE from test environment (rust-lang/cargo#16857)
- Support target.'cfg(..)'.rustdocflags analogously to rustflags (rust-lang/cargo#16846)

r? ghost
@rustbot rustbot modified the milestone: 1.96.0 Apr 9, 2026
rust-timer added a commit to rust-lang/rust that referenced this pull request Apr 9, 2026
Rollup merge of #155042 - weihanglo:update-cargo, r=weihanglo

Update cargo submodule

5 commits in 101549dddbd2b08e806f50154e3aa4cb3374cc21..eb94155a9a60943bd7b1cb04abec42f5d0de6ddc
2026-04-08 12:51:20 +0000 to 2026-04-09 13:10:20 +0000
- Revert "GitHub fast path uses `http_async`" (rust-lang/cargo#16861)
- Correct spelling in cargo info man page (rust-lang/cargo#16863)
- chore: Update annotate-snippets to 0.12.15 (rust-lang/cargo#16859)
- fix(test): strip RUSTUP_TOOLCHAIN_SOURCE from test environment (rust-lang/cargo#16857)
- Support target.'cfg(..)'.rustdocflags analogously to rustflags (rust-lang/cargo#16846)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cfg-expr Area: Platform cfg expressions A-documenting-cargo-itself Area: Cargo's documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support target.'cfg(..)'.rustdocflags analogously to rustflags

4 participants