about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-11-24 22:56:37 +0100
committerGitHub <noreply@github.com>2021-11-24 22:56:37 +0100
commita6a1d7ca2936ddb33dbaad69ae3a8a47b9208498 (patch)
tree5000d2963032cedb54c906861356172898efe916
parentcbe563a4d575f888d3889a6d8f103ce1ebbe9ad3 (diff)
parent9447d1f903742619b49f8ff5959b7553730c876a (diff)
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Create rustdoc_internals feature gate

As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.

This is pretty much what it would look like (needs to update the tests too).

The tracking issue is https://github.com/rust-lang/rust/issues/90418.

What do you think ``@rust-lang/rustdoc`` ?
-rw-r--r--compiler/rustc_ast_passes/src/feature_gate.rs6
-rw-r--r--compiler/rustc_feature/src/active.rs6
-rw-r--r--compiler/rustc_feature/src/removed.rs6
-rw-r--r--compiler/rustc_passes/src/check_attr.rs2
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--library/core/src/lib.rs3
-rw-r--r--library/std/src/lib.rs5
-rw-r--r--src/doc/rustdoc/src/unstable-features.md5
-rw-r--r--src/test/rustdoc-gui/src/test_docs/lib.rs2
-rw-r--r--src/test/rustdoc-json/primitive.rs2
-rw-r--r--src/test/rustdoc-ui/coverage/exotic.rs3
-rw-r--r--src/test/rustdoc-ui/invalid-keyword.rs2
-rw-r--r--src/test/rustdoc/keyword.rs2
-rw-r--r--src/test/rustdoc/tab_title.rs2
-rw-r--r--src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-doc_keyword.rs5
-rw-r--r--src/test/ui/feature-gates/feature-gate-doc_keyword.stderr12
-rw-r--r--src/test/ui/feature-gates/feature-gate-rustdoc_internals.rs5
-rw-r--r--src/test/ui/feature-gates/feature-gate-rustdoc_internals.stderr12
-rw-r--r--src/test/ui/rustdoc/doc_keyword.rs2
-rw-r--r--src/test/ui/rustdoc/renamed-features-rustdoc_internals.rs5
-rw-r--r--src/test/ui/rustdoc/renamed-features-rustdoc_internals.stderr19
22 files changed, 72 insertions, 37 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index 6a19984f8ea..ad539f2564d 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 c34ecc966d0..7860f92f96f 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 4b40040a036..b9f3b5ad1b1 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 2def57cf02a..f761eaae5ab 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -982,7 +982,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 c34cf822765..97b155d2377 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -1155,6 +1155,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 ab3938fd9e2..fdb23529599 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -166,7 +166,8 @@
 #![feature(derive_default_enum)]
 #![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 afd8d8edaa1..504c3b7e9f9 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 8da1d22a4d1..6e52127591c 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 14d8b186130..458bcc4780c 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 3a7d6d18c1b..b84c2f7c6ac 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 18f2014d9e4..72b70d6980b 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 ce2abc69bbd..2d70471c85e 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 652517c5c90..16f7cac5f51 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 7dce6092dea..0cc4f147e1c 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 <title> element
 
diff --git a/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs b/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs
index 053712a4b4e..7783dc40fcf 100644
--- a/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs
+++ b/src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs
@@ -1,7 +1,7 @@
 // compile-flags: -Z unstable-options
 
 #![feature(rustc_private)]
-#![feature(doc_keyword)]
+#![feature(rustdoc_internals)]
 
 #![crate_type = "lib"]
 
diff --git a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs b/src/test/ui/feature-gates/feature-gate-doc_keyword.rs
deleted file mode 100644
index 4bb9a40deb0..00000000000
--- a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-#[doc(keyword = "match")] //~ ERROR: `#[doc(keyword)]` is experimental
-/// wonderful
-mod foo{}
-
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-doc_keyword.stderr b/src/test/ui/feature-gates/feature-gate-doc_keyword.stderr
deleted file mode 100644
index c5dc7d537fd..00000000000
--- a/src/test/ui/feature-gates/feature-gate-doc_keyword.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0658]: `#[doc(keyword)]` is experimental
-  --> $DIR/feature-gate-doc_keyword.rs:1:1
-   |
-LL | #[doc(keyword = "match")]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #51315 <https://github.com/rust-lang/rust/issues/51315> for more information
-   = help: add `#![feature(doc_keyword)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/feature-gates/feature-gate-rustdoc_internals.rs b/src/test/ui/feature-gates/feature-gate-rustdoc_internals.rs
new file mode 100644
index 00000000000..d2ff4f62009
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-rustdoc_internals.rs
@@ -0,0 +1,5 @@
+#[doc(keyword = "match")] //~ ERROR: `#[doc(keyword)]` is meant for internal use only
+/// wonderful
+mod foo {}
+
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-rustdoc_internals.stderr b/src/test/ui/feature-gates/feature-gate-rustdoc_internals.stderr
new file mode 100644
index 00000000000..e96461ac38a
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-rustdoc_internals.stderr
@@ -0,0 +1,12 @@
+error[E0658]: `#[doc(keyword)]` is meant for internal use only
+  --> $DIR/feature-gate-rustdoc_internals.rs:1:1
+   |
+LL | #[doc(keyword = "match")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #90418 <https://github.com/rust-lang/rust/issues/90418> for more information
+   = help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/rustdoc/doc_keyword.rs b/src/test/ui/rustdoc/doc_keyword.rs
index 4518f77ef93..43b84e5018c 100644
--- a/src/test/ui/rustdoc/doc_keyword.rs
+++ b/src/test/ui/rustdoc/doc_keyword.rs
@@ -1,5 +1,5 @@
 #![crate_type = "lib"]
-#![feature(doc_keyword)]
+#![feature(rustdoc_internals)]
 
 #![doc(keyword = "hello")] //~ ERROR
 
diff --git a/src/test/ui/rustdoc/renamed-features-rustdoc_internals.rs b/src/test/ui/rustdoc/renamed-features-rustdoc_internals.rs
new file mode 100644
index 00000000000..739c624d0c6
--- /dev/null
+++ b/src/test/ui/rustdoc/renamed-features-rustdoc_internals.rs
@@ -0,0 +1,5 @@
+#![feature(doc_keyword)] //~ ERROR
+#![feature(doc_primitive)] //~ ERROR
+#![crate_type = "lib"]
+
+pub fn foo() {}
diff --git a/src/test/ui/rustdoc/renamed-features-rustdoc_internals.stderr b/src/test/ui/rustdoc/renamed-features-rustdoc_internals.stderr
new file mode 100644
index 00000000000..d0979ce97ac
--- /dev/null
+++ b/src/test/ui/rustdoc/renamed-features-rustdoc_internals.stderr
@@ -0,0 +1,19 @@
+error[E0557]: feature has been removed
+  --> $DIR/renamed-features-rustdoc_internals.rs:1:12
+   |
+LL | #![feature(doc_keyword)]
+   |            ^^^^^^^^^^^ feature has been removed
+   |
+   = note: merged into `#![feature(rustdoc_internals)]`
+
+error[E0557]: feature has been removed
+  --> $DIR/renamed-features-rustdoc_internals.rs:2:12
+   |
+LL | #![feature(doc_primitive)]
+   |            ^^^^^^^^^^^^^ feature has been removed
+   |
+   = note: merged into `#![feature(rustdoc_internals)]`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0557`.