diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index b011a2e8117af..18c505e297ff2 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -325,8 +325,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { cfg_hide => doc_cfg_hide masked => doc_masked notable_trait => doc_notable_trait - keyword => doc_keyword ); + + if nested_meta.has_name(sym::keyword) { + let msg = "`#[doc(keyword)]` is meant for internal use only"; + gate_feature_post!(self, rustdoc_internals, attr.span, msg); + } } } diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 608581306bef5..a374b3be06c4a 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -206,6 +206,8 @@ declare_features! ( (active, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None), /// Allows using compiler's own crates. (active, rustc_private, "1.0.0", Some(27812), None), + /// Allows using internal rustdoc features like `doc(primitive)` or `doc(keyword)`. + (active, rustdoc_internals, "1.58.0", Some(90418), None), /// Allows using `#[start]` on a function indicating that it is the program entrypoint. (active, start, "1.0.0", Some(29633), None), /// Allows using `#[structural_match]` which indicates that a type is structurally matchable. @@ -366,12 +368,8 @@ declare_features! ( (active, doc_cfg, "1.21.0", Some(43781), None), /// Allows `#[doc(cfg_hide(...))]`. (active, doc_cfg_hide, "1.57.0", Some(43781), None), - /// Allows using `#[doc(keyword = "...")]`. - (active, doc_keyword, "1.28.0", Some(51315), None), /// Allows `#[doc(masked)]`. (active, doc_masked, "1.21.0", Some(44027), None), - /// Allows using doc(primitive) without a future-incompat warning - (active, doc_primitive, "1.56.0", Some(88070), None), /// Allows `X..Y` patterns. (active, exclusive_range_pattern, "1.11.0", Some(37854), None), /// Allows exhaustive pattern matching on types that contain uninhabited types. diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 4b40040a03671..b9f3b5ad1b1fc 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -76,6 +76,12 @@ declare_features! ( /// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`. (removed, custom_derive, "1.32.0", Some(29644), None, Some("subsumed by `#[proc_macro_derive]`")), + /// Allows using `#[doc(keyword = "...")]`. + (removed, doc_keyword, "1.28.0", Some(51315), None, + Some("merged into `#![feature(rustdoc_internals)]`")), + /// Allows using `doc(primitive)` without a future-incompat warning. + (removed, doc_primitive, "1.56.0", Some(88070), None, + Some("merged into `#![feature(rustdoc_internals)]`")), /// Allows `#[doc(spotlight)]`. /// The attribute was renamed to `#[doc(notable_trait)]` /// and the feature to `doc_notable_trait`. diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 6ff2259dc5b0a..ecb8bf6f8753b 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -963,7 +963,7 @@ impl CheckAttrVisitor<'tcx> { } sym::primitive => { - if !self.tcx.features().doc_primitive { + if !self.tcx.features().rustdoc_internals { self.tcx.struct_span_lint_hir( INVALID_DOC_ATTRIBUTES, hir_id, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9992b1f31fefc..38edefbd803f7 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1154,6 +1154,7 @@ symbols! { rustc_unsafe_specialization_marker, rustc_variance, rustdoc, + rustdoc_internals, rustfmt, rvalue_static_promotion, s, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 4a64e2e2d102d..333a40ec0e1fb 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -165,7 +165,8 @@ #![feature(decl_macro)] #![feature(doc_cfg)] #![feature(doc_notable_trait)] -#![feature(doc_primitive)] +#![cfg_attr(bootstrap, feature(doc_primitive))] +#![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![feature(exhaustive_patterns)] #![feature(doc_cfg_hide)] #![feature(extern_types)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index f2490a77ce0f8..11c63e0968a34 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -275,10 +275,11 @@ #![feature(decl_macro)] #![feature(doc_cfg)] #![feature(doc_cfg_hide)] -#![feature(doc_keyword)] +#![cfg_attr(bootstrap, feature(doc_primitive))] +#![cfg_attr(bootstrap, feature(doc_keyword))] +#![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![feature(doc_masked)] #![feature(doc_notable_trait)] -#![feature(doc_primitive)] #![feature(dropck_eyepatch)] #![feature(duration_checked_float)] #![feature(duration_constants)] diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 16532215c6f33..efb1b6e44ca7d 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -138,7 +138,8 @@ This is for Rust compiler internal use only. Since primitive types are defined in the compiler, there's no place to attach documentation attributes. The `#[doc(primitive)]` attribute is used by the standard library to provide a way -to generate documentation for primitive types, and requires `#![feature(doc_primitive)]` to enable. +to generate documentation for primitive types, and requires `#![feature(rustdoc_internals)]` to +enable. ## Document keywords @@ -149,7 +150,7 @@ Rust keywords are documented in the standard library (look for `match` for examp To do so, the `#[doc(keyword = "...")]` attribute is used. Example: ```rust -#![feature(doc_keyword)] +#![feature(rustdoc_internals)] /// Some documentation about the keyword. #[doc(keyword = "keyword")] diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 14d8b18613087..458bcc4780c6c 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -2,7 +2,7 @@ //! documentation generated so we can test each different features. #![crate_name = "test_docs"] -#![feature(doc_keyword)] +#![feature(rustdoc_internals)] #![feature(doc_cfg)] use std::convert::AsRef; diff --git a/src/test/rustdoc-json/primitive.rs b/src/test/rustdoc-json/primitive.rs index 3a7d6d18c1bd0..b84c2f7c6ac39 100644 --- a/src/test/rustdoc-json/primitive.rs +++ b/src/test/rustdoc-json/primitive.rs @@ -1,6 +1,6 @@ // edition:2018 -#![feature(doc_primitive)] +#![feature(rustdoc_internals)] #[doc(primitive = "usize")] mod usize {} diff --git a/src/test/rustdoc-ui/coverage/exotic.rs b/src/test/rustdoc-ui/coverage/exotic.rs index 18f2014d9e463..72b70d6980bf3 100644 --- a/src/test/rustdoc-ui/coverage/exotic.rs +++ b/src/test/rustdoc-ui/coverage/exotic.rs @@ -1,8 +1,7 @@ // compile-flags:-Z unstable-options --show-coverage // check-pass -#![feature(doc_keyword)] -#![feature(doc_primitive)] +#![feature(rustdoc_internals)] //! the features only used in std also have entries in the table, so make sure those get pulled out //! properly as well diff --git a/src/test/rustdoc-ui/invalid-keyword.rs b/src/test/rustdoc-ui/invalid-keyword.rs index ce2abc69bbd28..2d70471c85e11 100644 --- a/src/test/rustdoc-ui/invalid-keyword.rs +++ b/src/test/rustdoc-ui/invalid-keyword.rs @@ -1,4 +1,4 @@ -#![feature(doc_keyword)] +#![feature(rustdoc_internals)] #[doc(keyword = "foo df")] //~ ERROR mod foo {} diff --git a/src/test/rustdoc/keyword.rs b/src/test/rustdoc/keyword.rs index 652517c5c90c0..16f7cac5f51cc 100644 --- a/src/test/rustdoc/keyword.rs +++ b/src/test/rustdoc/keyword.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -#![feature(doc_keyword)] +#![feature(rustdoc_internals)] // @has foo/index.html '//h2[@id="keywords"]' 'Keywords' // @has foo/index.html '//a[@href="keyword.match.html"]' 'match' diff --git a/src/test/rustdoc/tab_title.rs b/src/test/rustdoc/tab_title.rs index 7dce6092deaed..0cc4f147e1c07 100644 --- a/src/test/rustdoc/tab_title.rs +++ b/src/test/rustdoc/tab_title.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -#![feature(doc_keyword)] +#![feature(rustdoc_internals)] // tests for the html