Skip to content

Commit ec84169

Browse files
Improve code comments and extend tests for doc_cfg feature
1 parent 491e1ef commit ec84169

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/librustdoc/clean/types.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,8 @@ pub(crate) fn hir_attr_lists<'a, I: IntoIterator<Item = &'a hir::Attribute>>(
10091009
/// This type keeps track of (doc) cfg information as we go down the item tree.
10101010
#[derive(Clone, Debug)]
10111011
pub(crate) struct CfgInfo {
1012-
/// List of `doc(auto_cfg(hide(...)))` cfgs.
1012+
/// List of currently active `doc(auto_cfg(hide(...)))` cfgs,minus currently active
1013+
/// `doc(auto_cfg(show(...)))` cfgs.
10131014
hidden_cfg: FxHashSet<Cfg>,
10141015
/// Current computed `cfg`. Each time we enter a new item, this field is updated as well while
10151016
/// taking into account the `hidden_cfg` information.
@@ -1265,7 +1266,8 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
12651266
Some(Arc::new(cfg_info.current_cfg.clone()))
12661267
}
12671268
} else {
1268-
// Since we always want to collect all `cfg` items, we remove the hidden ones afterward.
1269+
// If `doc(auto_cfg)` feature is enabled, we want to collect all `cfg` items, we remove the
1270+
// hidden ones afterward.
12691271
match cfg_info.current_cfg.strip_hidden(&cfg_info.hidden_cfg) {
12701272
None | Some(Cfg::True) => None,
12711273
Some(cfg) => Some(Arc::new(cfg)),

tests/rustdoc/doc_auto_cfg_reexports.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,16 @@ mod x {
2020
// 'Available on non-crate feature pistache only.'
2121
#[cfg(not(feature = "pistache"))]
2222
pub use crate::x::B;
23+
24+
// Now checking that `cfg`s are not applied on non-inlined reexports.
25+
pub mod pub_sub_mod {
26+
//@ has 'foo/pub_sub_mod/index.html'
27+
// There should be only only item with `cfg` note.
28+
//@ count - '//*[@class="stab portability"]' 1
29+
// And obviously the item should be "blabla".
30+
//@ has - '//dt' 'blablaNon-pistache'
31+
#[cfg(not(feature = "pistache"))]
32+
pub fn blabla() {}
33+
34+
pub use self::blabla as another;
35+
}

0 commit comments

Comments
 (0)