Skip to content

unused_features false positive on doc_cfg #154487

Closed

Description

@kpreid

Code

#![feature(doc_cfg)]

#[cfg(feature = "enabled_feature")]
pub fn foo() {}

Current output

warning: feature `doc_cfg` is declared but not used
 --> src/lib.rs:1:12
  |
1 | #![feature(doc_cfg)]
  |            ^^^^^^^
  |
  = note: `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default

warning: `scratchpad` (lib) generated 1 warning

Desired output

No warning

Rationale and extra context

The feature modifies rustdoc output regardless of whether #[doc(cfg)] is explicitly used in the source code, so it is not unused.

Rust Version

rustc 1.96.0-nightly (fda6d37bb 2026-03-27)
binary: rustc
commit-hash: fda6d37bb88ee12fd50fa54d15859f1f91b74f55
commit-date: 2026-03-27
host: aarch64-apple-darwin
release: 1.96.0-nightly
LLVM version: 22.1.2

Anything else?

@rustbot label +F-doc_cfg

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 28, 2026
  2. Ko496-glitch commented on Mar 29, 2026

    @Ko496-glitch
    Contributor

    @kpreid hey can i work on this, I am starting to work on diagnostic issues so i can get use to rust env and clippy

  3. kpreid commented on Mar 29, 2026

    @kpreid
    ContributorAuthor

    You don’t need my permission or recommendation to work on this issue.

  4. mu001999 commented on Mar 30, 2026

    @mu001999
    Member

    Seems doc_cfg is only checked in librustdoc

  5. self-assigned this
    on Apr 13, 2026
  6. added a commit that references this issue on Apr 14, 2026
    ec3a6b4
  7. added a commit that references this issue on Apr 14, 2026
    15e9f2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsF-doc_cfg`#![feature(doc_cfg)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions