Put back the doc_cfg code behind a nightly feature

This commit is contained in:
Guillaume Gomez
2025-04-11 14:32:31 +02:00
parent ed05315867
commit c06a076634
16 changed files with 35 additions and 20 deletions

View File

@@ -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
}

View File

@@ -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> {

View File

@@ -1,2 +1,3 @@
#![feature(doc_cfg)]
#![doc(auto_cfg(hide(target_os = "linux")))]
#![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR

View File

@@ -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")))]
| ^^^^^^^^^^^^^^^^^^^

View File

@@ -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

View File

@@ -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))))]
| ^^^^^^^^^^^^

View File

@@ -1,4 +1,4 @@
#![feature(doc_auto_cfg)]
#![feature(doc_cfg)]
#![crate_name = "foo"]
//@ has foo/fn.foo.html

View File

@@ -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")))]

View File

@@ -1,4 +1,5 @@
//@ compile-flags:--cfg feature="worricow"
#![feature(doc_cfg)]
#![crate_name = "xenogenous"]
//@ has 'xenogenous/struct.Worricow.html'

View File

@@ -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'

View File

@@ -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'

View File

@@ -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"]

View File

@@ -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"]

View File

@@ -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.

View File

@@ -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() {}

View 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`.