]> git.proxmox.com Git - rustc.git/blob - src/test/rustdoc/doc-cfg.rs
Update upstream source from tag 'upstream/1.50.0+dfsg1'
[rustc.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="item-info"]/*[@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="item-info"]/*[@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="item-info"]/*[@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="item-info"]/*[@class="stab portability"]' \
27 // 'This is supported on Unix and ARM only.'
28 // @count - '//*[@class="stab portability"]' 1
29 #[doc(cfg(target_arch = "arm"))]
30 pub trait ArmOnly {
31 fn unix_and_arm_only_function();
32 }
33
34 #[doc(cfg(target_arch = "arm"))]
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="item-info"]/*[@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="item-info"]/*[@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 }