Skip to content

Commit a6a1d7c

Browse files
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](#90398 (comment)), 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 #90418. What do you think ``@rust-lang/rustdoc`` ?
2 parents cbe563a + 9447d1f commit a6a1d7c

File tree

22 files changed

+72
-37
lines changed

22 files changed

+72
-37
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
325325
cfg_hide => doc_cfg_hide
326326
masked => doc_masked
327327
notable_trait => doc_notable_trait
328-
keyword => doc_keyword
329328
);
329+
330+
if nested_meta.has_name(sym::keyword) {
331+
let msg = "`#[doc(keyword)]` is meant for internal use only";
332+
gate_feature_post!(self, rustdoc_internals, attr.span, msg);
333+
}
330334
}
331335
}
332336

compiler/rustc_feature/src/active.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ declare_features! (
206206
(active, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None),
207207
/// Allows using compiler's own crates.
208208
(active, rustc_private, "1.0.0", Some(27812), None),
209+
/// Allows using internal rustdoc features like `doc(primitive)` or `doc(keyword)`.
210+
(active, rustdoc_internals, "1.58.0", Some(90418), None),
209211
/// Allows using `#[start]` on a function indicating that it is the program entrypoint.
210212
(active, start, "1.0.0", Some(29633), None),
211213
/// Allows using `#[structural_match]` which indicates that a type is structurally matchable.
@@ -366,12 +368,8 @@ declare_features! (
366368
(active, doc_cfg, "1.21.0", Some(43781), None),
367369
/// Allows `#[doc(cfg_hide(...))]`.
368370
(active, doc_cfg_hide, "1.57.0", Some(43781), None),
369-
/// Allows using `#[doc(keyword = "...")]`.
370-
(active, doc_keyword, "1.28.0", Some(51315), None),
371371
/// Allows `#[doc(masked)]`.
372372
(active, doc_masked, "1.21.0", Some(44027), None),
373-
/// Allows using doc(primitive) without a future-incompat warning
374-
(active, doc_primitive, "1.56.0", Some(88070), None),
375373
/// Allows `X..Y` patterns.
376374
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
377375
/// Allows exhaustive pattern matching on types that contain uninhabited types.

compiler/rustc_feature/src/removed.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ declare_features! (
7676
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
7777
(removed, custom_derive, "1.32.0", Some(29644), None,
7878
Some("subsumed by `#[proc_macro_derive]`")),
79+
/// Allows using `#[doc(keyword = "...")]`.
80+
(removed, doc_keyword, "1.28.0", Some(51315), None,
81+
Some("merged into `#![feature(rustdoc_internals)]`")),
82+
/// Allows using `doc(primitive)` without a future-incompat warning.
83+
(removed, doc_primitive, "1.56.0", Some(88070), None,
84+
Some("merged into `#![feature(rustdoc_internals)]`")),
7985
/// Allows `#[doc(spotlight)]`.
8086
/// The attribute was renamed to `#[doc(notable_trait)]`
8187
/// and the feature to `doc_notable_trait`.

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ impl CheckAttrVisitor<'tcx> {
982982
}
983983

984984
sym::primitive => {
985-
if !self.tcx.features().doc_primitive {
985+
if !self.tcx.features().rustdoc_internals {
986986
self.tcx.struct_span_lint_hir(
987987
INVALID_DOC_ATTRIBUTES,
988988
hir_id,

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,7 @@ symbols! {
11551155
rustc_unsafe_specialization_marker,
11561156
rustc_variance,
11571157
rustdoc,
1158+
rustdoc_internals,
11581159
rustfmt,
11591160
rvalue_static_promotion,
11601161
s,

library/core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@
166166
#![feature(derive_default_enum)]
167167
#![feature(doc_cfg)]
168168
#![feature(doc_notable_trait)]
169-
#![feature(doc_primitive)]
169+
#![cfg_attr(bootstrap, feature(doc_primitive))]
170+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
170171
#![feature(exhaustive_patterns)]
171172
#![feature(doc_cfg_hide)]
172173
#![feature(extern_types)]

library/std/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@
275275
#![feature(decl_macro)]
276276
#![feature(doc_cfg)]
277277
#![feature(doc_cfg_hide)]
278-
#![feature(doc_keyword)]
278+
#![cfg_attr(bootstrap, feature(doc_primitive))]
279+
#![cfg_attr(bootstrap, feature(doc_keyword))]
280+
#![cfg_attr(not(bootstrap), feature(rustdoc_internals))]
279281
#![feature(doc_masked)]
280282
#![feature(doc_notable_trait)]
281-
#![feature(doc_primitive)]
282283
#![feature(dropck_eyepatch)]
283284
#![feature(duration_checked_float)]
284285
#![feature(duration_constants)]

src/doc/rustdoc/src/unstable-features.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ This is for Rust compiler internal use only.
138138

139139
Since primitive types are defined in the compiler, there's no place to attach documentation
140140
attributes. The `#[doc(primitive)]` attribute is used by the standard library to provide a way
141-
to generate documentation for primitive types, and requires `#![feature(doc_primitive)]` to enable.
141+
to generate documentation for primitive types, and requires `#![feature(rustdoc_internals)]` to
142+
enable.
142143

143144
## Document keywords
144145

@@ -149,7 +150,7 @@ Rust keywords are documented in the standard library (look for `match` for examp
149150
To do so, the `#[doc(keyword = "...")]` attribute is used. Example:
150151

151152
```rust
152-
#![feature(doc_keyword)]
153+
#![feature(rustdoc_internals)]
153154

154155
/// Some documentation about the keyword.
155156
#[doc(keyword = "keyword")]

src/test/rustdoc-gui/src/test_docs/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! documentation generated so we can test each different features.
33
44
#![crate_name = "test_docs"]
5-
#![feature(doc_keyword)]
5+
#![feature(rustdoc_internals)]
66
#![feature(doc_cfg)]
77

88
use std::convert::AsRef;

src/test/rustdoc-json/primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// edition:2018
22

3-
#![feature(doc_primitive)]
3+
#![feature(rustdoc_internals)]
44

55
#[doc(primitive = "usize")]
66
mod usize {}

0 commit comments

Comments
 (0)