about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-03-02 21:23:18 +0900
committerGitHub <noreply@github.com>2021-03-02 21:23:18 +0900
commit543ef7f13c03c495d31b42dde32c7ddce0d2fb15 (patch)
treed7a73ac633b0609e08823f463c2e11f8e22bcda2 /src
parent906e53520505acbb3948be594135c60a16b68b81 (diff)
parente27eba339772fd9081ed3f20ec18a7e8ab79fefd (diff)
Rollup merge of #82593 - sunfishcode:wasi-docs, r=alexcrichton
Teach rustdoc how to display WASI.

As a followup to [this comment] in #82420, this patch teaches rustdoc
how to display WASI.

[this comment]: https://github.com/rust-lang/rust/pull/82420#issuecomment-784523826

r? `@alexcrichton`
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/cfg.rs1
-rw-r--r--src/librustdoc/clean/cfg/tests.rs4
-rw-r--r--src/test/rustdoc/doc-cfg.rs32
3 files changed, 37 insertions, 0 deletions
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index c544d1f41ce..02adccef594 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -483,6 +483,7 @@ impl<'a> fmt::Display for Display<'a> {
                         "openbsd" => "OpenBSD",
                         "redox" => "Redox",
                         "solaris" => "Solaris",
+                        "wasi" => "WASI",
                         "windows" => "Windows",
                         _ => "",
                     },
diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs
index 3a78269f19a..34b9cbcb679 100644
--- a/src/librustdoc/clean/cfg/tests.rs
+++ b/src/librustdoc/clean/cfg/tests.rs
@@ -368,6 +368,10 @@ fn test_render_long_html() {
             "This is supported on <strong>macOS</strong> only."
         );
         assert_eq!(
+            name_value_cfg("target_os", "wasi").render_long_html(),
+            "This is supported on <strong>WASI</strong> only."
+        );
+        assert_eq!(
             name_value_cfg("target_pointer_width", "16").render_long_html(),
             "This is supported on <strong>16-bit</strong> only."
         );
diff --git a/src/test/rustdoc/doc-cfg.rs b/src/test/rustdoc/doc-cfg.rs
index 51a58378299..89a61a289fd 100644
--- a/src/test/rustdoc/doc-cfg.rs
+++ b/src/test/rustdoc/doc-cfg.rs
@@ -5,6 +5,8 @@
 // @!has - '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' ''
 // @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
 // @has - '//*[@class="stab portability"]' 'This is supported on Unix and ARM only.'
+// @has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()'
+// @has - '//*[@class="stab portability"]' 'This is supported on WASI and WebAssembly only.'
 pub struct Portable;
 
 // @has doc_cfg/unix_only/index.html \
@@ -37,6 +39,36 @@ pub mod unix_only {
     }
 }
 
+// @has doc_cfg/wasi_only/index.html \
+//  '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
+//  'This is supported on WASI only.'
+// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AWebAssembly\Z'
+// @count - '//*[@class="stab portability"]' 2
+#[doc(cfg(target_os = "wasi"))]
+pub mod wasi_only {
+    // @has doc_cfg/wasi_only/fn.wasi_only_function.html \
+    //  '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'This is supported on WASI only.'
+    // @count - '//*[@class="stab portability"]' 1
+    pub fn wasi_only_function() {
+        content::should::be::irrelevant();
+    }
+
+    // @has doc_cfg/wasi_only/trait.Wasm32Only.html \
+    //  '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
+    //  'This is supported on WASI and WebAssembly only.'
+    // @count - '//*[@class="stab portability"]' 1
+    #[doc(cfg(target_arch = "wasm32"))]
+    pub trait Wasm32Only {
+        fn wasi_and_wasm32_only_function();
+    }
+
+    #[doc(cfg(target_arch = "wasm32"))]
+    impl Wasm32Only for super::Portable {
+        fn wasi_and_wasm32_only_function() {}
+    }
+}
+
 // tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
 // item as well