Skip to content

Commit 645ca78

Browse files
Update rustdoc tests
1 parent b7d2cfb commit 645ca78

10 files changed

+61
-42
lines changed
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
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/feature-gate-doc_cfg_hide.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#![doc(cfg_hide(test))]
2-
//~^ ERROR `#[doc(cfg_hide)]` is experimental
1+
// FIXME: Remove this file once feature is removed
2+
3+
#![doc(cfg_hide(test))] //~ ERROR
34

45
#[cfg(not(test))]
56
pub fn public_fn() {}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
error[E0658]: `#[doc(cfg_hide)]` is experimental
2-
--> $DIR/feature-gate-doc_cfg_hide.rs:1:1
1+
error: unknown `doc` attribute `cfg_hide`
2+
--> $DIR/feature-gate-doc_cfg_hide.rs:3:8
33
|
44
LL | #![doc(cfg_hide(test))]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^
66
|
7-
= note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information
8-
= help: add `#![feature(doc_cfg_hide)]` to the crate attributes to enable
9-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
7+
= note: `#[deny(invalid_doc_attributes)]` on by default
108

119
error: aborting due to 1 previous error
1210

13-
For more information about this error, try `rustc --explain E0658`.

tests/rustdoc-ui/invalid-cfg.rs

+1-1
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 {}
+2-7
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
+9-20
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

+4-4
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
@@ -18,15 +18,15 @@ pub struct Scribacious;
1818

1919
//@ has 'oud/struct.Hyperdulia.html'
2020
//@ count - '//*[@class="stab portability"]' 1
21-
//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia'
21+
//@ matches - '//*[@class="stab portability"]' 'crate features hyperdulia only'
2222
//@ compile-flags:--cfg feature="hyperdulia"
2323
#[cfg(feature = "solecism")]
2424
#[cfg(feature = "hyperdulia")]
2525
pub struct Hyperdulia;
2626

2727
//@ has 'oud/struct.Oystercatcher.html'
2828
//@ count - '//*[@class="stab portability"]' 1
29-
//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only'
29+
//@ matches - '//*[@class="stab portability"]' 'crate features oystercatcher only'
3030
//@ compile-flags:--cfg feature="oystercatcher"
3131
#[cfg(all(feature = "solecism", feature = "oystercatcher"))]
3232
pub struct Oystercatcher;

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

+1-1
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;
+21
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)