about summary refs log tree commit diff
path: root/tests/rustdoc/doc-cfg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rustdoc/doc-cfg')
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-hide.rs32
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs7
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-implicit.rs31
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs44
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-simplification.rs182
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs20
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-traits.rs124
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg.rs101
8 files changed, 541 insertions, 0 deletions
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs
new file mode 100644
index 00000000000..ceb1f99fae0
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs
@@ -0,0 +1,32 @@
+#![crate_name = "oud"]
+#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]
+
+#![doc(cfg_hide(feature = "solecism"))]
+
+//@ has 'oud/struct.Solecism.html'
+//@ count   - '//*[@class="stab portability"]' 0
+//@ compile-flags:--cfg feature="solecism"
+#[cfg(feature = "solecism")]
+pub struct Solecism;
+
+//@ has 'oud/struct.Scribacious.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature solecism'
+#[cfg(feature = "solecism")]
+#[doc(cfg(feature = "solecism"))]
+pub struct Scribacious;
+
+//@ has 'oud/struct.Hyperdulia.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia'
+//@ compile-flags:--cfg feature="hyperdulia"
+#[cfg(feature = "solecism")]
+#[cfg(feature = "hyperdulia")]
+pub struct Hyperdulia;
+
+//@ has 'oud/struct.Oystercatcher.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only'
+//@ compile-flags:--cfg feature="oystercatcher"
+#[cfg(all(feature = "solecism", feature = "oystercatcher"))]
+pub struct Oystercatcher;
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs
new file mode 100644
index 00000000000..b5b8d0f427b
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs
@@ -0,0 +1,7 @@
+//@ compile-flags:--cfg feature="worricow"
+#![crate_name = "xenogenous"]
+
+//@ has 'xenogenous/struct.Worricow.html'
+//@ count   - '//*[@class="stab portability"]' 0
+#[cfg(feature = "worricow")]
+pub struct Worricow;
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs
new file mode 100644
index 00000000000..69b10867ee3
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs
@@ -0,0 +1,31 @@
+#![crate_name = "funambulism"]
+#![feature(doc_auto_cfg, doc_cfg)]
+
+//@ has 'funambulism/struct.Disorbed.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature disorbed'
+//@ compile-flags:--cfg feature="disorbed"
+#[cfg(feature = "disorbed")]
+pub struct Disorbed;
+
+//@ has 'funambulism/struct.Aesthesia.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature aesthesia'
+//@ compile-flags:--cfg feature="aesthesia"
+#[doc(cfg(feature = "aesthesia"))]
+pub struct Aesthesia;
+
+//@ has 'funambulism/struct.Pliothermic.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' 'crate feature pliothermic'
+//@ compile-flags:--cfg feature="epopoeist"
+#[cfg(feature = "epopoeist")]
+#[doc(cfg(feature = "pliothermic"))]
+pub struct Pliothermic;
+
+//@ has 'funambulism/struct.Simillimum.html'
+//@ count   - '//*[@class="stab portability"]' 0
+//@ compile-flags:--cfg feature="simillimum"
+#[cfg(feature = "simillimum")]
+#[doc(cfg(all()))]
+pub struct Simillimum;
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs
new file mode 100644
index 00000000000..256e3b0015c
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs
@@ -0,0 +1,44 @@
+// https://github.com/rust-lang/rust/issues/79201
+#![crate_name="foo"]
+
+#![feature(doc_cfg)]
+
+//@ has 'foo/trait.Foo.html'
+//@ count   - '//*[@class="stab portability"]' 6
+//@ matches - '//*[@class="stab portability"]' 'crate feature foo-root'
+//@ matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod'
+//@ matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod'
+//@ matches - '//*[@class="stab portability"]' 'crate feature foo-fn'
+//@ matches - '//*[@class="stab portability"]' 'crate feature foo-method'
+
+pub trait Foo {}
+
+#[doc(cfg(feature = "foo-root"))]
+impl crate::Foo for usize {}
+
+#[doc(cfg(feature = "foo-public-mod"))]
+pub mod public {
+    impl crate::Foo for u8 {}
+}
+
+#[doc(cfg(feature = "foo-private-mod"))]
+mod private {
+    impl crate::Foo for u16 {}
+}
+
+#[doc(cfg(feature = "foo-const"))]
+const _: () = {
+    impl crate::Foo for u32 {}
+};
+
+#[doc(cfg(feature = "foo-fn"))]
+fn __() {
+    impl crate::Foo for u64 {}
+}
+
+#[doc(cfg(feature = "foo-method"))]
+impl dyn Foo {
+    fn __() {
+        impl crate::Foo for u128 {}
+    }
+}
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs
new file mode 100644
index 00000000000..ce70de289c6
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs
@@ -0,0 +1,182 @@
+#![crate_name = "globuliferous"]
+#![feature(doc_cfg)]
+
+//@ has 'globuliferous/index.html'
+//@ count   - '//*[@class="stab portability"]' 1
+//@ matches - '//*[@class="stab portability"]' '^ratel$'
+
+//@ has 'globuliferous/ratel/index.html'
+//@ count   - '//*[@class="stab portability"]' 8
+//@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+//@ matches - '//*[@class="stab portability"]' '^zoonosology$'
+//@ matches - '//*[@class="stab portability"]' '^yusho$'
+//@ matches - '//*[@class="stab portability"]' '^nunciative$'
+//@ matches - '//*[@class="stab portability"]' '^thionic$'
+//@ matches - '//*[@class="stab portability"]' '^zincic$'
+//@ matches - '//*[@class="stab portability"]' '^cosmotellurian$'
+//@ matches - '//*[@class="stab portability"]' '^aposiopesis$'
+#[doc(cfg(feature = "ratel"))]
+pub mod ratel {
+    //@ has 'globuliferous/ratel/fn.ovicide.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    pub fn ovicide() {}
+
+    //@ has 'globuliferous/ratel/fn.zoonosology.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zoonosology'
+    #[doc(cfg(feature = "zoonosology"))]
+    pub fn zoonosology() {}
+
+    //@ has 'globuliferous/ratel/constant.DIAGRAPHICS.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    pub const DIAGRAPHICS: () = ();
+
+    //@ has 'globuliferous/ratel/constant.YUSHO.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and yusho'
+    #[doc(cfg(feature = "yusho"))]
+    pub const YUSHO: () = ();
+
+    //@ has 'globuliferous/ratel/static.KEYBUGLE.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    pub static KEYBUGLE: () = ();
+
+    //@ has 'globuliferous/ratel/static.NUNCIATIVE.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and nunciative'
+    #[doc(cfg(feature = "nunciative"))]
+    pub static NUNCIATIVE: () = ();
+
+    //@ has 'globuliferous/ratel/type.Wrick.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    pub type Wrick = ();
+
+    //@ has 'globuliferous/ratel/type.Thionic.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and thionic'
+    #[doc(cfg(feature = "thionic"))]
+    pub type Thionic = ();
+
+    //@ has 'globuliferous/ratel/struct.Eventration.html'
+    //@ count   - '//*[@class="stab portability"]' 1
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    pub struct Eventration;
+
+    //@ has 'globuliferous/ratel/struct.Zincic.html'
+    //@ count   - '//*[@class="stab portability"]' 2
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zincic'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature rutherford'
+    #[doc(cfg(feature = "zincic"))]
+    pub struct Zincic {
+        pub rectigrade: (),
+
+        #[doc(cfg(feature = "rutherford"))]
+        pub rutherford: (),
+    }
+
+    //@ has 'globuliferous/ratel/enum.Cosmotellurian.html'
+    //@ count   - '//*[@class="stab portability"]' 10
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and cosmotellurian'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature biotaxy'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature xiphopagus'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature juxtapositive'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature fuero'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature palaeophile'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth'
+    //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and xanthocomic'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth'
+    //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and whosoever'
+    #[doc(cfg(feature = "cosmotellurian"))]
+    pub enum Cosmotellurian {
+        Groundsel {
+            jagger: (),
+
+            #[doc(cfg(feature = "xiphopagus"))]
+            xiphopagus: (),
+        },
+
+        #[doc(cfg(feature = "biotaxy"))]
+        Biotaxy {
+            glossography: (),
+
+            #[doc(cfg(feature = "juxtapositive"))]
+            juxtapositive: (),
+        },
+    }
+
+    impl Cosmotellurian {
+        pub fn uxoricide() {}
+
+        #[doc(cfg(feature = "fuero"))]
+        pub fn fuero() {}
+
+        pub const MAMELLE: () = ();
+
+        #[doc(cfg(feature = "palaeophile"))]
+        pub const PALAEOPHILE: () = ();
+    }
+
+    #[doc(cfg(feature = "broadcloth"))]
+    impl Cosmotellurian {
+        pub fn trabeculated() {}
+
+        #[doc(cfg(feature = "xanthocomic"))]
+        pub fn xanthocomic() {}
+
+        pub const BRACHIFEROUS: () = ();
+
+        #[doc(cfg(feature = "whosoever"))]
+        pub const WHOSOEVER: () = ();
+    }
+
+    //@ has 'globuliferous/ratel/trait.Gnotobiology.html'
+    //@ count   - '//*[@class="stab portability"]' 4
+    //@ matches - '//*[@class="stab portability"]' 'crate feature ratel'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature unzymotic'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature summate'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature unctuous'
+    pub trait Gnotobiology {
+        const XYLOTHERAPY: ();
+
+        #[doc(cfg(feature = "unzymotic"))]
+        const UNZYMOTIC: ();
+
+        type Lepadoid;
+
+        #[doc(cfg(feature = "summate"))]
+        type Summate;
+
+        fn decalcomania();
+
+        #[doc(cfg(feature = "unctuous"))]
+        fn unctuous();
+    }
+
+    //@ has 'globuliferous/ratel/trait.Aposiopesis.html'
+    //@ count   - '//*[@class="stab portability"]' 4
+    //@ matches - '//*[@class="stab portability"]' 'crate features ratel and aposiopesis'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature umbracious'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature uakari'
+    //@ matches - '//*[@class="stab portability"]' 'crate feature rotograph'
+    #[doc(cfg(feature = "aposiopesis"))]
+    pub trait Aposiopesis {
+        const REDHIBITION: ();
+
+        #[doc(cfg(feature = "umbracious"))]
+        const UMBRACIOUS: ();
+
+        type Ophthalmoscope;
+
+        #[doc(cfg(feature = "uakari"))]
+        type Uakari;
+
+        fn meseems();
+
+        #[doc(cfg(feature = "rotograph"))]
+        fn rotograph();
+    }
+}
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs
new file mode 100644
index 00000000000..b66e86e36af
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs
@@ -0,0 +1,20 @@
+//@ only-x86_64
+//@ compile-flags:--test
+//@ should-fail
+
+// #49723: rustdoc didn't add target features when extracting or running doctests
+
+#![feature(doc_cfg)]
+
+/// Foo
+///
+/// # Examples
+///
+/// ```
+/// #![feature(cfg_target_feature)]
+///
+/// #[cfg(target_feature = "sse")]
+/// assert!(false);
+/// ```
+#[doc(cfg(target_feature = "sse"))]
+pub unsafe fn foo() {}
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-traits.rs b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs
new file mode 100644
index 00000000000..1256a7ae2c1
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs
@@ -0,0 +1,124 @@
+#![crate_name = "myrmecophagous"]
+#![feature(doc_cfg, associated_type_defaults)]
+
+//@ has 'myrmecophagous/index.html'
+//@ count   - '//*[@class="stab portability"]' 2
+//@ matches - '//*[@class="stab portability"]' '^jurisconsult$'
+//@ matches - '//*[@class="stab portability"]' '^quarter$'
+
+pub trait Lea {}
+
+//@ has 'myrmecophagous/trait.Vortoscope.html'
+//@ count   - '//*[@class="stab portability"]' 6
+//@ matches - '//*[@class="stab portability"]' 'crate feature zibib'
+//@ matches - '//*[@class="stab portability"]' 'crate feature poriform'
+//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia'
+//@ matches - '//*[@class="stab portability"]' 'crate feature lea'
+//@ matches - '//*[@class="stab portability"]' 'crate feature unit'
+//@ matches - '//*[@class="stab portability"]' 'crate feature quarter'
+pub trait Vortoscope {
+    type Batology = ();
+
+    #[doc(cfg(feature = "zibib"))]
+    type Zibib = ();
+
+    const YAHRZEIT: () = ();
+
+    #[doc(cfg(feature = "poriform"))]
+    const PORIFORM: () = ();
+
+    fn javanais() {}
+
+    #[doc(cfg(feature = "ethopoeia"))]
+    fn ethopoeia() {}
+}
+
+#[doc(cfg(feature = "lea"))]
+impl<T: Lea> Vortoscope for T {}
+
+#[doc(cfg(feature = "unit"))]
+impl Vortoscope for () {}
+
+//@ has 'myrmecophagous/trait.Jurisconsult.html'
+//@ count   - '//*[@class="stab portability"]' 7
+//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult'
+//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy'
+//@ matches - '//*[@class="stab portability"]' 'crate feature boodle'
+//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch'
+//@ matches - '//*[@class="stab portability"]' 'crate feature lea'
+//@ matches - '//*[@class="stab portability"]' 'crate feature unit'
+//@ matches - '//*[@class="stab portability"]' 'crate feature quarter'
+#[doc(cfg(feature = "jurisconsult"))]
+pub trait Jurisconsult {
+    type Urbanist = ();
+
+    #[doc(cfg(feature = "lithomancy"))]
+    type Lithomancy = ();
+
+    const UNIFILAR: () = ();
+
+    #[doc(cfg(feature = "boodle"))]
+    const BOODLE: () = ();
+
+    fn mersion() {}
+
+    #[doc(cfg(feature = "mistetch"))]
+    fn mistetch() {}
+}
+
+#[doc(cfg(feature = "lea"))]
+impl<T: Lea> Jurisconsult for T {}
+
+#[doc(cfg(feature = "unit"))]
+impl Jurisconsult for () {}
+
+//@ has 'myrmecophagous/struct.Ultimogeniture.html'
+//@ count   - '//*[@class="stab portability"]' 8
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature zibib'
+//@ matches - '//*[@class="stab portability"]' 'crate feature poriform'
+//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia'
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult'
+//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy'
+//@ matches - '//*[@class="stab portability"]' 'crate feature boodle'
+//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch'
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature copy'
+#[derive(Clone)]
+pub struct Ultimogeniture;
+
+impl Vortoscope for Ultimogeniture {}
+
+#[doc(cfg(feature = "jurisconsult"))]
+impl Jurisconsult for Ultimogeniture {}
+
+#[doc(cfg(feature = "copy"))]
+impl Copy for Ultimogeniture {}
+
+//@ has 'myrmecophagous/struct.Quarter.html'
+//@ count   - '//*[@class="stab portability"]' 9
+//@ matches - '//*[@class="stab portability"]' 'crate feature quarter'
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature zibib'
+//@ matches - '//*[@class="stab portability"]' 'crate feature poriform'
+//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia'
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult'
+//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy'
+//@ matches - '//*[@class="stab portability"]' 'crate feature boodle'
+//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch'
+//
+//@ matches - '//*[@class="stab portability"]' 'crate feature copy'
+#[doc(cfg(feature = "quarter"))]
+#[derive(Clone)]
+pub struct Quarter;
+
+#[doc(cfg(feature = "quarter"))]
+impl Vortoscope for Quarter {}
+
+#[doc(cfg(all(feature = "jurisconsult", feature = "quarter")))]
+impl Jurisconsult for Quarter {}
+
+#[doc(cfg(all(feature = "copy", feature = "quarter")))]
+impl Copy for Quarter {}
diff --git a/tests/rustdoc/doc-cfg/doc-cfg.rs b/tests/rustdoc/doc-cfg/doc-cfg.rs
new file mode 100644
index 00000000000..652c8419b4f
--- /dev/null
+++ b/tests/rustdoc/doc-cfg/doc-cfg.rs
@@ -0,0 +1,101 @@
+#![feature(doc_cfg)]
+#![feature(target_feature, cfg_target_feature)]
+
+//@ has doc_cfg/struct.Portable.html
+//@ !has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' ''
+//@ has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
+//@ has - '//*[@class="stab portability"]' 'Available on Unix and ARM only.'
+//@ has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()'
+//@ has - '//*[@class="stab portability"]' 'Available on WASI and WebAssembly only.'
+pub struct Portable;
+
+//@ has doc_cfg/unix_only/index.html \
+//  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//  'Available on Unix only.'
+//@ matches - '//dt//*[@class="stab portability"]' '\AARM\Z'
+//@ count - '//*[@class="stab portability"]' 2
+#[doc(cfg(unix))]
+pub mod unix_only {
+    //@ has doc_cfg/unix_only/fn.unix_only_function.html \
+    //  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'Available on Unix only.'
+    //@ count - '//*[@class="stab portability"]' 1
+    pub fn unix_only_function() {
+        content::should::be::irrelevant();
+    }
+
+    //@ has doc_cfg/unix_only/trait.ArmOnly.html \
+    //  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'Available on Unix and ARM only.'
+    //@ count - '//*[@class="stab portability"]' 1
+    #[doc(cfg(target_arch = "arm"))]
+    pub trait ArmOnly {
+        fn unix_and_arm_only_function();
+    }
+
+    #[doc(cfg(target_arch = "arm"))]
+    impl ArmOnly for super::Portable {
+        fn unix_and_arm_only_function() {}
+    }
+}
+
+//@ has doc_cfg/wasi_only/index.html \
+//  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//  'Available on WASI only.'
+//@ matches - '//dt//*[@class="stab portability"]' '\AWebAssembly\Z'
+//@ count - '//*[@class="stab portability"]' 2
+#[doc(cfg(target_os = "wasi"))]
+pub mod wasi_only {
+    //@ has doc_cfg/wasi_only/fn.wasi_only_function.html \
+    //  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'Available on WASI only.'
+    //@ count - '//*[@class="stab portability"]' 1
+    pub fn wasi_only_function() {
+        content::should::be::irrelevant();
+    }
+
+    //@ has doc_cfg/wasi_only/trait.Wasm32Only.html \
+    //  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'Available on WASI and WebAssembly only.'
+    //@ count - '//*[@class="stab portability"]' 1
+    #[doc(cfg(target_arch = "wasm32"))]
+    pub trait Wasm32Only {
+        fn wasi_and_wasm32_only_function();
+    }
+
+    #[doc(cfg(target_arch = "wasm32"))]
+    impl Wasm32Only for super::Portable {
+        fn wasi_and_wasm32_only_function() {}
+    }
+}
+
+// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
+// item as well
+
+// the portability header is different on the module view versus the full view
+//@ has doc_cfg/index.html
+//@ matches - '//dt//*[@class="stab portability"]' '\Aavx\Z'
+
+//@ has doc_cfg/fn.uses_target_feature.html
+//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//        'Available with target feature avx only.'
+#[target_feature(enable = "avx")]
+pub unsafe fn uses_target_feature() {
+    content::should::be::irrelevant();
+}
+
+//@ has doc_cfg/fn.uses_cfg_target_feature.html
+//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//        'Available with target feature avx only.'
+#[doc(cfg(target_feature = "avx"))]
+pub fn uses_cfg_target_feature() {
+    uses_target_feature();
+}
+
+// multiple attributes should be allowed
+//@ has doc_cfg/fn.multiple_attrs.html \
+//  '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//  'Available on x and y and z only.'
+#[doc(cfg(x))]
+#[doc(cfg(y), cfg(z))]
+pub fn multiple_attrs() {}