Open
Description
Consider the following code:
#[doc(cfg(feature="include_file"))]
pub mod include_file {
pub fn generated() {}
}
pub use include_file::*;
pub use include_file::generated;
pub use include_file::generated as renamed;
The produced documentation looks like this:
I think we should be showing the doc_cfg badge consistently here: either on all of the re-exports or none of them. I would probably lean towards "none" in this particular case, in part because it would be easier to implement properly situations where re-exports don't share the features of the modules that are being re-exported. For instance:
#[doc(cfg(feature="include_file"))]
pub mod include_file {
pub fn generated() {}
}
#[doc(cfg(feature="reexport_glob"))]
pub use include_file::*;
#[doc(cfg(feature="reexport_generated"))]
pub use include_file::generated;
#[doc(cfg(feature="reexport_renamed"))]
pub use include_file::generated as renamed;
which generates exactly the same documentation page as shown above. I believe in this case we should show exactly the specified cfg
badges, rather than attempting to infer from what items are being re-exported.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]`doc_cfg` does not have any effect on the re-exports[/-][+]`doc_cfg` does not have any effect on the re-export items[/+][-]`doc_cfg` does not have any effect on the re-export items[/-][+]`doc_cfg` does not have a correct effect on `use` items referencing other public items[/+]est31 commentedon May 7, 2021
I agree.
You can only use something from a module if the module is available, which means that if there are multiple implementations of a module gated by different cfg attributes, but the use is free of any cfg, there should be no inheritance from the module that rustdoc ran for. Conversely, if the pub use contains a more restricted cfg than the module, you would want to document that restricted cfg instead of the module's cfg, because the use would simply not be available in some cases.
TLDR: pub use should only show what attributes on the use itself contain.
#[doc(cfg(…))]
doesn’t work properly with cross-crate re-exports. #88743#[doc(cfg(…))]
,#[doc(cfg_hide(…))]
anddoc_auto_cfg
#43781doc_cfg
should not merge cfgs on non-glob inlined reexports #112881Rollup merge of rust-lang#113091 - GuillaumeGomez:prevent-cfg-merge-r…
Unrolled build for rust-lang#113091