about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-03-29 00:54:22 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-09-27 11:29:48 +0200
commit6537278e114a98ea6f2c80d7d7ffacb2868be770 (patch)
tree18297e85470f1c676d2ccbe06e3a9cbbcbf11404
parent7c00bccd3b3eb6717e3c801123107962e671e48f (diff)
downloadrust-6537278e114a98ea6f2c80d7d7ffacb2868be770.tar.gz
rust-6537278e114a98ea6f2c80d7d7ffacb2868be770.zip
Update rustdoc tests
-rw-r--r--tests/rustdoc-ui/cfg-hide-show-conflict.rs2
-rw-r--r--tests/rustdoc-ui/cfg-hide-show-conflict.stderr14
-rw-r--r--tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs5
-rw-r--r--tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr11
-rw-r--r--tests/rustdoc-ui/invalid-cfg.rs2
-rw-r--r--tests/rustdoc-ui/lints/doc_cfg_hide.rs9
-rw-r--r--tests/rustdoc-ui/lints/doc_cfg_hide.stderr29
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-hide.rs8
-rw-r--r--tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs2
-rw-r--r--tests/rustdoc/doc_auto_cfg_reexports.rs21
10 files changed, 61 insertions, 42 deletions
diff --git a/tests/rustdoc-ui/cfg-hide-show-conflict.rs b/tests/rustdoc-ui/cfg-hide-show-conflict.rs
new file mode 100644
index 00000000000..a8a50fe15c7
--- /dev/null
+++ b/tests/rustdoc-ui/cfg-hide-show-conflict.rs
@@ -0,0 +1,2 @@
+#![doc(auto_cfg(hide(target_os = "linux")))]
+#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR
diff --git a/tests/rustdoc-ui/cfg-hide-show-conflict.stderr b/tests/rustdoc-ui/cfg-hide-show-conflict.stderr
new file mode 100644
index 00000000000..d2d0564606a
--- /dev/null
+++ b/tests/rustdoc-ui/cfg-hide-show-conflict.stderr
@@ -0,0 +1,14 @@
+error: same `cfg` was in `auto_cfg(hide(...))` and `auto_cfg(show(...))` on the same item
+  --> $DIR/cfg-hide-show-conflict.rs:2:31
+   |
+LL | #![doc(auto_cfg(show(windows, target_os = "linux")))]
+   |                               ^^^^^^^^^^^^^^^^^^^
+   |
+note: first change was here
+  --> $DIR/cfg-hide-show-conflict.rs:1:22
+   |
+LL | #![doc(auto_cfg(hide(target_os = "linux")))]
+   |                      ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs b/tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs
index 17812018b9b..e49285a01b8 100644
--- a/tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs
+++ b/tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs
@@ -1,5 +1,6 @@
-#![doc(cfg_hide(test))]
-//~^ ERROR `#[doc(cfg_hide)]` is experimental
+// FIXME: Remove this file once feature is removed
+
+#![doc(cfg_hide(test))] //~ ERROR
 
 #[cfg(not(test))]
 pub fn public_fn() {}
diff --git a/tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr b/tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr
index 55135986ffe..b3eee2af7f7 100644
--- a/tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr
+++ b/tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr
@@ -1,13 +1,10 @@
-error[E0658]: `#[doc(cfg_hide)]` is experimental
-  --> $DIR/feature-gate-doc_cfg_hide.rs:1:1
+error: unknown `doc` attribute `cfg_hide`
+  --> $DIR/feature-gate-doc_cfg_hide.rs:3:8
    |
 LL | #![doc(cfg_hide(test))]
-   | ^^^^^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^^^^
    |
-   = note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information
-   = help: add `#![feature(doc_cfg_hide)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+   = note: `#[deny(invalid_doc_attributes)]` on by default
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/rustdoc-ui/invalid-cfg.rs b/tests/rustdoc-ui/invalid-cfg.rs
index d237b8605c0..aff36286c53 100644
--- a/tests/rustdoc-ui/invalid-cfg.rs
+++ b/tests/rustdoc-ui/invalid-cfg.rs
@@ -1,4 +1,4 @@
 #![feature(doc_cfg)]
 #[doc(cfg = "x")] //~ ERROR not followed by parentheses
 #[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
-struct S {}
+pub struct S {}
diff --git a/tests/rustdoc-ui/lints/doc_cfg_hide.rs b/tests/rustdoc-ui/lints/doc_cfg_hide.rs
index 9a8bce2a92a..abf56318479 100644
--- a/tests/rustdoc-ui/lints/doc_cfg_hide.rs
+++ b/tests/rustdoc-ui/lints/doc_cfg_hide.rs
@@ -1,7 +1,2 @@
-#![feature(doc_cfg_hide)]
-
-#![doc(cfg_hide = "test")] //~ ERROR
-#![doc(cfg_hide)] //~ ERROR
-
-#[doc(cfg_hide(doc))] //~ ERROR
-pub fn foo() {}
+#![doc(auto_cfg(hide = "test"))] //~ ERROR
+#![doc(auto_cfg(hide))] //~ ERROR
diff --git a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr
index 0c9d0879b0a..bb0e52eb666 100644
--- a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr
+++ b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr
@@ -1,27 +1,16 @@
-error: this attribute can only be applied at the crate level
-  --> $DIR/doc_cfg_hide.rs:6:7
+error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
+  --> $DIR/doc_cfg_hide.rs:1:8
    |
-LL | #[doc(cfg_hide(doc))]
-   |       ^^^^^^^^^^^^^
+LL | #![doc(auto_cfg(hide = "test"))]
+   |        ^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
    = note: `#[deny(invalid_doc_attributes)]` on by default
-help: to apply to the crate, use an inner attribute
-   |
-LL | #![doc(cfg_hide(doc))]
-   |  +
-
-error: `#[doc(cfg_hide(...))]` takes a list of attributes
-  --> $DIR/doc_cfg_hide.rs:3:8
-   |
-LL | #![doc(cfg_hide = "test")]
-   |        ^^^^^^^^^^^^^^^^^
 
-error: `#[doc(cfg_hide(...))]` takes a list of attributes
-  --> $DIR/doc_cfg_hide.rs:4:8
+error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
+  --> $DIR/doc_cfg_hide.rs:2:8
    |
-LL | #![doc(cfg_hide)]
-   |        ^^^^^^^^
+LL | #![doc(auto_cfg(hide))]
+   |        ^^^^^^^^^^^^^^
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs
index ceb1f99fae0..cf906ede7e1 100644
--- a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs
+++ b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs
@@ -1,7 +1,7 @@
 #![crate_name = "oud"]
-#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]
+#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide, no_core)]
 
-#![doc(cfg_hide(feature = "solecism"))]
+#![doc(auto_cfg(hide(feature = "solecism")))]
 
 //@ has 'oud/struct.Solecism.html'
 //@ count   - '//*[@class="stab portability"]' 0
@@ -18,7 +18,7 @@ pub struct Scribacious;
 
 //@ has 'oud/struct.Hyperdulia.html'
 //@ count   - '//*[@class="stab portability"]' 1
-//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia'
+//@ matches - '//*[@class="stab portability"]' 'crate features hyperdulia only'
 //@ compile-flags:--cfg feature="hyperdulia"
 #[cfg(feature = "solecism")]
 #[cfg(feature = "hyperdulia")]
@@ -26,7 +26,7 @@ pub struct Hyperdulia;
 
 //@ has 'oud/struct.Oystercatcher.html'
 //@ count   - '//*[@class="stab portability"]' 1
-//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only'
+//@ matches - '//*[@class="stab portability"]' 'crate features oystercatcher only'
 //@ compile-flags:--cfg feature="oystercatcher"
 #[cfg(all(feature = "solecism", feature = "oystercatcher"))]
 pub struct Oystercatcher;
diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs
index b5b8d0f427b..27923893bdd 100644
--- a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs
+++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs
@@ -2,6 +2,6 @@
 #![crate_name = "xenogenous"]
 
 //@ has 'xenogenous/struct.Worricow.html'
-//@ count   - '//*[@class="stab portability"]' 0
+//@ count   - '//*[@class="stab portability"]' 1
 #[cfg(feature = "worricow")]
 pub struct Worricow;
diff --git a/tests/rustdoc/doc_auto_cfg_reexports.rs b/tests/rustdoc/doc_auto_cfg_reexports.rs
new file mode 100644
index 00000000000..f226c52e2eb
--- /dev/null
+++ b/tests/rustdoc/doc_auto_cfg_reexports.rs
@@ -0,0 +1,21 @@
+// Checks that `cfg` are correctly applied on inlined reexports.
+
+#![crate_name = "foo"]
+
+// Check with `std` item.
+//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-moustache'
+//@ has 'foo/struct.C.html' '//*[@class="stab portability"]' \
+//      'Available on non-crate feature moustache only.'
+#[cfg(not(feature = "moustache"))]
+pub use std::cell::RefCell as C;
+
+// Check with local item.
+mod x {
+    pub struct B;
+}
+
+//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-pistache'
+//@ has 'foo/struct.B.html' '//*[@class="stab portability"]' \
+//      'Available on non-crate feature pistache only.'
+#[cfg(not(feature = "pistache"))]
+pub use crate::x::B;