Skip to content

Commit b3fb0d1

Browse files
add target_feature items to doc_cfg rustdoc test
1 parent 017bfc3 commit b3fb0d1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/rustdoc/doc-cfg.rs

+24
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(doc_cfg)]
12+
#![feature(target_feature, cfg_target_feature)]
1213

1314
// @has doc_cfg/struct.Portable.html
1415
// @!has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' ''
@@ -45,3 +46,26 @@ pub mod unix_only {
4546
fn unix_and_arm_only_function() {}
4647
}
4748
}
49+
50+
// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
51+
// item as well
52+
53+
// the portability header is different on the module view versus the full view
54+
// @has doc_cfg/index.html
55+
// @matches - '//*[@class=" module-item"]//*[@class="stab portability"]' '\Aavx\Z'
56+
57+
// @has doc_cfg/fn.uses_target_feature.html
58+
// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
59+
// 'This is supported with target feature avx only.'
60+
#[target_feature(enable = "avx")]
61+
pub unsafe fn uses_target_feature() {
62+
content::should::be::irrelevant();
63+
}
64+
65+
// @has doc_cfg/fn.uses_cfg_target_feature.html
66+
// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
67+
// 'This is supported with target feature avx only.'
68+
#[doc(cfg(target_feature = "avx"))]
69+
pub fn uses_cfg_target_feature() {
70+
uses_target_feature();
71+
}

0 commit comments

Comments
 (0)