-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: doc_cfg
hints not shown on reexports from private modules
#83428
Comments
This also affects re-exports of entire crates. Unfortunately there the fix is not clear at all, since the "parent" crate is obviously not guaranteed to have the same features as the crate being re-exported. |
@jplatte Within the same crate as well; it's not about the features that are enabled (though it is relevant which are available) but about the combined That's necessary to cleanly solve crate reexports, since you effectively want to ensure that the top-level crate feature |
I wonder if this is just an ordering issue of the passes: rust/src/librustdoc/passes/mod.rs Lines 85 to 87 in 7807a69
The private modules have disappeared by the point where we pass all the |
@Nemo157 Thanks for the suggestion - I moved |
I observe this on public items as well: pub mod foo {
#![doc(cfg(feature = "foo"))]
pub struct Foo;
}
#[doc(cfg(feature = "foo"))]
pub use foo::Foo; Does not show the badge at re-exports. |
So from the following code: #[doc(cfg(feature = "foobar"))]
mod imp_priv {
/// Feature on `struct` in private module is never shown
pub struct BarPriv {}
impl BarPriv {
/// Oddly enough the feature guard _is_ shown here
pub fn test() {}
}
}
#[doc(cfg(feature = "foobar"))]
pub use crate::imp_priv::*;
|
From gtk-rs/gir#1079
Given the following Rust code with in-line annotations of the expected behaviour:
On:
The issue
rustdoc
does not seem to be able to generate feature requirement labels on types in private modules (mod imp_priv
) that are publicly reexported (pub use crate::imp_priv::*;
). The labels do not show up on the module overview norstruct
page, but do propagate into items like functions for the given type.Observed
This renders the
BarPriv
type without any feature requirement, neither in the module overview:Nor on the
struct
page:Note that the label is propagated onto
pub fn test() {}
(does not have an explicit#[doc(cfg())]
),rustdoc
at least understood that!Expected output
It is supposed to render the feature requirement for
foobar
likeBar
, both in the module overview above as on thestruct
page:Bonus
It seems tricky to combine feature requirements on the
mod
andpub use
reexport. In the case above they are the same, but what if:The type is only publicly available when
foo
andbar
are specified. Specifyingfoo
is fine but makes the contents ofpriv
unreachable through the current module, specifying onlybar
should result in a "modulepriv
not found" error.CC @GuillaumeGomez
The text was updated successfully, but these errors were encountered: