rust-lang/rust

Inconsistent default display of doc(cfg(...)) on impls of empty traits

dtolnay opened this issue · 5 comments

#![feature(doc_cfg)]

pub struct S;

#[doc(cfg(feature = "traits"))]
impl Eq for S {}

#[doc(cfg(feature = "traits"))]
impl PartialEq for S {
    fn eq(&self, _rhs: &Self) -> bool {
        true
    }
}

cargo doc renders this as follows. Notice that the blue banner appears for Eq (I guess because the trait is empty) but not for PartialEq. I believe that it should consistently appear for neither Eq nor PartialEq, or both Eq and PartialEq.


Expanding the [+] next to impl PartialEq shows the other blue banner but this issue is about the default appearance on page load.


Mentioning doc(cfg(...)) tracking issue #43781.
Mentioning @GuillaumeGomez @Nemo157

Ohh, the collapse settings are fun; I never noticed this in #78678 because I have rustdoc-collapse: true which seems to imply not collapsing the trait implementations. Clearing that setting from local storage, or if it's set to false does this; I think it should be possible to make it so that having this block there either ignores collapsing so it shows always, (though this may be inconsistent with how it works with functions), or make it default to uncollapsing the trait.

(Something else to check at the same time: what happens with JS disabled)

Nothing is collapsed when JS is disabled. :)

I'll take a look tomorrow.

Nothing is collapsed when JS is disabled. :)

The [+] Show hidden undocumented items toggle, and the items it toggles, are hidden when JS is disabled.

Hum... I suppose it's a new issue then. Something to add in noscript.css.