Skip to content

doc_auto_cfg doesn't notice when a trait is impl'd in a module gated by a feature #101129

Closed
@nicholasbishop

Description

I noticed that after enabling doc_auto_cfg on a crate on docs.rs, some impls are missing the badge showing that a feature flag is needed to get that impl. For example, this impl is only available with the std feature enabled.

I think this is due to those impls being in a separate module, where the whole module is gated with a cfg(feature = "std"). Here's a minimalish example:

# In Cargo.toml:
[features]
coolstuff = []
// In src/lib.rs:
#![feature(doc_auto_cfg)]

pub struct S;
pub trait MyTrait1 {}
pub trait MyTrait2 {}

#[cfg(feature = "coolstuff")]
impl MyTrait1 for S {}

#[cfg(feature = "coolstuff")]
mod submod {
    use crate::{S, MyTrait2};
    impl MyTrait2 for S {}
}

Build with cargo +nightly doc -F coolstuff --open, then navigate to the page for struct S.

Under the "Trait Implementations" section, I see both impl MyTrait1 for S and impl MyTrait2 for S as expected. I also expect both to have a badge saying "Available on crate feature coolstuff only", but instead only MyTrait1 shows this badge.

image

Meta

rustc +nightly --version --verbose:

rustc 1.65.0-nightly (eaadb8947 2022-08-27)
binary: rustc
commit-hash: eaadb8947b850a025404082f6297766c4680a42a
commit-date: 2022-08-27
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc 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