]> git.proxmox.com Git - rustc.git/blob - src/test/rustdoc/doc-cfg.rs
Merge branch 'debian/experimental' into debian/sid
[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 // @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.'
10 pub struct Portable;
11
12 // @has doc_cfg/unix_only/index.html \
13 // '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
14 // 'This is supported on Unix only.'
15 // @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AARM\Z'
16 // @count - '//*[@class="stab portability"]' 2
17 #[doc(cfg(unix))]
18 pub mod unix_only {
19 // @has doc_cfg/unix_only/fn.unix_only_function.html \
20 // '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
21 // 'This is supported on Unix only.'
22 // @count - '//*[@class="stab portability"]' 1
23 pub fn unix_only_function() {
24 content::should::be::irrelevant();
25 }
26
27 // @has doc_cfg/unix_only/trait.ArmOnly.html \
28 // '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
29 // 'This is supported on Unix and ARM only.'
30 // @count - '//*[@class="stab portability"]' 1
31 #[doc(cfg(target_arch = "arm"))]
32 pub trait ArmOnly {
33 fn unix_and_arm_only_function();
34 }
35
36 #[doc(cfg(target_arch = "arm"))]
37 impl ArmOnly for super::Portable {
38 fn unix_and_arm_only_function() {}
39 }
40 }
41
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
72 // tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
73 // item as well
74
75 // the portability header is different on the module view versus the full view
76 // @has doc_cfg/index.html
77 // @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\Aavx\Z'
78
79 // @has doc_cfg/fn.uses_target_feature.html
80 // @has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
81 // 'This is supported with target feature avx only.'
82 #[target_feature(enable = "avx")]
83 pub unsafe fn uses_target_feature() {
84 content::should::be::irrelevant();
85 }
86
87 // @has doc_cfg/fn.uses_cfg_target_feature.html
88 // @has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
89 // 'This is supported with target feature avx only.'
90 #[doc(cfg(target_feature = "avx"))]
91 pub fn uses_cfg_target_feature() {
92 uses_target_feature();
93 }