]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)
committerGitHub <noreply@github.com>
Wed, 24 Nov 2021 21:56:37 +0000 (22:56 +0100)
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`` ?

22 files changed:
compiler/rustc_ast_passes/src/feature_gate.rs
compiler/rustc_feature/src/active.rs
compiler/rustc_feature/src/removed.rs
compiler/rustc_passes/src/check_attr.rs
compiler/rustc_span/src/symbol.rs
library/core/src/lib.rs
library/std/src/lib.rs
src/doc/rustdoc/src/unstable-features.md
src/test/rustdoc-gui/src/test_docs/lib.rs
src/test/rustdoc-json/primitive.rs
src/test/rustdoc-ui/coverage/exotic.rs
src/test/rustdoc-ui/invalid-keyword.rs
src/test/rustdoc/keyword.rs
src/test/rustdoc/tab_title.rs
src/test/ui-fulldeps/internal-lints/existing_doc_keyword.rs
src/test/ui/feature-gates/feature-gate-doc_keyword.rs [deleted file]
src/test/ui/feature-gates/feature-gate-doc_keyword.stderr [deleted file]
src/test/ui/feature-gates/feature-gate-rustdoc_internals.rs [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-rustdoc_internals.stderr [new file with mode: 0644]
src/test/ui/rustdoc/doc_keyword.rs
src/test/ui/rustdoc/renamed-features-rustdoc_internals.rs [new file with mode: 0644]
src/test/ui/rustdoc/renamed-features-rustdoc_internals.stderr [new file with mode: 0644]

index 6a19984f8ea4612e82289b7c95d09839ca65a4e4..ad539f2564d4c01e2230e28b76073aacd87862d3 100644 (file)
@@ -325,8 +325,12 @@ macro_rules! gate_doc { ($($name:ident => $feature:ident)*) => {
                     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);
+                }
             }
         }
 
index c34ecc966d0ae21989ab921b6502f9bb3615ecc2..7860f92f96f9647d2367a74bd16ca10f0cff5f1f 100644 (file)
@@ -206,6 +206,8 @@ pub fn set(&self, features: &mut Features, span: Span) {
     (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 @@ pub fn set(&self, features: &mut Features, span: Span) {
     (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.
index 4b40040a03671672ec3e6a8612f8d7fd7600f753..b9f3b5ad1b1fce8b5c6aebbf821dbcaa0306b5af 100644 (file)
@@ -76,6 +76,12 @@ macro_rules! 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`.
index 2def57cf02a61564b412ba20da6af37c1bccd5a5..f761eaae5ab73652822d584ac0c4b0fd0ef7f92b 100644 (file)
@@ -982,7 +982,7 @@ fn check_doc_attrs(
                         }
 
                         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,
index c34cf822765f73615e32d650a0c12db821c3aa4b..97b155d2377c789eb8ffa8d46f63d3559cf82b89 100644 (file)
         rustc_unsafe_specialization_marker,
         rustc_variance,
         rustdoc,
+        rustdoc_internals,
         rustfmt,
         rvalue_static_promotion,
         s,
index ab3938fd9e2382ccd600711bee68e68183b2ea62..fdb23529599c890aa6a9aeed9bff1ca85dd4a15c 100644 (file)
 #![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)]
index afd8d8edaa169f8b41d1bed27fdb56f7a4eb6ad8..504c3b7e9f99c575be33b94fffbfb405ede59e32 100644 (file)
 #![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)]
index 8da1d22a4d172d3f6a2c5830bcc10cc138d6df1d..6e52127591c76c66388d63a6abf817778ddae434 100644 (file)
@@ -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")]
index 14d8b18613087caf1d8c311cc7e4648f17ca109a..458bcc4780c6c5abfa909b611982fd7439e8b85b 100644 (file)
@@ -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;
index 3a7d6d18c1bd0639f64ccfa6d19c501c795906fe..b84c2f7c6ac39e440090cfb83ebbe7e2ed9c4147 100644 (file)
@@ -1,6 +1,6 @@
 // edition:2018
 
-#![feature(doc_primitive)]
+#![feature(rustdoc_internals)]
 
 #[doc(primitive = "usize")]
 mod usize {}
index 18f2014d9e4638f569d8f98c8390ef6d8bfdc585..72b70d6980bf3f9e54997334b35b60e4c470086a 100644 (file)
@@ -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
index ce2abc69bbd28be4fb43b29e4bdf31ff64eb7378..2d70471c85e111f3f93672079d234c25ee81b20c 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(doc_keyword)]
+#![feature(rustdoc_internals)]
 
 #[doc(keyword = "foo df")] //~ ERROR
 mod foo {}
index 652517c5c90c06e87f282b83d9db81473debb7bc..16f7cac5f51cc77774a6372c1e8ec22280bbbf0a 100644 (file)
@@ -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'
index 7dce6092deaed95fddbbbee00262ff2a90925254..0cc4f147e1c071fc4f5cd19986e10ba303957c92 100644 (file)
@@ -1,5 +1,5 @@
 #![crate_name = "foo"]
-#![feature(doc_keyword)]
+#![feature(rustdoc_internals)]
 
 // tests for the html <title> element
 
index 053712a4b4ee647d8d152bce6edc8483d2efa368..7783dc40fcf206ac6b64e0a4ce122534be01e110 100644 (file)
@@ -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 (file)
index 4bb9a40..0000000
+++ /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 (file)
index c5dc7d5..0000000
+++ /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 (file)
index 0000000..d2ff4f6
--- /dev/null
@@ -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 (file)
index 0000000..e96461a
--- /dev/null
@@ -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`.
index 4518f77ef933dec06e287d9104895f23b62549d2..43b84e5018cda2c17385b533d71b2ca795a38d35 100644 (file)
@@ -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 (file)
index 0000000..739c624
--- /dev/null
@@ -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 (file)
index 0000000..d0979ce
--- /dev/null
@@ -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`.