Update rustdoc tests

This commit is contained in:
Guillaume Gomez 2025-03-29 00:54:22 +01:00
parent 7c00bccd3b
commit 6537278e11
10 changed files with 62 additions and 43 deletions

View file

@ -0,0 +1,2 @@
#![doc(auto_cfg(hide(target_os = "linux")))]
#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR

View file

@ -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

View file

@ -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() {}

View file

@ -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`.

View file

@ -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 {}

View file

@ -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

View file

@ -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
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
--> $DIR/doc_cfg_hide.rs:2:8
|
LL | #![doc(cfg_hide(doc))]
| +
LL | #![doc(auto_cfg(hide))]
| ^^^^^^^^^^^^^^
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
|
LL | #![doc(cfg_hide)]
| ^^^^^^^^
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

View file

@ -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;

View file

@ -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;

View file

@ -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;