rust-lang / rust-lang/rust

`#![feature(doc_cfg)]` uses feature name from dependency, not the feature that enables the method

Open
#157,523 7 comments 0 reactions 1 assignee View on GitHub

@GuillaumeGomez is already working on this.

Since Jun 6, 2026.

C-bug F-doc_cfg T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

https://github.com/jhpratt/doc-cfg-demo

Reproduction Steps

after cloning the repository

cd alpha
cargo +nightly doc --all-features

Outcome

The documentation for S::foo shows Available on crate feature `wrong-feature-name` only. It should show Available on crate feature `correct-feature-name` only. While correct for crate beta, a user viewing the docs of crate alpha does not care about that; they would want to see what feature of alpha is needed to enable the method in question.

Version

rustc 1.98.0-nightly (57d06900f 2026-05-27)

This bug has existed for years; I'd be very surprised if it was fixed since I last updated my nightly version.

Additional Details

Feel free to use the repository in any manner you'd like, including as a regression test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.