Put back the doc_cfg code behind a nightly feature
This commit is contained in:
@@ -182,6 +182,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
|
||||
gate_doc!(
|
||||
"experimental" {
|
||||
cfg => doc_cfg
|
||||
masked => doc_masked
|
||||
notable_trait => doc_notable_trait
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
|
||||
};
|
||||
|
||||
pub(crate) fn propagate_doc_cfg(cr: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr)
|
||||
if cx.tcx.features().doc_cfg() {
|
||||
CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr)
|
||||
} else {
|
||||
cr
|
||||
}
|
||||
}
|
||||
|
||||
struct CfgPropagator<'a, 'tcx> {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
#![feature(doc_cfg)]
|
||||
#![doc(auto_cfg(hide(target_os = "linux")))]
|
||||
#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error: same `cfg` was in `auto_cfg(hide(...))` and `auto_cfg(show(...))` on the same item
|
||||
--> $DIR/cfg-hide-show-conflict.rs:2:31
|
||||
--> $DIR/cfg-hide-show-conflict.rs:3:31
|
||||
|
|
||||
LL | #![doc(auto_cfg(show(windows, target_os = "linux")))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first change was here
|
||||
--> $DIR/cfg-hide-show-conflict.rs:1:22
|
||||
--> $DIR/cfg-hide-show-conflict.rs:2:22
|
||||
|
|
||||
LL | #![doc(auto_cfg(hide(target_os = "linux")))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![feature(doc_cfg)]
|
||||
#![doc(auto_cfg(hide = "test"))] //~ ERROR
|
||||
#![doc(auto_cfg(hide))] //~ ERROR
|
||||
#![doc(auto_cfg(hide(not(windows))))] //~ ERROR
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
|
||||
--> $DIR/doc_cfg_hide.rs:1:8
|
||||
--> $DIR/doc_cfg_hide.rs:2:8
|
||||
|
|
||||
LL | #![doc(auto_cfg(hide = "test"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -7,13 +7,13 @@ LL | #![doc(auto_cfg(hide = "test"))]
|
||||
= note: `#[deny(invalid_doc_attributes)]` on by default
|
||||
|
||||
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
|
||||
--> $DIR/doc_cfg_hide.rs:2:8
|
||||
--> $DIR/doc_cfg_hide.rs:3:8
|
||||
|
|
||||
LL | #![doc(auto_cfg(hide))]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/values items
|
||||
--> $DIR/doc_cfg_hide.rs:3:22
|
||||
--> $DIR/doc_cfg_hide.rs:4:22
|
||||
|
|
||||
LL | #![doc(auto_cfg(hide(not(windows))))]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(doc_auto_cfg)]
|
||||
#![feature(doc_cfg)]
|
||||
#![crate_name = "foo"]
|
||||
|
||||
//@ has foo/fn.foo.html
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#![crate_name = "oud"]
|
||||
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide, no_core)]
|
||||
#![feature(doc_cfg)]
|
||||
|
||||
#![doc(auto_cfg(hide(feature = "solecism")))]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//@ compile-flags:--cfg feature="worricow"
|
||||
#![feature(doc_cfg)]
|
||||
#![crate_name = "xenogenous"]
|
||||
|
||||
//@ has 'xenogenous/struct.Worricow.html'
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Test covering RFC 3631 features.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
#![feature(no_core)]
|
||||
#![no_core]
|
||||
#![no_std]
|
||||
|
||||
#![feature(doc_cfg)]
|
||||
#![doc(auto_cfg(hide(feature = "hidden")))]
|
||||
|
||||
//@ has 'foo/index.html'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Checks that `cfg` are correctly applied on inlined reexports.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
#![feature(doc_cfg)]
|
||||
|
||||
// Check with `std` item.
|
||||
//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-moustache'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/101129>.
|
||||
|
||||
#![feature(doc_auto_cfg)]
|
||||
#![feature(doc_cfg)]
|
||||
#![crate_type = "lib"]
|
||||
#![crate_name = "foo"]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/113982
|
||||
#![feature(no_core, doc_auto_cfg)]
|
||||
#![feature(no_core, doc_cfg)]
|
||||
#![no_core]
|
||||
#![crate_name = "foo"]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// the reexported item whereas glob reexports do with the `doc_auto_cfg` feature.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
#![feature(doc_auto_cfg)]
|
||||
#![feature(doc_cfg)]
|
||||
|
||||
//@ has 'foo/index.html'
|
||||
// There are two items.
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
//@ build-pass
|
||||
|
||||
// FIXME: Remove this test once `doc_cfg` feature is completely removed.
|
||||
|
||||
#[doc(cfg(unix))]
|
||||
#[doc(cfg(unix))] //~ ERROR
|
||||
fn main() {}
|
||||
|
||||
13
tests/ui/feature-gates/feature-gate-doc_cfg.stderr
Normal file
13
tests/ui/feature-gates/feature-gate-doc_cfg.stderr
Normal file
@@ -0,0 +1,13 @@
|
||||
error[E0658]: `#[doc(cfg)]` is experimental
|
||||
--> $DIR/feature-gate-doc_cfg.rs:1:1
|
||||
|
|
||||
LL | #[doc(cfg(unix))]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information
|
||||
= help: add `#![feature(doc_cfg)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Reference in New Issue
Block a user