Skip to content

Commit 1a0781f

Browse files
Put back the doc_cfg code behind a nightly feature
1 parent ccc2074 commit 1a0781f

16 files changed

+35
-20
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
172172

173173
gate_doc!(
174174
"experimental" {
175+
cfg => doc_cfg
175176
masked => doc_masked
176177
notable_trait => doc_notable_trait
177178
}

src/librustdoc/passes/propagate_doc_cfg.rs

+5-1
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> {
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

+2-2
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
| ^^^^^^^^^^^^^^^^^^^
+1
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

+3-3
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

+1-1
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-hide.rs

+1-1
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-implicit-gate.rs

+1
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-reexport-foreign-113982.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs
22

33
// https://github.com/rust-lang/rust/issues/113982
4-
#![feature(no_core, doc_auto_cfg)]
4+
#![feature(no_core, doc_cfg)]
55
#![no_core]
66
#![crate_name = "foo"]
77

tests/rustdoc/doc_auto_cfg.rs

+1-4
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'

tests/rustdoc/doc_auto_cfg_nested_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/101129>.
22

3-
#![feature(doc_auto_cfg)]
3+
#![feature(doc_cfg)]
44
#![crate_type = "lib"]
55
#![crate_name = "foo"]
66

tests/rustdoc/doc_auto_cfg_reexports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Checks that `cfg` are correctly applied on inlined reexports.
22

33
#![crate_name = "foo"]
4+
#![feature(doc_cfg)]
45

56
// Check with `std` item.
67
//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-moustache'

tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// the reexported item whereas glob reexports do with the `doc_auto_cfg` feature.
33

44
#![crate_name = "foo"]
5-
#![feature(doc_auto_cfg)]
5+
#![feature(doc_cfg)]
66

77
//@ has 'foo/index.html'
88
// There are two items.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
//@ build-pass
2-
3-
// FIXME: Remove this test once `doc_cfg` feature is completely removed.
4-
5-
#[doc(cfg(unix))]
1+
#[doc(cfg(unix))] //~ ERROR
62
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: `#[doc(cfg)]` is experimental
2+
--> $DIR/feature-gate-doc_cfg.rs:1:1
3+
|
4+
LL | #[doc(cfg(unix))]
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information
8+
= help: add `#![feature(doc_cfg)]` 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
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)