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