Skip to content

Commit

Permalink
Exclude cfg "doc" and "doctest" from feature doc_auto_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Jun 15, 2022
1 parent 9aa1ccd commit 713578b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
})
.collect::<Vec<_>>()
})
.chain([Cfg::Cfg(sym::test, None)].into_iter())
.chain(
[Cfg::Cfg(sym::test, None), Cfg::Cfg(sym::doc, None), Cfg::Cfg(sym::doctest, None)]
.into_iter(),
)
.collect();

self.cx.cache.exact_paths = self.exact_paths;
Expand Down
25 changes: 15 additions & 10 deletions src/test/rustdoc/doc-auto-cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@
#![crate_name = "foo"]

// @has foo/fn.foo.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-doctest'
#[cfg(not(doctest))]
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-meowmeow'
#[cfg(not(meowmeow))]
pub fn foo() {}

// @has foo/fn.bar.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test'
#[cfg(any(test, doc))]
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doctest'
#[cfg(any(meowmeow, test, doc, doctest))]
pub fn bar() {}

// @has foo/fn.appear_1.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test'
#[cfg(any(doc, not(test)))]
#[cfg(any(meowmeow, doc, not(test)))]
pub fn appear_1() {} // issue #98065

// @has foo/fn.appear_2.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test'
#[cfg(any(doc, all(test)))]
#[cfg(any(meowmeow, doc, all(test)))]
pub fn appear_2() {} // issue #98065

// @has foo/fn.appear_3.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
#[cfg(any(doc, all()))]
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow'
// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc'
#[cfg(any(meowmeow, doc, all()))]
pub fn appear_3() {} // issue #98065

0 comments on commit 713578b

Please sign in to comment.