Skip to content

Commit b12ebd6

Browse files
Put back the doc_cfg code behind a nightly feature
1 parent 81e5ece commit b12ebd6

16 files changed

+35
-20
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
182182

183183
gate_doc!(
184184
"experimental" {
185+
cfg => doc_cfg
185186
masked => doc_masked
186187
notable_trait => doc_notable_trait
187188
}

src/librustdoc/passes/propagate_doc_cfg.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
1818
};
1919

2020
pub(crate) fn propagate_doc_cfg(cr: Crate, cx: &mut DocContext<'_>) -> Crate {
21-
CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr)
21+
if cx.tcx.features().doc_cfg() {
22+
CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr)
23+
} else {
24+
cr
25+
}
2226
}
2327

2428
struct CfgPropagator<'a, 'tcx> {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
#![feature(doc_cfg)]
12
#![doc(auto_cfg(hide(target_os = "linux")))]
23
#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR

tests/rustdoc-ui/cfg-hide-show-conflict.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
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
2+
--> $DIR/cfg-hide-show-conflict.rs:3:31
33
|
44
LL | #![doc(auto_cfg(show(windows, target_os = "linux")))]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
note: first change was here
8-
--> $DIR/cfg-hide-show-conflict.rs:1:22
8+
--> $DIR/cfg-hide-show-conflict.rs:2:22
99
|
1010
LL | #![doc(auto_cfg(hide(target_os = "linux")))]
1111
| ^^^^^^^^^^^^^^^^^^^
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(doc_cfg)]
12
#![doc(auto_cfg(hide = "test"))] //~ ERROR
23
#![doc(auto_cfg(hide))] //~ ERROR
34
#![doc(auto_cfg(hide(not(windows))))] //~ ERROR

tests/rustdoc-ui/lints/doc_cfg_hide.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
2-
--> $DIR/doc_cfg_hide.rs:1:8
2+
--> $DIR/doc_cfg_hide.rs:2:8
33
|
44
LL | #![doc(auto_cfg(hide = "test"))]
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[deny(invalid_doc_attributes)]` on by default
88

99
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
10-
--> $DIR/doc_cfg_hide.rs:2:8
10+
--> $DIR/doc_cfg_hide.rs:3:8
1111
|
1212
LL | #![doc(auto_cfg(hide))]
1313
| ^^^^^^^^^^^^^^
1414

1515
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/values items
16-
--> $DIR/doc_cfg_hide.rs:3:22
16+
--> $DIR/doc_cfg_hide.rs:4:22
1717
|
1818
LL | #![doc(auto_cfg(hide(not(windows))))]
1919
| ^^^^^^^^^^^^

tests/rustdoc/doc-auto-cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(doc_auto_cfg)]
1+
#![feature(doc_cfg)]
22
#![crate_name = "foo"]
33

44
//@ has foo/fn.foo.html

tests/rustdoc/doc-cfg/doc-cfg-hide.rs

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

44
#![doc(auto_cfg(hide(feature = "solecism")))]
55

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags:--cfg feature="worricow"
2+
#![feature(doc_cfg)]
23
#![crate_name = "xenogenous"]
34

45
//@ has 'xenogenous/struct.Worricow.html'

tests/rustdoc/doc_auto_cfg.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Test covering RFC 3631 features.
22

33
#![crate_name = "foo"]
4-
#![feature(no_core)]
5-
#![no_core]
6-
#![no_std]
7-
4+
#![feature(doc_cfg)]
85
#![doc(auto_cfg(hide(feature = "hidden")))]
96

107
//@ has 'foo/index.html'

0 commit comments

Comments
 (0)