]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/doc-cfg.rs
Auto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay
[rust.git] / src / test / rustdoc / doc-cfg.rs
1 #![feature(doc_cfg)]
2 #![feature(target_feature, cfg_target_feature)]
3
4 // @has doc_cfg/struct.Portable.html
5 // @!has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' ''
6 // @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
7 // @has - '//*[@class="stab portability"]' 'This is supported on Unix and ARM only.'
8 pub struct Portable;
9
10 // @has doc_cfg/unix_only/index.html \
11 //  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
12 //  'This is supported on Unix only.'
13 // @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AARM\Z'
14 // @count - '//*[@class="stab portability"]' 2
15 #[doc(cfg(unix))]
16 pub mod unix_only {
17     // @has doc_cfg/unix_only/fn.unix_only_function.html \
18     //  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
19     //  'This is supported on Unix only.'
20     // @count - '//*[@class="stab portability"]' 1
21     pub fn unix_only_function() {
22         content::should::be::irrelevant();
23     }
24
25     // @has doc_cfg/unix_only/trait.ArmOnly.html \
26     //  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
27     //  'This is supported on Unix and ARM only.'
28     // @count - '//*[@class="stab portability"]' 2
29     #[doc(cfg(target_arch = "arm"))]
30     pub trait ArmOnly {
31         fn unix_and_arm_only_function();
32     }
33
34     impl ArmOnly for super::Portable {
35         fn unix_and_arm_only_function() {}
36     }
37 }
38
39 // tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
40 // item as well
41
42 // the portability header is different on the module view versus the full view
43 // @has doc_cfg/index.html
44 // @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\Aavx\Z'
45
46 // @has doc_cfg/fn.uses_target_feature.html
47 // @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
48 //        'This is supported with target feature avx only.'
49 #[target_feature(enable = "avx")]
50 pub unsafe fn uses_target_feature() {
51     content::should::be::irrelevant();
52 }
53
54 // @has doc_cfg/fn.uses_cfg_target_feature.html
55 // @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
56 //        'This is supported with target feature avx only.'
57 #[doc(cfg(target_feature = "avx"))]
58 pub fn uses_cfg_target_feature() {
59     uses_target_feature();
60 }