rustdoc: doc_cfg on trait impls needs more visibility
yaahc opened this issue · 1 comments
yaahc commented
I'm trying to annotate all the parts of a crate that are available based on feature flags and I've had the following experience when annotating a trait impl.
#[cfg(feature = "registry")]
#[cfg_attr(docsrs, doc(cfg(feature = "registry")))]
impl<'a, L, S> LookupSpan<'a> for Layered<L, S>
where
S: Subscriber + LookupSpan<'a>,
{
type Data = S::Data;
fn span_data(&'a self, id: &span::Id) -> Option<Self::Data> {
self.inner.span_data(id)
}
}This is what it looks like with the default visibility
After expanding a single [+]
Fully expanded
Ideally the default visibility with everything minimized should still indicate that this trait impl is dependent upon the given feature.
WaffleLapkin commented
(except I'm missing something) On the latest nightly the messages couldn't be seen at all
Cargo version
% cargo --version
cargo 1.46.0-nightly (c26576f9a 2020-06-23)The code:
#![cfg_attr(docsrs, feature(doc_cfg))]
pub struct SomeType;
pub trait SomeTrait {
type SomeAssoc;
fn some_method(&self);
}
#[cfg(feature = "some_feature")]
#[cfg_attr(docsrs, doc(cfg(feature = "some_feature")))]
impl SomeTrait for SomeType {
type SomeAssoc = i32;
fn some_method(&self) {}
}The command:
% RUSTDOCFLAGS="--cfg docsrs" cargo doc --features "some_feature" --open



