Skip to content

Commit e27eba3

Browse files
committed
Add a test in src/test/rustdoc/doc-cfg.rs
1 parent b89e828 commit e27eba3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/rustdoc/doc-cfg.rs

+32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// @!has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' ''
66
// @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
77
// @has - '//*[@class="stab portability"]' 'This is supported on Unix and ARM only.'
8+
// @has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()'
9+
// @has - '//*[@class="stab portability"]' 'This is supported on WASI and WebAssembly only.'
810
pub struct Portable;
911

1012
// @has doc_cfg/unix_only/index.html \
@@ -37,6 +39,36 @@ pub mod unix_only {
3739
}
3840
}
3941

42+
// @has doc_cfg/wasi_only/index.html \
43+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
44+
// 'This is supported on WASI only.'
45+
// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AWebAssembly\Z'
46+
// @count - '//*[@class="stab portability"]' 2
47+
#[doc(cfg(target_os = "wasi"))]
48+
pub mod wasi_only {
49+
// @has doc_cfg/wasi_only/fn.wasi_only_function.html \
50+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
51+
// 'This is supported on WASI only.'
52+
// @count - '//*[@class="stab portability"]' 1
53+
pub fn wasi_only_function() {
54+
content::should::be::irrelevant();
55+
}
56+
57+
// @has doc_cfg/wasi_only/trait.Wasm32Only.html \
58+
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
59+
// 'This is supported on WASI and WebAssembly only.'
60+
// @count - '//*[@class="stab portability"]' 1
61+
#[doc(cfg(target_arch = "wasm32"))]
62+
pub trait Wasm32Only {
63+
fn wasi_and_wasm32_only_function();
64+
}
65+
66+
#[doc(cfg(target_arch = "wasm32"))]
67+
impl Wasm32Only for super::Portable {
68+
fn wasi_and_wasm32_only_function() {}
69+
}
70+
}
71+
4072
// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
4173
// item as well
4274

0 commit comments

Comments
 (0)