Skip to content

Commit 96bb524

Browse files
Update rustdoc tests
1 parent 82ece41 commit 96bb524

File tree

8 files changed

+52
-31
lines changed

8 files changed

+52
-31
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#![doc(auto_cfg(hide(target_os = "linux")))]
2+
#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: same `cfg` was in `auto_cfg(hide(...))` and `auto_cfg(show(...))` on the same item
2+
--> $DIR/cfg-hide-show-conflict.rs:2:31
3+
|
4+
LL | #![doc(auto_cfg(show(windows, target_os = "linux")))]
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: first change was here
8+
--> $DIR/cfg-hide-show-conflict.rs:1:22
9+
|
10+
LL | #![doc(auto_cfg(hide(target_os = "linux")))]
11+
| ^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+

tests/rustdoc-ui/invalid-cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#![feature(doc_cfg)]
22
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
33
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
4-
struct S {}
4+
pub struct S {}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
#![feature(doc_cfg_hide)]
2-
3-
#![doc(cfg_hide = "test")] //~ ERROR
4-
#![doc(cfg_hide)] //~ ERROR
5-
6-
#[doc(cfg_hide(doc))] //~ ERROR
7-
pub fn foo() {}
1+
#![doc(auto_cfg(hide = "test"))] //~ ERROR
2+
#![doc(auto_cfg(hide))] //~ ERROR
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
error: this attribute can only be applied at the crate level
2-
--> $DIR/doc_cfg_hide.rs:6:7
1+
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
2+
--> $DIR/doc_cfg_hide.rs:1:8
33
|
4-
LL | #[doc(cfg_hide(doc))]
5-
| ^^^^^^^^^^^^^
4+
LL | #![doc(auto_cfg(hide = "test"))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
87
= note: `#[deny(invalid_doc_attributes)]` on by default
9-
help: to apply to the crate, use an inner attribute
10-
|
11-
LL | #![doc(cfg_hide(doc))]
12-
| +
13-
14-
error: `#[doc(cfg_hide(...))]` takes a list of attributes
15-
--> $DIR/doc_cfg_hide.rs:3:8
16-
|
17-
LL | #![doc(cfg_hide = "test")]
18-
| ^^^^^^^^^^^^^^^^^
198

20-
error: `#[doc(cfg_hide(...))]` takes a list of attributes
21-
--> $DIR/doc_cfg_hide.rs:4:8
9+
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
10+
--> $DIR/doc_cfg_hide.rs:2:8
2211
|
23-
LL | #![doc(cfg_hide)]
24-
| ^^^^^^^^
12+
LL | #![doc(auto_cfg(hide))]
13+
| ^^^^^^^^^^^^^^
2514

26-
error: aborting due to 3 previous errors
15+
error: aborting due to 2 previous errors
2716

tests/rustdoc/doc-cfg-hide.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![crate_name = "oud"]
2-
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]
2+
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide, no_core)]
33

4-
#![doc(cfg_hide(feature = "solecism"))]
4+
#![doc(auto_cfg(hide(feature = "solecism")))]
55

66
//@ has 'oud/struct.Solecism.html'
77
//@ count - '//*[@class="stab portability"]' 0

tests/rustdoc/doc-cfg-implicit-gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#![crate_name = "xenogenous"]
33

44
//@ has 'xenogenous/struct.Worricow.html'
5-
//@ count - '//*[@class="stab portability"]' 0
5+
//@ count - '//*[@class="stab portability"]' 1
66
#[cfg(feature = "worricow")]
77
pub struct Worricow;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Checks that `cfg` are correctly applied on inlined reexports.
2+
3+
#![crate_name = "foo"]
4+
5+
// Check with `std` item.
6+
//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-moustache'
7+
//@ has 'foo/struct.C.html' '//*[@class="stab portability"]' \
8+
// 'Available on non-crate feature moustache only.'
9+
#[cfg(not(feature = "moustache"))]
10+
pub use std::cell::RefCell as C;
11+
12+
// Check with local item.
13+
mod x {
14+
pub struct B;
15+
}
16+
17+
//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-pistache'
18+
//@ has 'foo/struct.B.html' '//*[@class="stab portability"]' \
19+
// 'Available on non-crate feature pistache only.'
20+
#[cfg(not(feature = "pistache"))]
21+
pub use crate::x::B;

0 commit comments

Comments
 (0)