Doc_auto_cfg is gone: what am I supposed to do?

I'm the author of WinSafe crate. When generating its documentation, I always used doc_auto_cfg to tag the items which depend on cargo features, but currently the documentation is broken:

error[E0557]: feature has been removed
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
                            ^^^^^^^^^^^^ feature has been removed
note: merged into `doc_cfg`

Then I followed the recommendation and my lib.rs:

#![cfg_attr(docsrs, feature(doc_auto_cfg))]

is now:

#![cfg_attr(docsrs, feature(doc_cfg))]

but the output docs are wrong. Below are two screenshots: the old one at left (correct), and the new one on the right, with the tags messed up:

What am I supposed to do?

I am not familiar with its exact behavior, but I believe the feature flag change is just that doc_cfg and doc_auto_cfg are now combined; that is, doc_cfg now also enables the functionality doc_auto_cfg used to enable.

The change in output you are seeing, then, must be a bug in the auto cfg functionality. You should create a test case and report the bug.

As a workaround, you can try using the explicit #[doc(cfg)] to tell rustdoc what it should display:

#[cfg(feature = "ole")]
#[doc(cfg(feature = "ole"))]
struct IUnknown { ... }

@kpreid What's the repo I should fill an issue?

rustdoc is kept with the compiler in rust-lang/rust/src/librustdoc and so you should file rustdoc bugs there (you can use this template, in particular).

Just for the record, I filled an issue at the GitHub repo:

We're in February and doc_cfg is still broken, unfortunately.

So I found a temporary way to build the docs using the deceased doc_auto_cfg: using the last nightly channel which supported it: nightly-2025-09-27 (1.92.0).

How did I find that? Through pain.

This is the command line I'm using to build my docs:

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly-2025-09-27 doc --all-features

I'm trying to figure out how to enable building docs so the features items require show up like in this post, and it's unclear to me how this is supposed to work. Some advice online points to the now removed doc_auto_cfg.

Is there documentation I'm missing?

It's still an unstable feature, though it looks like it's on the path to stabilization. I expect its documentation to improve once it has stabilized.

The doc_auto_cfg is the "old" way to do it and is unavailable in more recent nightly builds. You should be using the doc_cfg feature nowadays. However, even if you do that, you can still run into problems due to dependencies still using doc_auto_cfg.

From my experience, most crates seem to have switched to doc_cfg, but it's not always the case that cargo will use updated crate. Using cargo update --dry-run --verbose you can see if crate upgrades are being held back due to MSRV constraints. If you run into doc_auto_cfg being unrecognized, then bump your rust-version to fulfill the requirements

How to use it:

  1. In your libs.rs, make sure you have:
    #![cfg_attr(docsrs, feature(doc_cfg))]
    
  2. Tag your items:
    #[cfg(feature = "tpool")]
    #[cfg_attr(docsrs, doc(cfg(feature = "tpool")))]
    pub fn run_ro_thrd<F>(&self, f: F) {
      // ..
    }
    
  3. Build docs locally:
    $ RUSTFLAGS="--cfg docsrs" RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
    
  4. To make docs.rs make use of them, tell it use use docsrs in Cargo.toml:
    [package.metadata.docs.rs]
    all-features = true
    rustdoc-args = ["--cfg", "docsrs"]
    

I was doing a few things wrong, thanks.

I didn't realize I had to tag my items individually. Is there no way too avoid this, it seems awfully redundant and error-prone, when I want to apply this to every item with a feature in the project. I can see wanting the ability to hide the feature notice for default features, or special cases, but I don't want that at the moment.

Also looks like I'm stuck until generic-array updates.

No, you do not have to tag items individually. The functionality of doc_auto_cfg is not gone; it is just part of doc_cfg now. With feature(doc_cfg), you get both automatic tagging and the ability to override it.

Sorry, I should have been clear: As @kpreid said, you do not need to do that. If you read the top of the thread, there appears to be a bug that causes some items to not be handled properly -- tagging them explicitly works around the problem.

This may be a crate that is held back due to a MSRV constraint. Are you using Edition 2024? If you run cargo update --dry-run --verbose, does it tell you that there are crates being held back due to MSRV?

I am using edition 2024, and I didn't notice anything about that package being held back due to MSRV.

I ran in an issue with generic-array not being updated from 0.14.7 to 0.14.9 because crypto-common v0.1.7 depends on that specific version. (Pin generic-array to v0.14.7 and release crypto-common v0.1.7 (#2088) · RustCrypto/traits@66a997c · GitHub)
As a workaround, it was possible to downgrade crypto-common to 0.1.6 and then upgrade generic-array to 0.14.9.

Follow up: this bug has been finally fixed :smiling_face_with_tear: