Skip to content

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Mar 24, 2025

Implementation of rust-lang/rfcs#3631.

This implementation actually resulted in a lot of simplifications:

  • All cfg computation is now done in one place: propagate_doc_cfg.rs. Because (trait) impls are not retrieved at the same time as the other items, we cannot perform this computation in the clean process, it needs to be after.
  • Because there is cfg inheritance, we can keep track of them in one place (in propagate_doc_cfg.rs), meaning we don't need to copy an item's attributes to its children anymore. Only exception: impl items. For them we clone only cfg attributes.
  • propagate_doc_cfg.rs is also now much simpler, much less need to keep track of parents, since everything we need is handled by the new CfgInfo type.
  • I also suspect that Cfg::simplify_with could either be removed or at least used directly into propagate_doc_cfg.rs when we compute cfgs. Considering how big the PR already is, I'll do it in a follow-up.

I didn't remove the doc_cfg* features in this PR because some dependencies used in rustc (like stdarch) are using it, so we need to have a nightly released with this PR before I can switch to the new feature.

r? ghost

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Mar 24, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

What remains to be done:

I'd also want to block the stabilization on landing #138844 to avoid a stable rustdoc feature relying on externally observable hacks in rustc.
The crater run in #138844 returned mostly clean, so I expect it to land soon.

@GuillaumeGomez
Copy link
Member Author

Noted! And that will be a nice improvement, thanks!

Just one thing left for the cfg expansion missing: #[cfg_attr(blabla, derive(Debug))]. In this case, the cfg is not kept in the generated derive items. It's been in my TODO list for a long time now. ^^'

@petrochenkov
Copy link
Contributor

Just one thing left for the cfg expansion missing: #[cfg_attr(blabla, derive(Debug))]

Do you mean like in #138515? :)

@GuillaumeGomez
Copy link
Member Author

You're my hero! Gonna need to handle this new attribute then. :)

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 25, 2025

☔ The latest upstream changes (presumably #138923) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez GuillaumeGomez force-pushed the rfc-3631 branch 2 times, most recently from d88598f to db25eea Compare March 27, 2025 10:18
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Mar 27, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 27, 2025

☔ The latest upstream changes (presumably #138927) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez GuillaumeGomez force-pushed the rfc-3631 branch 2 times, most recently from b8cb424 to b581ce1 Compare March 28, 2025 23:54
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the rfc-3631 branch 4 times, most recently from 71369a1 to fbee8a9 Compare April 1, 2025 15:52
@rust-log-analyzer

This comment has been minimized.

Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 29, 2025
…mease

Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`

Tracking issue: rust-lang#43781

The `doc_auto_cfg` and `doc_cfg_hide` features were removed in a recent nightly (by rust-lang#138907).
I believe that the rustc version numbers at which the features were declared to be removed were incorrect, however, and should both be "1.92" (±1). As evidence in favour of this, the error we get from using this was:

```text
error[E0557]: feature has been removed
  --> src/lib.rs:22:29
   |
22 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in 1.58.0; see <rust-lang#138907> for more information
   = note: merged into `doc_cfg`
```

Note especially the "removed in 1.58" claim. Further evidence is found in the comment further up this file: https://github.com/rust-lang/rust/blob/4ffeda10e10d4fa0c8edbd0dd9642d8ae7d3e66e/compiler/rustc_feature/src/removed.rs#L49-L53

I've chosen 1.92 as that was the milestone which rust-lang#138907 was added to.

cc `@GuillaumeGomez`
mbrobbel added a commit to substrait-io/substrait-rs that referenced this pull request Sep 29, 2025
rust-timer added a commit that referenced this pull request Sep 29, 2025
Rollup merge of #147123 - DJMcNab:doc_cfg_merge_version, r=fmease

Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`

Tracking issue: #43781

The `doc_auto_cfg` and `doc_cfg_hide` features were removed in a recent nightly (by #138907).
I believe that the rustc version numbers at which the features were declared to be removed were incorrect, however, and should both be "1.92" (±1). As evidence in favour of this, the error we get from using this was:

```text
error[E0557]: feature has been removed
  --> src/lib.rs:22:29
   |
22 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in 1.58.0; see <#138907> for more information
   = note: merged into `doc_cfg`
```

Note especially the "removed in 1.58" claim. Further evidence is found in the comment further up this file: https://github.com/rust-lang/rust/blob/4ffeda10e10d4fa0c8edbd0dd9642d8ae7d3e66e/compiler/rustc_feature/src/removed.rs#L49-L53

I've chosen 1.92 as that was the milestone which #138907 was added to.

cc `@GuillaumeGomez`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 29, 2025
…_from_attrs, r=lolbinarycat

Remove one loop in `extract_cfg_from_attrs`

Follow-up of rust-lang#138907.

r? lolbinarycat
github-merge-queue bot pushed a commit to linebender/fearless_simd that referenced this pull request Sep 29, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 29, 2025
…_from_attrs, r=lolbinarycat

Remove one loop in `extract_cfg_from_attrs`

Follow-up of rust-lang#138907.

r? lolbinarycat
/// Allows deriving traits as per `SmartPointer` specification
(removed, derive_smart_pointer, "1.84.0", Some(123430), Some("replaced by `CoercePointee`"), 131284),
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(removed, doc_auto_cfg, "1.58.0", Some(43781), Some("merged into `doc_cfg`"), 138907),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the correct version? It generates an error message like:

error[E0557]: feature has been removed
 --> zeroize/src/lib.rs:2:29
  |
2 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
  |                             ^^^^^^^^^^^^ feature has been removed
  |
  = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/138907> for more information
  = note: merged into `doc_cfg`

Seems like it was added in 1.58.0, not removed in 1.58.0...

Copy link
Member

Choose a reason for hiding this comment

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

Already fixed by #147123 which is gonna be in the next nightly.

tarcieri added a commit to tarcieri/typenum that referenced this pull request Sep 29, 2025
`doc_auto_cfg` was merged into `doc_cfg` in rust-lang/rust#138907
bryfox added a commit to foxglove/foxglove-sdk that referenced this pull request Sep 29, 2025
This renames the `doc_auto_cfg` feature, following
rust-lang/rust#138907. We install the latest
nightly build in CI for docs generation; developers will need to update
to at least 2025-09-28.
rust-timer added a commit that referenced this pull request Sep 30, 2025
Rollup merge of #147133 - GuillaumeGomez:rm-loop-extract_cfg_from_attrs, r=lolbinarycat

Remove one loop in `extract_cfg_from_attrs`

Follow-up of #138907.

r? lolbinarycat
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 30, 2025
…ore-stripping-items, r=lolbinarycat

[rustdoc] Move doc cfg propagation pass before items stripping passes

Follow-up of rust-lang#138907.

r? lolbinarycat
rust-timer added a commit that referenced this pull request Sep 30, 2025
Rollup merge of #147153 - GuillaumeGomez:doc-propagation-before-stripping-items, r=lolbinarycat

[rustdoc] Move doc cfg propagation pass before items stripping passes

Follow-up of #138907.

r? lolbinarycat
bobrik added a commit to bobrik/foundations that referenced this pull request Sep 30, 2025
```
error[E0557]: feature has been removed
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/socket2-0.6.0/src/lib.rs:57:29
   |
57 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in CURRENT_RUSTC_VERSION; see <rust-lang/rust#138907> for more information
   = note: merged into `doc_cfg`
```
bobrik added a commit to bobrik/foundations that referenced this pull request Sep 30, 2025
```
error[E0557]: feature has been removed
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/socket2-0.6.0/src/lib.rs:57:29
   |
57 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in CURRENT_RUSTC_VERSION; see <rust-lang/rust#138907> for more information
   = note: merged into `doc_cfg`
```
bobrik added a commit to bobrik/foundations that referenced this pull request Sep 30, 2025
Nightly fails due to a dependency:

```
error[E0557]: feature has been removed
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/socket2-0.6.0/src/lib.rs:57:29
   |
57 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in CURRENT_RUSTC_VERSION; see <rust-lang/rust#138907> for more information
   = note: merged into `doc_cfg`
```
Oyami-Srk added a commit to Oyami-Srk/socket2 that referenced this pull request Sep 30, 2025
`doc_auto_cfg` has been removed in the latest nightly, see
rust-lang/rust#138907. This feature
was merged into `doc_cfg`.

This fixes the rustdoc build in the latest nightly toolchain with
docsrs feature enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.