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?

2 Likes

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).

1 Like

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