From 1346a1195ca3dc070a40bdd420f0a8852207e871 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 16 Dec 2025 12:44:53 +0100 Subject: [PATCH] Stabilize `doc_cfg` feature --- compiler/rustc_ast_passes/src/feature_gate.rs | 2 - .../src/error_codes/E0536.md | 2 - compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/unstable.rs | 2 - library/alloc/src/lib.rs | 2 - library/core/src/lib.rs | 1 - library/std/src/lib.rs | 1 - library/std_detect/src/lib.rs | 2 +- library/stdarch/crates/core_arch/src/lib.rs | 1 - src/doc/rustdoc/src/unstable-features.md | 268 ------------------ .../write-documentation/the-doc-attribute.md | 268 ++++++++++++++++++ .../src/language-features/doc-cfg.md | 46 --- src/librustdoc/passes/propagate_doc_cfg.rs | 6 +- tests/rustdoc-gui/src/lib2/lib.rs | 1 - tests/rustdoc-gui/src/test_docs/lib.rs | 1 - tests/rustdoc-ui/cfg-boolean-literal.rs | 2 - tests/rustdoc-ui/cfg-hide-show-conflict.rs | 1 - .../rustdoc-ui/cfg-hide-show-conflict.stderr | 4 +- tests/rustdoc-ui/doc-cfg-2.rs | 2 - tests/rustdoc-ui/doc-cfg-2.stderr | 20 +- .../doc-cfg-check-cfg.cfg_empty.stderr | 6 +- tests/rustdoc-ui/doc-cfg-check-cfg.rs | 1 - tests/rustdoc-ui/doc-cfg-unstable.rs | 1 - tests/rustdoc-ui/doc-cfg-unstable.stderr | 2 +- tests/rustdoc-ui/doc-cfg.rs | 2 - tests/rustdoc-ui/doc-cfg.stderr | 10 +- .../doctest/doc-test-rustdoc-feature.rs | 3 - .../doctest/doc-test-rustdoc-feature.stdout | 2 +- tests/rustdoc-ui/feature-gate-doc_cfg.rs | 6 - tests/rustdoc-ui/feature-gate-doc_cfg.stderr | 63 +--- tests/rustdoc-ui/invalid-cfg.rs | 1 - tests/rustdoc-ui/invalid-cfg.stderr | 16 +- tests/rustdoc-ui/lints/doc_cfg_hide.rs | 1 - tests/rustdoc-ui/lints/doc_cfg_hide.stderr | 6 +- tests/rustdoc/cfg-bool.rs | 1 - .../rustdoc/doc-auto-cfg-public-in-private.rs | 1 - tests/rustdoc/doc-auto-cfg.rs | 1 - tests/rustdoc/doc-cfg/doc-cfg-hide.rs | 1 - .../rustdoc/doc-cfg/doc-cfg-implicit-gate.rs | 1 - tests/rustdoc/doc-cfg/doc-cfg-implicit.rs | 1 - .../doc-cfg-inherit-from-module-79201.rs | 2 - .../rustdoc/doc-cfg/doc-cfg-simplification.rs | 1 - .../rustdoc/doc-cfg/doc-cfg-target-feature.rs | 2 - tests/rustdoc/doc-cfg/doc-cfg-traits.rs | 2 +- tests/rustdoc/doc-cfg/doc-cfg.rs | 1 - tests/rustdoc/doc-cfg/duplicate-cfg.rs | 1 - tests/rustdoc/doc_auto_cfg.rs | 1 - tests/rustdoc/doc_auto_cfg_reexports.rs | 1 - tests/rustdoc/feature-gate-doc_auto_cfg.rs | 2 - .../rustdoc/impl/doc_auto_cfg_nested_impl.rs | 1 - tests/rustdoc/inline_cross/doc-auto-cfg.rs | 1 - tests/rustdoc/reexport/cfg_doc_reexport.rs | 1 - .../glob-reexport-attribute-merge-120487.rs | 1 - ...b-reexport-attribute-merge-doc-auto-cfg.rs | 1 - tests/rustdoc/reexport/reexport-attr-merge.rs | 1 - tests/rustdoc/reexport/reexport-cfg.rs | 1 - ...ability-tags-deprecated-and-portability.rs | 1 - ...stability-tags-unstable-and-portability.rs | 1 - tests/rustdoc/target-feature.rs | 2 - .../ui/feature-gates/feature-gate-doc_cfg.rs | 2 - .../feature-gates/feature-gate-doc_cfg.stderr | 13 - 61 files changed, 314 insertions(+), 485 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/doc-cfg.md delete mode 100644 tests/rustdoc-ui/feature-gate-doc_cfg.rs delete mode 100644 tests/ui/feature-gates/feature-gate-doc_cfg.rs delete mode 100644 tests/ui/feature-gates/feature-gate-doc_cfg.stderr diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index dbbd3906b5258..cc782ab918e5d 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -181,8 +181,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_doc!( "experimental" { - cfg => doc_cfg - auto_cfg => doc_cfg masked => doc_masked notable_trait => doc_notable_trait } diff --git a/compiler/rustc_error_codes/src/error_codes/E0536.md b/compiler/rustc_error_codes/src/error_codes/E0536.md index 7603be4fcc935..107296922569c 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0536.md +++ b/compiler/rustc_error_codes/src/error_codes/E0536.md @@ -5,7 +5,6 @@ The `not` cfg-predicate was malformed. Erroneous code example (using `cargo doc`): ```ignore, E0536 (only triggers on cargo doc) -#![feature(doc_cfg)] #[doc(cfg(not()))] pub fn main() { @@ -15,7 +14,6 @@ pub fn main() { The `not` predicate expects one cfg-pattern. Example: ``` -#![feature(doc_cfg)] #[doc(cfg(not(target_os = "linux")))] // ok! pub fn main() { diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 7e765918d7b69..4e0a2147f846d 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -187,6 +187,8 @@ declare_features! ( (accepted, do_not_recommend, "1.85.0", Some(51992)), /// Allows `#[doc(alias = "...")]`. (accepted, doc_alias, "1.48.0", Some(50146)), + /// Allows `#[doc(cfg(...))]`. + (accepted, doc_cfg, "1.21.0", Some(43781)), /// Allows `..` in tuple (struct) patterns. (accepted, dotdot_in_tuple_patterns, "1.14.0", Some(33627)), /// Allows `..=` in patterns (RFC 1192). diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index fe053935f9e64..c1e524849d975 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -487,8 +487,6 @@ declare_features! ( (unstable, derive_from, "1.91.0", Some(144889)), /// Allows giving non-const impls custom diagnostic messages if attempted to be used as const (unstable, diagnostic_on_const, "CURRENT_RUSTC_VERSION", Some(143874)), - /// Allows `#[doc(cfg(...))]`. - (unstable, doc_cfg, "1.21.0", Some(43781)), /// Allows `#[doc(masked)]`. (unstable, doc_masked, "1.21.0", Some(44027)), /// Allows features to allow target_feature to better interact with traits. diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 8097e43e03a2b..2d5684a8df439 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -192,8 +192,6 @@ #![rustc_preserve_ub_checks] // tidy-alphabetical-end // -// Rustdoc features: -#![feature(doc_cfg)] // Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]` // blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad // that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 9ecc2365e69b7..79b86f47c0e1a 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -148,7 +148,6 @@ #![feature(deprecated_suggestion)] #![feature(derive_const)] #![feature(diagnostic_on_const)] -#![feature(doc_cfg)] #![feature(doc_notable_trait)] #![feature(extern_types)] #![feature(f16)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 8fb1b1b05d20c..5857d973c7d95 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -278,7 +278,6 @@ #![feature(core_float_math)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] -#![feature(doc_cfg)] #![feature(doc_masked)] #![feature(doc_notable_trait)] #![feature(dropck_eyepatch)] diff --git a/library/std_detect/src/lib.rs b/library/std_detect/src/lib.rs index 73e2f5dd96442..ac1a23ea2edf7 100644 --- a/library/std_detect/src/lib.rs +++ b/library/std_detect/src/lib.rs @@ -15,7 +15,7 @@ //! * `s390x`: [`is_s390x_feature_detected`] #![unstable(feature = "stdarch_internal", issue = "none")] -#![feature(staged_api, cfg_select, doc_cfg, allow_internal_unstable)] +#![feature(staged_api, cfg_select, allow_internal_unstable)] #![deny(rust_2018_idioms)] #![allow(clippy::shadow_reuse)] #![cfg_attr(test, allow(unused_imports))] diff --git a/library/stdarch/crates/core_arch/src/lib.rs b/library/stdarch/crates/core_arch/src/lib.rs index a059a9c225708..766c0bc7ee3d8 100644 --- a/library/stdarch/crates/core_arch/src/lib.rs +++ b/library/stdarch/crates/core_arch/src/lib.rs @@ -17,7 +17,6 @@ fmt_helpers_for_derive, rustc_attrs, staged_api, - doc_cfg, riscv_target_feature, arm_target_feature, mips_target_feature, diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 08465ea541b80..d749b42722cff 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -750,271 +750,3 @@ pass `--doctest-build-arg ARG` for each argument `ARG`. ## `--generate-macro-expansion`: Generate macros expansion toggles in source code This flag enables the generation of toggles to expand macros in the HTML source code pages. - -## `#[doc(cfg)]` and `#[doc(auto_cfg)]` - -This feature aims at providing rustdoc users the possibility to add visual markers to the rendered documentation to know under which conditions an item is available (currently possible through the following unstable feature: `doc_cfg`). - -It does not aim to allow having a same item with different `cfg`s to appear more than once in the generated documentation. - -It does not aim to document items which are *inactive* under the current configuration (i.e., “`cfg`ed out”). - -This features adds the following attributes: - - * `#[doc(auto_cfg)]`/`#[doc(auto_cfg = true)]`/`#[doc(auto_cfg = false)]` - * `#[doc(cfg(...))]` - * `#![doc(auto_cfg(hide(...)))]` / `#[doc(auto_cfg(show(...)))]` - -All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `auto_cfg(hide(...))` and `auto_cfg(show(...))` are provided: they allow a child item to override its parent. - -### `#[doc(cfg(...))]` - -This attribute provides a standardized format to override `#[cfg()]` attributes to document conditionally available items. Example: - -```rust,ignore (nightly) -// the "real" cfg condition -#[cfg(feature = "futures-io")] -// the `doc(cfg())` so it's displayed to the readers -#[doc(cfg(feature = "futures-io"))] -pub mod futures {} -``` - -It will display in the documentation for this module: - -```text -This is supported on feature="futures-io" only. -``` - -You can use it to display information in generated documentation, whether or not there is a `#[cfg()]` attribute: - -```rust,ignore (nightly) -#[doc(cfg(feature = "futures-io"))] -pub mod futures {} -``` - -It will be displayed exactly the same as the previous code. - -This attribute has the same syntax as conditional compilation, but it only causes documentation to be added. This means `#[doc(cfg(not(windows)))]` will not cause your docs to be hidden on non-windows targets, even though `#[cfg(not(windows))]` does do that. - -If `doc(auto_cfg)` is enabled on the item, `doc(cfg)` will override it anyway so in the two previous examples, even if the `doc(auto_cfg)` feature was enabled, it would still display the same thing. - -This attribute works on modules and on items. - -### `#[doc(auto_cfg(hide(...)))]` - -This attribute is used to prevent some `cfg` to be generated in the visual markers. It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. So in the previous example: - -```rust,ignore (nightly) -#[cfg(any(unix, feature = "futures-io"))] -pub mod futures {} -``` - -It currently displays both `unix` and `feature = "futures-io"` into the documentation, which is not great. To prevent the `unix` cfg to ever be displayed, you can use this attribute at the crate root level: - -```rust,ignore (nightly) -#![doc(auto_cfg(hide(unix)))] -``` - -Or directly on a given item/module as it covers any of the item's descendants: - -```rust,ignore (nightly) -#[doc(auto_cfg(hide(unix)))] -#[cfg(any(unix, feature = "futures-io"))] -pub mod futures { - // `futures` and all its descendants won't display "unix" in their cfgs. -} -``` - -Then, the `unix` cfg will never be displayed into the documentation. - -Rustdoc currently hides `doc` and `doctest` attributes by default and reserves the right to change the list of "hidden by default" attributes. - -The attribute accepts only a list of identifiers or key/value items. So you can write: - -```rust,ignore (nightly) -#[doc(auto_cfg(hide(unix, doctest, feature = "something")))] -#[doc(auto_cfg(hide()))] -``` - -But you cannot write: - -```rust,ignore (nightly) -#[doc(auto_cfg(hide(not(unix))))] -``` - -So if we use `doc(auto_cfg(hide(unix)))`, it means it will hide all mentions of `unix`: - -```rust,ignore (nightly) -#[cfg(unix)] // nothing displayed -#[cfg(any(unix))] // nothing displayed -#[cfg(any(unix, windows))] // only `windows` displayed -``` - -However, it only impacts the `unix` cfg, not the feature: - -```rust,ignore (nightly) -#[cfg(feature = "unix")] // `feature = "unix"` is displayed -``` - -If `cfg_auto(show(...))` and `cfg_auto(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example: - -```rust,ignore (nightly) -#[doc(auto_cfg(hide(unix)))] -#[doc(auto_cfg(show(unix)))] // Error! -pub fn foo() {} -``` - -Using this attribute will re-enable `auto_cfg` if it was disabled at this location: - -```rust,ignore (nightly) -#[doc(auto_cfg = false)] // Disabling `auto_cfg` -pub fn foo() {} -``` - -And using `doc(auto_cfg)` will re-enable it: - -```rust,ignore (nightly) -#[doc(auto_cfg = false)] // Disabling `auto_cfg` -pub mod module { - #[doc(auto_cfg(hide(unix)))] // `auto_cfg` is re-enabled. - pub fn foo() {} -} -``` - -However, using `doc(auto_cfg = ...)` and `doc(auto_cfg(...))` on the same item will emit an error: - -```rust,ignore (nightly) -#[doc(auto_cfg = false)] -#[doc(auto_cfg(hide(unix)))] // error -pub fn foo() {} -``` - -The reason behind this is that `doc(auto_cfg = ...)` enables or disables the feature, whereas `doc(auto_cfg(...))` enables it unconditionally, making the first attribute to appear useless as it will be overidden by the next `doc(auto_cfg)` attribute. - -### `#[doc(auto_cfg(show(...)))]` - -This attribute does the opposite of `#[doc(auto_cfg(hide(...)))]`: if you used `#[doc(auto_cfg(hide(...)))]` and want to revert its effect on an item and its descendants, you can use `#[doc(auto_cfg(show(...)))]`. -It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. - -For example: - -```rust,ignore (nightly) -#[doc(auto_cfg(hide(unix)))] -#[cfg(any(unix, feature = "futures-io"))] -pub mod futures { - // `futures` and all its descendants won't display "unix" in their cfgs. - #[doc(auto_cfg(show(unix)))] - pub mod child { - // `child` and all its descendants will display "unix" in their cfgs. - } -} -``` - -The attribute accepts only a list of identifiers or key/value items. So you can write: - -```rust,ignore (nightly) -#[doc(auto_cfg(show(unix, doctest, feature = "something")))] -#[doc(auto_cfg(show()))] -``` - -But you cannot write: - -```rust,ignore (nightly) -#[doc(auto_cfg(show(not(unix))))] -``` - -If `auto_cfg(show(...))` and `auto_cfg(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example: - -```rust,ignore (nightly) -#[doc(auto_cfg(show(unix)))] -#[doc(auto_cfg(hide(unix)))] // Error! -pub fn foo() {} -``` - -Using this attribute will re-enable `auto_cfg` if it was disabled at this location: - -```rust,ignore (nightly) -#[doc(auto_cfg = false)] // Disabling `auto_cfg` -#[doc(auto_cfg(show(unix)))] // `auto_cfg` is re-enabled. -pub fn foo() {} -``` - -### `#[doc(auto_cfg)`/`#[doc(auto_cfg = true)]`/`#[doc(auto_cfg = false)]` - -By default, `#[doc(auto_cfg)]` is enabled at the crate-level. When it's enabled, Rustdoc will automatically display `cfg(...)` compatibility information as-if the same `#[doc(cfg(...))]` had been specified. - -This attribute impacts the item on which it is used and its descendants. - -So if we take back the previous example: - -```rust -#[cfg(feature = "futures-io")] -pub mod futures {} -``` - -There's no need to "duplicate" the `cfg` into a `doc(cfg())` to make Rustdoc display it. - -In some situations, the detailed conditional compilation rules used to implement the feature might not serve as good documentation (for example, the list of supported platforms might be very long, and it might be better to document them in one place). To turn it off, add the `#[doc(auto_cfg = false)]` attribute on the item. - -If no argument is specified (ie `#[doc(auto_cfg)]`), it's the same as writing `#[doc(auto_cfg = true)]`. - -## Inheritance - -Rustdoc merges `cfg` attributes from parent modules to its children. For example, in this case, the module `non_unix` will describe the entire compatibility matrix for the module, and not just its directly attached information: - -```rust,ignore (nightly) -#[doc(cfg(any(windows, unix)))] -pub mod desktop { - #[doc(cfg(not(unix)))] - pub mod non_unix { - // ... - } -} -``` - -This code will display: - -```text -Available on (Windows or Unix) and non-Unix only. -``` - -### Re-exports and inlining - -`cfg` attributes of a re-export are never merged with the re-exported item(s) attributes except if the re-export has the `#[doc(inline)]` attribute. In this case, the `cfg` of the re-exported item will be merged with the re-export's. - -When talking about "attributes merge", we mean that if the re-export has `#[cfg(unix)]` and the re-exported item has `#[cfg(feature = "foo")]`, you will only see `cfg(unix)` on the re-export and only `cfg(feature = "foo")` on the re-exported item, unless the re-export has `#[doc(inline)]`, then you will only see the re-exported item with both `cfg(unix)` and `cfg(feature = "foo")`. - -Example: - -```rust,ignore (nightly) -#[doc(cfg(any(windows, unix)))] -pub mod desktop { - #[doc(cfg(not(unix)))] - pub mod non_unix { - // code - } -} - -#[doc(cfg(target_os = "freebsd"))] -pub use desktop::non_unix as non_unix_desktop; -#[doc(cfg(target_os = "macos"))] -#[doc(inline)] -pub use desktop::non_unix as inlined_non_unix_desktop; -``` - -In this example, `non_unix_desktop` will only display `cfg(target_os = "freeebsd")` and not display any `cfg` from `desktop::non_unix`. - -On the contrary, `inlined_non_unix_desktop` will have cfgs from both the re-export and the re-exported item. - -So that also means that if a crate re-exports a foreign item, unless it has `#[doc(inline)]`, the `cfg` and `doc(cfg)` attributes will not be visible: - -```rust,ignore (nightly) -// dep: -#[cfg(feature = "a")] -pub struct S; - -// crate using dep: - -// There will be no mention of `feature = "a"` in the documentation. -pub use dep::S as Y; -``` diff --git a/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md b/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md index 3af53fa58e18c..e9ad4bb98b476 100644 --- a/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md +++ b/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md @@ -297,3 +297,271 @@ list of attributes. In the previous example, both attributes would be present: #![deny(dead_code)] // from the crate-root #![allow(dead_code)] // from `my_mod` ``` + +### `#[doc(cfg)]` and `#[doc(auto_cfg)]` + +This feature aims at providing rustdoc users the possibility to add visual markers to the rendered documentation to know under which conditions an item is available. + +It does not aim to allow having a same item with different `cfg`s to appear more than once in the generated documentation. + +It does not aim to document items which are *inactive* under the current configuration (i.e., “`cfg`ed out”). + +This features adds the following attributes: + + * `#[doc(auto_cfg)]`/`#[doc(auto_cfg = true)]`/`#[doc(auto_cfg = false)]` + * `#[doc(cfg(...))]` + * `#![doc(auto_cfg(hide(...)))]` / `#[doc(auto_cfg(show(...)))]` + +All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `auto_cfg(hide(...))` and `auto_cfg(show(...))` are provided: they allow a child item to override its parent. + +#### `#[doc(cfg(...))]` + +This attribute provides a standardized format to override `#[cfg()]` attributes to document conditionally available items. Example: + +```rust,ignore (nightly) +// the "real" cfg condition +#[cfg(feature = "futures-io")] +// the `doc(cfg())` so it's displayed to the readers +#[doc(cfg(feature = "futures-io"))] +pub mod futures {} +``` + +It will display in the documentation for this module: + +```text +This is supported on feature="futures-io" only. +``` + +You can use it to display information in generated documentation, whether or not there is a `#[cfg()]` attribute: + +```rust,ignore (nightly) +#[doc(cfg(feature = "futures-io"))] +pub mod futures {} +``` + +It will be displayed exactly the same as the previous code. + +This attribute has the same syntax as conditional compilation, but it only causes documentation to be added. This means `#[doc(cfg(not(windows)))]` will not cause your docs to be hidden on non-windows targets, even though `#[cfg(not(windows))]` does do that. + +If `doc(auto_cfg)` is enabled on the item, `doc(cfg)` will override it anyway so in the two previous examples, even if the `doc(auto_cfg)` feature was enabled, it would still display the same thing. + +This attribute works on modules and on items. + +#### `#[doc(auto_cfg(hide(...)))]` + +This attribute is used to prevent some `cfg` to be generated in the visual markers. It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. So in the previous example: + +```rust,ignore (nightly) +#[cfg(any(unix, feature = "futures-io"))] +pub mod futures {} +``` + +It currently displays both `unix` and `feature = "futures-io"` into the documentation, which is not great. To prevent the `unix` cfg to ever be displayed, you can use this attribute at the crate root level: + +```rust,ignore (nightly) +#![doc(auto_cfg(hide(unix)))] +``` + +Or directly on a given item/module as it covers any of the item's descendants: + +```rust,ignore (nightly) +#[doc(auto_cfg(hide(unix)))] +#[cfg(any(unix, feature = "futures-io"))] +pub mod futures { + // `futures` and all its descendants won't display "unix" in their cfgs. +} +``` + +Then, the `unix` cfg will never be displayed into the documentation. + +Rustdoc currently hides `doc` and `doctest` attributes by default and reserves the right to change the list of "hidden by default" attributes. + +The attribute accepts only a list of identifiers or key/value items. So you can write: + +```rust,ignore (nightly) +#[doc(auto_cfg(hide(unix, doctest, feature = "something")))] +#[doc(auto_cfg(hide()))] +``` + +But you cannot write: + +```rust,ignore (nightly) +#[doc(auto_cfg(hide(not(unix))))] +``` + +So if we use `doc(auto_cfg(hide(unix)))`, it means it will hide all mentions of `unix`: + +```rust,ignore (nightly) +#[cfg(unix)] // nothing displayed +#[cfg(any(unix))] // nothing displayed +#[cfg(any(unix, windows))] // only `windows` displayed +``` + +However, it only impacts the `unix` cfg, not the feature: + +```rust,ignore (nightly) +#[cfg(feature = "unix")] // `feature = "unix"` is displayed +``` + +If `cfg_auto(show(...))` and `cfg_auto(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example: + +```rust,ignore (nightly) +#[doc(auto_cfg(hide(unix)))] +#[doc(auto_cfg(show(unix)))] // Error! +pub fn foo() {} +``` + +Using this attribute will re-enable `auto_cfg` if it was disabled at this location: + +```rust,ignore (nightly) +#[doc(auto_cfg = false)] // Disabling `auto_cfg` +pub fn foo() {} +``` + +And using `doc(auto_cfg)` will re-enable it: + +```rust,ignore (nightly) +#[doc(auto_cfg = false)] // Disabling `auto_cfg` +pub mod module { + #[doc(auto_cfg(hide(unix)))] // `auto_cfg` is re-enabled. + pub fn foo() {} +} +``` + +However, using `doc(auto_cfg = ...)` and `doc(auto_cfg(...))` on the same item will emit an error: + +```rust,ignore (nightly) +#[doc(auto_cfg = false)] +#[doc(auto_cfg(hide(unix)))] // error +pub fn foo() {} +``` + +The reason behind this is that `doc(auto_cfg = ...)` enables or disables the feature, whereas `doc(auto_cfg(...))` enables it unconditionally, making the first attribute to appear useless as it will be overidden by the next `doc(auto_cfg)` attribute. + +#### `#[doc(auto_cfg(show(...)))]` + +This attribute does the opposite of `#[doc(auto_cfg(hide(...)))]`: if you used `#[doc(auto_cfg(hide(...)))]` and want to revert its effect on an item and its descendants, you can use `#[doc(auto_cfg(show(...)))]`. +It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. + +For example: + +```rust,ignore (nightly) +#[doc(auto_cfg(hide(unix)))] +#[cfg(any(unix, feature = "futures-io"))] +pub mod futures { + // `futures` and all its descendants won't display "unix" in their cfgs. + #[doc(auto_cfg(show(unix)))] + pub mod child { + // `child` and all its descendants will display "unix" in their cfgs. + } +} +``` + +The attribute accepts only a list of identifiers or key/value items. So you can write: + +```rust,ignore (nightly) +#[doc(auto_cfg(show(unix, doctest, feature = "something")))] +#[doc(auto_cfg(show()))] +``` + +But you cannot write: + +```rust,ignore (nightly) +#[doc(auto_cfg(show(not(unix))))] +``` + +If `auto_cfg(show(...))` and `auto_cfg(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example: + +```rust,ignore (nightly) +#[doc(auto_cfg(show(unix)))] +#[doc(auto_cfg(hide(unix)))] // Error! +pub fn foo() {} +``` + +Using this attribute will re-enable `auto_cfg` if it was disabled at this location: + +```rust,ignore (nightly) +#[doc(auto_cfg = false)] // Disabling `auto_cfg` +#[doc(auto_cfg(show(unix)))] // `auto_cfg` is re-enabled. +pub fn foo() {} +``` + +#### `#[doc(auto_cfg)`/`#[doc(auto_cfg = true)]`/`#[doc(auto_cfg = false)]` + +By default, `#[doc(auto_cfg)]` is enabled at the crate-level. When it's enabled, Rustdoc will automatically display `cfg(...)` compatibility information as-if the same `#[doc(cfg(...))]` had been specified. + +This attribute impacts the item on which it is used and its descendants. + +So if we take back the previous example: + +```rust +#[cfg(feature = "futures-io")] +pub mod futures {} +``` + +There's no need to "duplicate" the `cfg` into a `doc(cfg())` to make Rustdoc display it. + +In some situations, the detailed conditional compilation rules used to implement the feature might not serve as good documentation (for example, the list of supported platforms might be very long, and it might be better to document them in one place). To turn it off, add the `#[doc(auto_cfg = false)]` attribute on the item. + +If no argument is specified (ie `#[doc(auto_cfg)]`), it's the same as writing `#[doc(auto_cfg = true)]`. + +#### Inheritance + +Rustdoc merges `cfg` attributes from parent modules to its children. For example, in this case, the module `non_unix` will describe the entire compatibility matrix for the module, and not just its directly attached information: + +```rust,ignore (nightly) +#[doc(cfg(any(windows, unix)))] +pub mod desktop { + #[doc(cfg(not(unix)))] + pub mod non_unix { + // ... + } +} +``` + +This code will display: + +```text +Available on (Windows or Unix) and non-Unix only. +``` + +#### Re-exports and inlining + +`cfg` attributes of a re-export are never merged with the re-exported item(s) attributes except if the re-export has the `#[doc(inline)]` attribute. In this case, the `cfg` of the re-exported item will be merged with the re-export's. + +When talking about "attributes merge", we mean that if the re-export has `#[cfg(unix)]` and the re-exported item has `#[cfg(feature = "foo")]`, you will only see `cfg(unix)` on the re-export and only `cfg(feature = "foo")` on the re-exported item, unless the re-export has `#[doc(inline)]`, then you will only see the re-exported item with both `cfg(unix)` and `cfg(feature = "foo")`. + +Example: + +```rust,ignore (nightly) +#[doc(cfg(any(windows, unix)))] +pub mod desktop { + #[doc(cfg(not(unix)))] + pub mod non_unix { + // code + } +} + +#[doc(cfg(target_os = "freebsd"))] +pub use desktop::non_unix as non_unix_desktop; +#[doc(cfg(target_os = "macos"))] +#[doc(inline)] +pub use desktop::non_unix as inlined_non_unix_desktop; +``` + +In this example, `non_unix_desktop` will only display `cfg(target_os = "freeebsd")` and not display any `cfg` from `desktop::non_unix`. + +On the contrary, `inlined_non_unix_desktop` will have cfgs from both the re-export and the re-exported item. + +So that also means that if a crate re-exports a foreign item, unless it has `#[doc(inline)]`, the `cfg` and `doc(cfg)` attributes will not be visible: + +```rust,ignore (nightly) +// dep: +#[cfg(feature = "a")] +pub struct S; + +// crate using dep: + +// There will be no mention of `feature = "a"` in the documentation. +pub use dep::S as Y; +``` diff --git a/src/doc/unstable-book/src/language-features/doc-cfg.md b/src/doc/unstable-book/src/language-features/doc-cfg.md deleted file mode 100644 index b15f5ee66aba1..0000000000000 --- a/src/doc/unstable-book/src/language-features/doc-cfg.md +++ /dev/null @@ -1,46 +0,0 @@ -# `doc_cfg` - -The tracking issue for this feature is: [#43781] - ------- - -The `doc_cfg` feature allows an API be documented as only available in some specific platforms. -This attribute has two effects: - -1. In the annotated item's documentation, there will be a message saying "Available on - (platform) only". - -2. The item's doc-tests will only run on the specific platform. - -In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a -special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your -crate. - -This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the -standard library be documented. - -```rust -#![feature(doc_cfg)] - -#[cfg(any(windows, doc))] -#[doc(cfg(windows))] -/// The application's icon in the notification area (a.k.a. system tray). -/// -/// # Examples -/// -/// ```no_run -/// extern crate my_awesome_ui_library; -/// use my_awesome_ui_library::current_app; -/// use my_awesome_ui_library::windows::notification; -/// -/// let icon = current_app().get::(); -/// icon.show(); -/// icon.show_message("Hello"); -/// ``` -pub struct Icon { - // ... -} -``` - -[#43781]: https://github.com/rust-lang/rust/issues/43781 -[#43348]: https://github.com/rust-lang/rust/issues/43348 diff --git a/src/librustdoc/passes/propagate_doc_cfg.rs b/src/librustdoc/passes/propagate_doc_cfg.rs index 95f5537f394c0..f0cba0d8bba0f 100644 --- a/src/librustdoc/passes/propagate_doc_cfg.rs +++ b/src/librustdoc/passes/propagate_doc_cfg.rs @@ -17,11 +17,7 @@ pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass { }; pub(crate) fn propagate_doc_cfg(cr: Crate, cx: &mut DocContext<'_>) -> Crate { - if cx.tcx.features().doc_cfg() { - CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr) - } else { - cr - } + CfgPropagator { cx, cfg_info: CfgInfo::default() }.fold_crate(cr) } struct CfgPropagator<'a, 'tcx> { diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs index b87fdeea89da0..6690ab90eb057 100644 --- a/tests/rustdoc-gui/src/lib2/lib.rs +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -1,6 +1,5 @@ // ignore-tidy-linelength -#![feature(doc_cfg)] #![feature(negative_impls)] pub mod another_folder; diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 0ee2a66d4b689..a1317ec2da462 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -6,7 +6,6 @@ #![crate_name = "test_docs"] #![allow(internal_features)] #![feature(rustdoc_internals)] -#![feature(doc_cfg)] #![feature(associated_type_defaults)] /*! diff --git a/tests/rustdoc-ui/cfg-boolean-literal.rs b/tests/rustdoc-ui/cfg-boolean-literal.rs index 74808d066c715..845194e1ded6a 100644 --- a/tests/rustdoc-ui/cfg-boolean-literal.rs +++ b/tests/rustdoc-ui/cfg-boolean-literal.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(doc_cfg)] - #[doc(cfg(false))] pub fn foo() {} diff --git a/tests/rustdoc-ui/cfg-hide-show-conflict.rs b/tests/rustdoc-ui/cfg-hide-show-conflict.rs index 8e98b95c85bb9..a8a50fe15c7e1 100644 --- a/tests/rustdoc-ui/cfg-hide-show-conflict.rs +++ b/tests/rustdoc-ui/cfg-hide-show-conflict.rs @@ -1,3 +1,2 @@ -#![feature(doc_cfg)] #![doc(auto_cfg(hide(target_os = "linux")))] #![doc(auto_cfg(show(windows, target_os = "linux")))] //~ ERROR diff --git a/tests/rustdoc-ui/cfg-hide-show-conflict.stderr b/tests/rustdoc-ui/cfg-hide-show-conflict.stderr index 22231e82cd7bf..d2d0564606a54 100644 --- a/tests/rustdoc-ui/cfg-hide-show-conflict.stderr +++ b/tests/rustdoc-ui/cfg-hide-show-conflict.stderr @@ -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:3:31 + --> $DIR/cfg-hide-show-conflict.rs:2:31 | LL | #![doc(auto_cfg(show(windows, target_os = "linux")))] | ^^^^^^^^^^^^^^^^^^^ | note: first change was here - --> $DIR/cfg-hide-show-conflict.rs:2:22 + --> $DIR/cfg-hide-show-conflict.rs:1:22 | LL | #![doc(auto_cfg(hide(target_os = "linux")))] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/rustdoc-ui/doc-cfg-2.rs b/tests/rustdoc-ui/doc-cfg-2.rs index 7a5d1f3e3dbb5..82c38e585bed4 100644 --- a/tests/rustdoc-ui/doc-cfg-2.rs +++ b/tests/rustdoc-ui/doc-cfg-2.rs @@ -1,5 +1,3 @@ -#![feature(doc_cfg)] - #[doc(cfg(foo), cfg(bar))] //~^ WARN unexpected `cfg` condition name: `foo` //~| WARN unexpected `cfg` condition name: `bar` diff --git a/tests/rustdoc-ui/doc-cfg-2.stderr b/tests/rustdoc-ui/doc-cfg-2.stderr index 1272e569897b5..4b4f775d6da4d 100644 --- a/tests/rustdoc-ui/doc-cfg-2.stderr +++ b/tests/rustdoc-ui/doc-cfg-2.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `foo` - --> $DIR/doc-cfg-2.rs:3:11 + --> $DIR/doc-cfg-2.rs:1:11 | LL | #[doc(cfg(foo), cfg(bar))] | ^^^ @@ -10,7 +10,7 @@ LL | #[doc(cfg(foo), cfg(bar))] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `bar` - --> $DIR/doc-cfg-2.rs:3:21 + --> $DIR/doc-cfg-2.rs:1:21 | LL | #[doc(cfg(foo), cfg(bar))] | ^^^ @@ -19,7 +19,7 @@ LL | #[doc(cfg(foo), cfg(bar))] = note: see for more information about checking conditional configuration error: only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]` - --> $DIR/doc-cfg-2.rs:6:16 + --> $DIR/doc-cfg-2.rs:4:16 | LL | #[doc(auto_cfg(42))] | ^^ @@ -27,37 +27,37 @@ LL | #[doc(auto_cfg(42))] = note: `#[deny(invalid_doc_attributes)]` on by default error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items - --> $DIR/doc-cfg-2.rs:7:21 + --> $DIR/doc-cfg-2.rs:5:21 | LL | #[doc(auto_cfg(hide(true)))] | ^^^^ error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items - --> $DIR/doc-cfg-2.rs:8:21 + --> $DIR/doc-cfg-2.rs:6:21 | LL | #[doc(auto_cfg(hide(42)))] | ^^ error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items - --> $DIR/doc-cfg-2.rs:9:21 + --> $DIR/doc-cfg-2.rs:7:21 | LL | #[doc(auto_cfg(hide("a")))] | ^^^ error: expected boolean for `#[doc(auto_cfg = ...)]` - --> $DIR/doc-cfg-2.rs:10:18 + --> $DIR/doc-cfg-2.rs:8:18 | LL | #[doc(auto_cfg = 42)] | ^^ error: expected boolean for `#[doc(auto_cfg = ...)]` - --> $DIR/doc-cfg-2.rs:11:18 + --> $DIR/doc-cfg-2.rs:9:18 | LL | #[doc(auto_cfg = "a")] | ^^^ warning: unexpected `cfg` condition name: `feature` - --> $DIR/doc-cfg-2.rs:14:21 + --> $DIR/doc-cfg-2.rs:12:21 | LL | #[doc(auto_cfg(hide(feature = "windows")))] | ^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | #[doc(auto_cfg(hide(feature = "windows")))] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `foo` - --> $DIR/doc-cfg-2.rs:16:21 + --> $DIR/doc-cfg-2.rs:14:21 | LL | #[doc(auto_cfg(hide(foo)))] | ^^^ diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr b/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr index 3f67b85900aab..7c96def340acd 100644 --- a/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `foo` - --> $DIR/doc-cfg-check-cfg.rs:15:11 + --> $DIR/doc-cfg-check-cfg.rs:14:11 | LL | #[doc(cfg(foo))] | ^^^ @@ -9,7 +9,7 @@ LL | #[doc(cfg(foo))] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `foo` - --> $DIR/doc-cfg-check-cfg.rs:19:11 + --> $DIR/doc-cfg-check-cfg.rs:18:11 | LL | #[doc(cfg(foo))] | ^^^ @@ -18,7 +18,7 @@ LL | #[doc(cfg(foo))] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `foo` - --> $DIR/doc-cfg-check-cfg.rs:12:12 + --> $DIR/doc-cfg-check-cfg.rs:11:12 | LL | #![doc(cfg(foo))] | ^^^ diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.rs b/tests/rustdoc-ui/doc-cfg-check-cfg.rs index 7d37077a32ddc..c221e5c1ac9c9 100644 --- a/tests/rustdoc-ui/doc-cfg-check-cfg.rs +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.rs @@ -8,7 +8,6 @@ //@[cfg_empty] compile-flags: --check-cfg cfg() //@[cfg_foo] compile-flags: --check-cfg cfg(foo) -#![feature(doc_cfg)] #![doc(cfg(foo))] //[cfg_empty]~^ WARN unexpected `cfg` condition name: `foo` diff --git a/tests/rustdoc-ui/doc-cfg-unstable.rs b/tests/rustdoc-ui/doc-cfg-unstable.rs index b77c3654497d2..08cb35af98144 100644 --- a/tests/rustdoc-ui/doc-cfg-unstable.rs +++ b/tests/rustdoc-ui/doc-cfg-unstable.rs @@ -1,5 +1,4 @@ // #138113: rustdoc didn't gate unstable predicates inside `doc(cfg(..))` -#![feature(doc_cfg)] // `cfg_version` #[doc(cfg(sanitize = "thread"))] //~ ERROR `cfg(sanitize)` is experimental and subject to change diff --git a/tests/rustdoc-ui/doc-cfg-unstable.stderr b/tests/rustdoc-ui/doc-cfg-unstable.stderr index 9651c5f1a0b09..a3db0c1d7f266 100644 --- a/tests/rustdoc-ui/doc-cfg-unstable.stderr +++ b/tests/rustdoc-ui/doc-cfg-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: `cfg(sanitize)` is experimental and subject to change - --> $DIR/doc-cfg-unstable.rs:5:11 + --> $DIR/doc-cfg-unstable.rs:4:11 | LL | #[doc(cfg(sanitize = "thread"))] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/rustdoc-ui/doc-cfg.rs b/tests/rustdoc-ui/doc-cfg.rs index f30d80aa9cda5..122515a0a2093 100644 --- a/tests/rustdoc-ui/doc-cfg.rs +++ b/tests/rustdoc-ui/doc-cfg.rs @@ -1,5 +1,3 @@ -#![feature(doc_cfg)] - #[doc(cfg(), cfg(foo, bar))] //~^ ERROR malformed `doc` attribute input //~| ERROR malformed `doc` attribute input diff --git a/tests/rustdoc-ui/doc-cfg.stderr b/tests/rustdoc-ui/doc-cfg.stderr index ce16ec31d8754..08c44a0b5cb49 100644 --- a/tests/rustdoc-ui/doc-cfg.stderr +++ b/tests/rustdoc-ui/doc-cfg.stderr @@ -1,5 +1,5 @@ error[E0805]: malformed `doc` attribute input - --> $DIR/doc-cfg.rs:3:1 + --> $DIR/doc-cfg.rs:1:1 | LL | #[doc(cfg(), cfg(foo, bar))] | ^^^^^^^^^--^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[doc(cfg(), cfg(foo, bar))] | expected a single argument here error[E0805]: malformed `doc` attribute input - --> $DIR/doc-cfg.rs:3:1 + --> $DIR/doc-cfg.rs:1:1 | LL | #[doc(cfg(), cfg(foo, bar))] | ^^^^^^^^^^^^^^^^----------^^ @@ -15,7 +15,7 @@ LL | #[doc(cfg(), cfg(foo, bar))] | expected a single argument here error[E0805]: malformed `doc` attribute input - --> $DIR/doc-cfg.rs:6:1 + --> $DIR/doc-cfg.rs:4:1 | LL | #[doc(cfg())] | ^^^^^^^^^--^^ @@ -23,7 +23,7 @@ LL | #[doc(cfg())] | expected a single argument here error[E0805]: malformed `doc` attribute input - --> $DIR/doc-cfg.rs:7:1 + --> $DIR/doc-cfg.rs:5:1 | LL | #[doc(cfg(foo, bar))] | ^^^^^^^^^----------^^ @@ -31,7 +31,7 @@ LL | #[doc(cfg(foo, bar))] | expected a single argument here error[E0539]: malformed `doc` attribute input - --> $DIR/doc-cfg.rs:8:1 + --> $DIR/doc-cfg.rs:6:1 | LL | #[doc(auto_cfg(hide(foo::bar)))] | ^^^^^^^^^^^^^^^^^^^^--------^^^^ diff --git a/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs index dd04adfe6179c..572d114a04ff5 100644 --- a/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs +++ b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs @@ -3,12 +3,9 @@ //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" -#![feature(doc_cfg)] - // Make sure `cfg(doc)` is set when finding doctests but not inside the doctests. /// ``` -/// #![feature(doc_cfg)] /// assert!(!cfg!(doc)); /// ``` #[cfg(doc)] diff --git a/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout index 5b07fc4c87af5..89b88bb650fa5 100644 --- a/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout +++ b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) ... ok +test $DIR/doc-test-rustdoc-feature.rs - Foo (line 8) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/tests/rustdoc-ui/feature-gate-doc_cfg.rs b/tests/rustdoc-ui/feature-gate-doc_cfg.rs deleted file mode 100644 index b474a1524bc19..0000000000000 --- a/tests/rustdoc-ui/feature-gate-doc_cfg.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![doc(auto_cfg)] //~ ERROR -#![doc(auto_cfg(false))] //~ ERROR -#![doc(auto_cfg(true))] //~ ERROR -#![doc(auto_cfg(hide(feature = "solecism")))] //~ ERROR -#![doc(auto_cfg(show(feature = "bla")))] //~ ERROR -#![doc(cfg(feature = "solecism"))] //~ ERROR diff --git a/tests/rustdoc-ui/feature-gate-doc_cfg.stderr b/tests/rustdoc-ui/feature-gate-doc_cfg.stderr index 68a86c1abb777..a631f8ebc3bac 100644 --- a/tests/rustdoc-ui/feature-gate-doc_cfg.stderr +++ b/tests/rustdoc-ui/feature-gate-doc_cfg.stderr @@ -1,63 +1,16 @@ -error[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:1:1 - | -LL | #![doc(auto_cfg)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #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[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:2:1 +error: only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]` + --> $DIR/feature-gate-doc_cfg.rs:1:17 | LL | #![doc(auto_cfg(false))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | - = note: see issue #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 + = note: `#[deny(invalid_doc_attributes)]` on by default -error[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:3:1 +error: only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]` + --> $DIR/feature-gate-doc_cfg.rs:2:17 | LL | #![doc(auto_cfg(true))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #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[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:4:1 - | -LL | #![doc(auto_cfg(hide(feature = "solecism")))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #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[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:5:1 - | -LL | #![doc(auto_cfg(show(feature = "bla")))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #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[E0658]: `#[doc(cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:6:1 - | -LL | #![doc(cfg(feature = "solecism"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #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 6 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/rustdoc-ui/invalid-cfg.rs b/tests/rustdoc-ui/invalid-cfg.rs index 4d00edc0c7c24..52b420dd82530 100644 --- a/tests/rustdoc-ui/invalid-cfg.rs +++ b/tests/rustdoc-ui/invalid-cfg.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #[doc(cfg = "x")] //~ ERROR malformed `doc` attribute input #[doc(cfg(x, y))] //~ ERROR malformed `doc` attribute input pub struct S {} diff --git a/tests/rustdoc-ui/invalid-cfg.stderr b/tests/rustdoc-ui/invalid-cfg.stderr index 5396110709692..3e32eacc6b2a8 100644 --- a/tests/rustdoc-ui/invalid-cfg.stderr +++ b/tests/rustdoc-ui/invalid-cfg.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:2:1 + --> $DIR/invalid-cfg.rs:1:1 | LL | #[doc(cfg = "x")] | ^^^^^^^^^^-----^^ @@ -7,7 +7,7 @@ LL | #[doc(cfg = "x")] | expected this to be a list error[E0805]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:3:1 + --> $DIR/invalid-cfg.rs:2:1 | LL | #[doc(cfg(x, y))] | ^^^^^^^^^------^^ @@ -15,7 +15,7 @@ LL | #[doc(cfg(x, y))] | expected a single argument here error[E0539]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:7:1 + --> $DIR/invalid-cfg.rs:6:1 | LL | #[doc(cfg = "x")] | ^^^^^^^^^^-----^^ @@ -23,7 +23,7 @@ LL | #[doc(cfg = "x")] | expected this to be a list error[E0805]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:8:1 + --> $DIR/invalid-cfg.rs:7:1 | LL | #[doc(cfg(x, y))] | ^^^^^^^^^------^^ @@ -31,7 +31,7 @@ LL | #[doc(cfg(x, y))] | expected a single argument here error[E0539]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:12:1 + --> $DIR/invalid-cfg.rs:11:1 | LL | #[doc(cfg = "x")] | ^^^^^^^^^^-----^^ @@ -39,7 +39,7 @@ LL | #[doc(cfg = "x")] | expected this to be a list error[E0805]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:13:1 + --> $DIR/invalid-cfg.rs:12:1 | LL | #[doc(cfg(x, y))] | ^^^^^^^^^------^^ @@ -47,7 +47,7 @@ LL | #[doc(cfg(x, y))] | expected a single argument here error[E0539]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:18:1 + --> $DIR/invalid-cfg.rs:17:1 | LL | #[doc(cfg = "x")] | ^^^^^^^^^^-----^^ @@ -55,7 +55,7 @@ LL | #[doc(cfg = "x")] | expected this to be a list error[E0805]: malformed `doc` attribute input - --> $DIR/invalid-cfg.rs:19:1 + --> $DIR/invalid-cfg.rs:18:1 | LL | #[doc(cfg(x, y))] | ^^^^^^^^^------^^ diff --git a/tests/rustdoc-ui/lints/doc_cfg_hide.rs b/tests/rustdoc-ui/lints/doc_cfg_hide.rs index 397b21393e5c7..4f2625d00ce43 100644 --- a/tests/rustdoc-ui/lints/doc_cfg_hide.rs +++ b/tests/rustdoc-ui/lints/doc_cfg_hide.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #![doc(auto_cfg(hide = "test"))] //~ ERROR #![doc(auto_cfg(hide))] //~ ERROR #![doc(auto_cfg(hide(not(windows))))] //~ ERROR diff --git a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr index acbe6ef69dd58..995b231aea7af 100644 --- a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr +++ b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr @@ -1,5 +1,5 @@ error: `#![doc(auto_cfg(hide(...)))]` expects a list of items - --> $DIR/doc_cfg_hide.rs:2:17 + --> $DIR/doc_cfg_hide.rs:1:17 | 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(...)))]` expects a list of items - --> $DIR/doc_cfg_hide.rs:3:17 + --> $DIR/doc_cfg_hide.rs:2:17 | LL | #![doc(auto_cfg(hide))] | ^^^^ error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items - --> $DIR/doc_cfg_hide.rs:4:22 + --> $DIR/doc_cfg_hide.rs:3:22 | LL | #![doc(auto_cfg(hide(not(windows))))] | ^^^^^^^^^^^^ diff --git a/tests/rustdoc/cfg-bool.rs b/tests/rustdoc/cfg-bool.rs index 0aaa132e0b540..5bfe44c0f364c 100644 --- a/tests/rustdoc/cfg-bool.rs +++ b/tests/rustdoc/cfg-bool.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #![crate_name = "foo"] // regression test for https://github.com/rust-lang/rust/issues/138112 diff --git a/tests/rustdoc/doc-auto-cfg-public-in-private.rs b/tests/rustdoc/doc-auto-cfg-public-in-private.rs index b78e3f1b932c2..ebc84c1a4bfbc 100644 --- a/tests/rustdoc/doc-auto-cfg-public-in-private.rs +++ b/tests/rustdoc/doc-auto-cfg-public-in-private.rs @@ -1,7 +1,6 @@ // This test ensures that even though private items are removed from generated docs, // their `cfg`s will still impact their child items. -#![feature(doc_cfg)] #![crate_name = "foo"] pub struct X; diff --git a/tests/rustdoc/doc-auto-cfg.rs b/tests/rustdoc/doc-auto-cfg.rs index e56cf18d08a0c..8021625d94818 100644 --- a/tests/rustdoc/doc-auto-cfg.rs +++ b/tests/rustdoc/doc-auto-cfg.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #![crate_name = "foo"] //@ has foo/fn.foo.html diff --git a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs index e919206d3a478..d5ce6d1d85b4b 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-hide.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-hide.rs @@ -1,5 +1,4 @@ #![crate_name = "oud"] -#![feature(doc_cfg)] #![doc(auto_cfg(hide(feature = "solecism")))] diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs index 9ae8b8fca4f7a..27923893bddae 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit-gate.rs @@ -1,5 +1,4 @@ //@ compile-flags:--cfg feature="worricow" -#![feature(doc_cfg)] #![crate_name = "xenogenous"] //@ has 'xenogenous/struct.Worricow.html' diff --git a/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs index c092675ee5cf9..0cdb59580f42d 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-implicit.rs @@ -1,5 +1,4 @@ #![crate_name = "funambulism"] -#![feature(doc_cfg)] //@ has 'funambulism/struct.Disorbed.html' //@ count - '//*[@class="stab portability"]' 1 diff --git a/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs index 256e3b0015c63..332f3596fcd9f 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-inherit-from-module-79201.rs @@ -1,8 +1,6 @@ // https://github.com/rust-lang/rust/issues/79201 #![crate_name="foo"] -#![feature(doc_cfg)] - //@ has 'foo/trait.Foo.html' //@ count - '//*[@class="stab portability"]' 6 //@ matches - '//*[@class="stab portability"]' 'crate feature foo-root' diff --git a/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs index ce70de289c623..36e9257741f49 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-simplification.rs @@ -1,5 +1,4 @@ #![crate_name = "globuliferous"] -#![feature(doc_cfg)] //@ has 'globuliferous/index.html' //@ count - '//*[@class="stab portability"]' 1 diff --git a/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs index b66e86e36af8b..2a1a82a132ba3 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-target-feature.rs @@ -4,8 +4,6 @@ // #49723: rustdoc didn't add target features when extracting or running doctests -#![feature(doc_cfg)] - /// Foo /// /// # Examples diff --git a/tests/rustdoc/doc-cfg/doc-cfg-traits.rs b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs index 1256a7ae2c171..cd055e0843a86 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg-traits.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg-traits.rs @@ -1,5 +1,5 @@ #![crate_name = "myrmecophagous"] -#![feature(doc_cfg, associated_type_defaults)] +#![feature(associated_type_defaults)] //@ has 'myrmecophagous/index.html' //@ count - '//*[@class="stab portability"]' 2 diff --git a/tests/rustdoc/doc-cfg/doc-cfg.rs b/tests/rustdoc/doc-cfg/doc-cfg.rs index 652c8419b4fb8..c11d8c8dbd0bb 100644 --- a/tests/rustdoc/doc-cfg/doc-cfg.rs +++ b/tests/rustdoc/doc-cfg/doc-cfg.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #![feature(target_feature, cfg_target_feature)] //@ has doc_cfg/struct.Portable.html diff --git a/tests/rustdoc/doc-cfg/duplicate-cfg.rs b/tests/rustdoc/doc-cfg/duplicate-cfg.rs index 93f26ab944d34..cd6c8b1c806fe 100644 --- a/tests/rustdoc/doc-cfg/duplicate-cfg.rs +++ b/tests/rustdoc/doc-cfg/duplicate-cfg.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] -#![feature(doc_cfg)] //@ has 'foo/index.html' //@ matches '-' '//dt//*[@class="stab portability"]' '^sync$' diff --git a/tests/rustdoc/doc_auto_cfg.rs b/tests/rustdoc/doc_auto_cfg.rs index a1903e1a0ca3d..95efdd16b971c 100644 --- a/tests/rustdoc/doc_auto_cfg.rs +++ b/tests/rustdoc/doc_auto_cfg.rs @@ -1,7 +1,6 @@ // Basic tests covering RFC 3631 features. #![crate_name = "foo"] -#![feature(doc_cfg)] #![doc(auto_cfg(hide(feature = "hidden")))] //@ has 'foo/index.html' diff --git a/tests/rustdoc/doc_auto_cfg_reexports.rs b/tests/rustdoc/doc_auto_cfg_reexports.rs index ecfe9aabcfed4..d0fe19794ea37 100644 --- a/tests/rustdoc/doc_auto_cfg_reexports.rs +++ b/tests/rustdoc/doc_auto_cfg_reexports.rs @@ -1,7 +1,6 @@ // 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' diff --git a/tests/rustdoc/feature-gate-doc_auto_cfg.rs b/tests/rustdoc/feature-gate-doc_auto_cfg.rs index 75a488bc8ab16..99c6799ab947d 100644 --- a/tests/rustdoc/feature-gate-doc_auto_cfg.rs +++ b/tests/rustdoc/feature-gate-doc_auto_cfg.rs @@ -1,5 +1,3 @@ -#![feature(doc_cfg)] - #![crate_name = "foo"] //@ has foo/fn.foo.html diff --git a/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs index f24ebcd52acb6..38d4eee9622d4 100644 --- a/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs +++ b/tests/rustdoc/impl/doc_auto_cfg_nested_impl.rs @@ -1,6 +1,5 @@ // Regression test for . -#![feature(doc_cfg)] #![crate_type = "lib"] #![crate_name = "foo"] diff --git a/tests/rustdoc/inline_cross/doc-auto-cfg.rs b/tests/rustdoc/inline_cross/doc-auto-cfg.rs index 6e0f6e22f8c78..17aea20ff1171 100644 --- a/tests/rustdoc/inline_cross/doc-auto-cfg.rs +++ b/tests/rustdoc/inline_cross/doc-auto-cfg.rs @@ -1,7 +1,6 @@ // Test that `doc(auto_cfg)` works with inlined cross-crate re-exports. //@ compile-flags: --cfg feature="extra" --cfg feature="addon" -#![feature(doc_cfg)] #![crate_name = "it"] //@ aux-build: doc-auto-cfg.rs diff --git a/tests/rustdoc/reexport/cfg_doc_reexport.rs b/tests/rustdoc/reexport/cfg_doc_reexport.rs index 2c3b3110fb724..f2975bc7779ef 100644 --- a/tests/rustdoc/reexport/cfg_doc_reexport.rs +++ b/tests/rustdoc/reexport/cfg_doc_reexport.rs @@ -1,4 +1,3 @@ -#![feature(doc_cfg)] #![feature(no_core, lang_items)] #![crate_name = "foo"] diff --git a/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs b/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs index 5b918e0ffd9f2..bf1be62482a82 100644 --- a/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs +++ b/tests/rustdoc/reexport/glob-reexport-attribute-merge-120487.rs @@ -3,7 +3,6 @@ // Regression test for . #![crate_name = "foo"] -#![feature(doc_cfg)] //@ has 'foo/index.html' // There are two items. diff --git a/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs index b0f7df6f3e2d4..80704ce431d94 100644 --- a/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs +++ b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs @@ -2,7 +2,6 @@ // the reexported item whereas glob reexports do with the `doc_auto_cfg` feature. #![crate_name = "foo"] -#![feature(doc_cfg)] //@ has 'foo/index.html' // There are two items. diff --git a/tests/rustdoc/reexport/reexport-attr-merge.rs b/tests/rustdoc/reexport/reexport-attr-merge.rs index aef302eb0b29a..740d9c34bb290 100644 --- a/tests/rustdoc/reexport/reexport-attr-merge.rs +++ b/tests/rustdoc/reexport/reexport-attr-merge.rs @@ -3,7 +3,6 @@ // are not copied from an item when inlined. #![crate_name = "foo"] -#![feature(doc_cfg)] //@ has 'foo/index.html' diff --git a/tests/rustdoc/reexport/reexport-cfg.rs b/tests/rustdoc/reexport/reexport-cfg.rs index b624e5acf502e..a46d51b9f13ad 100644 --- a/tests/rustdoc/reexport/reexport-cfg.rs +++ b/tests/rustdoc/reexport/reexport-cfg.rs @@ -2,7 +2,6 @@ // include `cfg`s from the previous chained items. #![crate_name = "foo"] -#![feature(doc_cfg)] mod foo { #[cfg(not(feature = "foo"))] diff --git a/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs b/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs index f83f28f458ef5..676767fbfd4f9 100644 --- a/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs +++ b/tests/rustdoc/reexport/reexport-stability-tags-deprecated-and-portability.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] -#![feature(doc_cfg)] pub mod tag { #[deprecated(since = "0.1.8", note = "Use bar() instead")] diff --git a/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs b/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs index adf3eed204a26..6d063d64c6d9b 100644 --- a/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs +++ b/tests/rustdoc/reexport/reexport-stability-tags-unstable-and-portability.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] -#![feature(doc_cfg)] #![feature(staged_api)] #![stable(feature = "rust1", since = "1.0.0")] diff --git a/tests/rustdoc/target-feature.rs b/tests/rustdoc/target-feature.rs index f2686f81fbff0..59a08a0ca949e 100644 --- a/tests/rustdoc/target-feature.rs +++ b/tests/rustdoc/target-feature.rs @@ -1,5 +1,3 @@ -#![feature(doc_cfg)] - #![crate_name = "foo"] //@ has 'foo/index.html' diff --git a/tests/ui/feature-gates/feature-gate-doc_cfg.rs b/tests/ui/feature-gates/feature-gate-doc_cfg.rs deleted file mode 100644 index 213a5a8c5a988..0000000000000 --- a/tests/ui/feature-gates/feature-gate-doc_cfg.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[doc(cfg(unix))] //~ ERROR -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-doc_cfg.stderr b/tests/ui/feature-gates/feature-gate-doc_cfg.stderr deleted file mode 100644 index 5315aaeeb3edb..0000000000000 --- a/tests/ui/feature-gates/feature-gate-doc_cfg.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `#[doc(cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:1:1 - | -LL | #[doc(cfg(unix))] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #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`.