about summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorWim Looman <git@nemo157.com>2020-11-03 19:45:16 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2021-10-05 17:25:44 +0200
commit10cdbd847fd00d093ce89a4fffde5d90c8bb9817 (patch)
tree565637fa1346110af2b1b1aa415cd1d1b2fe025a /src/test/rustdoc
parent074f63648bd2368d5ca19aed02b5763a144e5d05 (diff)
downloadrust-10cdbd847fd00d093ce89a4fffde5d90c8bb9817.tar.gz
rust-10cdbd847fd00d093ce89a4fffde5d90c8bb9817.zip
Make cfg implicitly imply doc(cfg)
This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via #[doc(cfg(...))], so e.g. to
hide a #[cfg] you can use something like:

```rust
 #[cfg(unix)]
 #[doc(cfg(all()))]
pub struct Unix;
```

(since `all()` is always true, it is never shown in the docs)
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/doc-cfg-implicit-gate.rs7
-rw-r--r--src/test/rustdoc/doc-cfg-implicit.rs31
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/rustdoc/doc-cfg-implicit-gate.rs b/src/test/rustdoc/doc-cfg-implicit-gate.rs
new file mode 100644
index 00000000000..92804d3729b
--- /dev/null
+++ b/src/test/rustdoc/doc-cfg-implicit-gate.rs
@@ -0,0 +1,7 @@
+// compile-flags:--cfg feature="worricow"
+#![crate_name = "xenogenous"]
+
+// @has 'xenogenous/struct.Worricow.html'
+// @count   - '//*[@class="stab portability"]' 0
+#[cfg(feature = "worricow")]
+pub struct Worricow;
diff --git a/src/test/rustdoc/doc-cfg-implicit.rs b/src/test/rustdoc/doc-cfg-implicit.rs
new file mode 100644
index 00000000000..36c2025785d
--- /dev/null
+++ b/src/test/rustdoc/doc-cfg-implicit.rs
@@ -0,0 +1,31 @@
+#![crate_name = "funambulism"]
+#![feature(doc_cfg)]
+
+// @has 'funambulism/struct.Disorbed.html'
+// @count   - '//*[@class="stab portability"]' 1
+// @matches - '//*[@class="stab portability"]' 'crate feature disorbed'
+// compile-flags:--cfg feature="disorbed"
+#[cfg(feature = "disorbed")]
+pub struct Disorbed;
+
+// @has 'funambulism/struct.Aesthesia.html'
+// @count   - '//*[@class="stab portability"]' 1
+// @matches - '//*[@class="stab portability"]' 'crate feature aesthesia'
+// compile-flags:--cfg feature="aesthesia"
+#[doc(cfg(feature = "aesthesia"))]
+pub struct Aesthesia;
+
+// @has 'funambulism/struct.Pliothermic.html'
+// @count   - '//*[@class="stab portability"]' 1
+// @matches - '//*[@class="stab portability"]' 'crate feature pliothermic'
+// compile-flags:--cfg feature="epopoeist"
+#[cfg(feature = "epopoeist")]
+#[doc(cfg(feature = "pliothermic"))]
+pub struct Pliothermic;
+
+// @has 'funambulism/struct.Simillimum.html'
+// @count   - '//*[@class="stab portability"]' 0
+// compile-flags:--cfg feature="simillimum"
+#[cfg(feature = "simillimum")]
+#[doc(cfg(all()))]
+pub struct Simillimum;