Skip to content

Commit 6c93c63

Browse files
Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes` Fixes #88070. It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem. r? `@jyn514`
2 parents 8fe5b56 + f6035fb commit 6c93c63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+217
-165
lines changed

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ declare_features! (
225225
(active, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None),
226226
/// Allows using compiler's own crates.
227227
(active, rustc_private, "1.0.0", Some(27812), None),
228-
/// Allows using internal rustdoc features like `doc(primitive)` or `doc(keyword)`.
228+
/// Allows using internal rustdoc features like `doc(keyword)`.
229229
(active, rustdoc_internals, "1.58.0", Some(90418), None),
230230
/// Allows using the `rustdoc::missing_doc_code_examples` lint
231231
(active, rustdoc_missing_doc_code_examples, "1.31.0", Some(101730), None),

compiler/rustc_feature/src/builtin_attrs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
778778
definition of a trait, it's currently in experimental form and should be changed before \
779779
being exposed outside of the std"
780780
),
781+
rustc_attr!(
782+
rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing,
783+
r#"`rustc_doc_primitive` is a rustc internal attribute"#,
784+
),
781785

782786
// ==========================================================================
783787
// Internal attributes, Testing:

compiler/rustc_passes/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ passes_doc_test_unknown =
148148
passes_doc_test_takes_list =
149149
`#[doc(test(...)]` takes a list of attributes
150150
151-
passes_doc_primitive =
152-
`doc(primitive)` should never have been stable
153-
154151
passes_doc_cfg_hide_takes_list =
155152
`#[doc(cfg_hide(...)]` takes a list of attributes
156153

compiler/rustc_passes/src/check_attr.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1109,17 +1109,6 @@ impl CheckAttrVisitor<'_> {
11091109
}
11101110
}
11111111

1112-
sym::primitive => {
1113-
if !self.tcx.features().rustdoc_internals {
1114-
self.tcx.emit_spanned_lint(
1115-
INVALID_DOC_ATTRIBUTES,
1116-
hir_id,
1117-
i_meta.span,
1118-
errors::DocPrimitive,
1119-
);
1120-
}
1121-
}
1122-
11231112
_ => {
11241113
let path = rustc_ast_pretty::pprust::path_to_string(&i_meta.path);
11251114
if i_meta.has_name(sym::spotlight) {

compiler/rustc_passes/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ pub struct DocTestTakesList;
288288
#[diag(passes_doc_cfg_hide_takes_list)]
289289
pub struct DocCfgHideTakesList;
290290

291-
#[derive(LintDiagnostic)]
292-
#[diag(passes_doc_primitive)]
293-
pub struct DocPrimitive;
294-
295291
#[derive(LintDiagnostic)]
296292
#[diag(passes_doc_test_unknown_any)]
297293
pub struct DocTestUnknownAny {

compiler/rustc_resolve/src/rustdoc.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,14 @@ pub fn inner_docs(attrs: &[ast::Attribute]) -> bool {
339339
attrs.iter().find(|a| a.doc_str().is_some()).map_or(true, |a| a.style == ast::AttrStyle::Inner)
340340
}
341341

342-
/// Has `#[doc(primitive)]` or `#[doc(keyword)]`.
342+
/// Has `#[rustc_doc_primitive]` or `#[doc(keyword)]`.
343343
pub fn has_primitive_or_keyword_docs(attrs: &[ast::Attribute]) -> bool {
344344
for attr in attrs {
345-
if attr.has_name(sym::doc) && let Some(items) = attr.meta_item_list() {
345+
if attr.has_name(sym::rustc_doc_primitive) {
346+
return true;
347+
} else if attr.has_name(sym::doc) && let Some(items) = attr.meta_item_list() {
346348
for item in items {
347-
if item.has_name(sym::primitive) || item.has_name(sym::keyword) {
349+
if item.has_name(sym::keyword) {
348350
return true;
349351
}
350352
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ symbols! {
12461246
rustc_diagnostic_macros,
12471247
rustc_dirty,
12481248
rustc_do_not_const_check,
1249+
rustc_doc_primitive,
12491250
rustc_dummy,
12501251
rustc_dump_env_program_clauses,
12511252
rustc_dump_program_clauses,

library/core/src/primitive_docs.rs

+50-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// `library/{std,core}/src/primitive_docs.rs` should have the same contents.
22
// These are different files so that relative links work properly without
33
// having to have `CARGO_PKG_NAME` set, but conceptually they should always be the same.
4-
#[doc(primitive = "bool")]
4+
#[cfg_attr(bootstrap, doc(primitive = "bool"))]
5+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "bool")]
56
#[doc(alias = "true")]
67
#[doc(alias = "false")]
78
/// The boolean type.
@@ -63,7 +64,8 @@
6364
#[stable(feature = "rust1", since = "1.0.0")]
6465
mod prim_bool {}
6566

66-
#[doc(primitive = "never")]
67+
#[cfg_attr(bootstrap, doc(primitive = "never"))]
68+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "never")]
6769
#[doc(alias = "!")]
6870
//
6971
/// The `!` type, also called "never".
@@ -274,7 +276,8 @@ mod prim_bool {}
274276
#[unstable(feature = "never_type", issue = "35121")]
275277
mod prim_never {}
276278

277-
#[doc(primitive = "char")]
279+
#[cfg_attr(bootstrap, doc(primitive = "char"))]
280+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "char")]
278281
#[allow(rustdoc::invalid_rust_codeblocks)]
279282
/// A character type.
280283
///
@@ -398,7 +401,8 @@ mod prim_never {}
398401
#[stable(feature = "rust1", since = "1.0.0")]
399402
mod prim_char {}
400403

401-
#[doc(primitive = "unit")]
404+
#[cfg_attr(bootstrap, doc(primitive = "unit"))]
405+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "unit")]
402406
#[doc(alias = "(")]
403407
#[doc(alias = ")")]
404408
#[doc(alias = "()")]
@@ -460,7 +464,8 @@ impl Copy for () {
460464
// empty
461465
}
462466

463-
#[doc(primitive = "pointer")]
467+
#[cfg_attr(bootstrap, doc(primitive = "pointer"))]
468+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "pointer")]
464469
#[doc(alias = "ptr")]
465470
#[doc(alias = "*")]
466471
#[doc(alias = "*const")]
@@ -577,7 +582,8 @@ impl Copy for () {
577582
#[stable(feature = "rust1", since = "1.0.0")]
578583
mod prim_pointer {}
579584

580-
#[doc(primitive = "array")]
585+
#[cfg_attr(bootstrap, doc(primitive = "array"))]
586+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "array")]
581587
#[doc(alias = "[]")]
582588
#[doc(alias = "[T;N]")] // unfortunately, rustdoc doesn't have fuzzy search for aliases
583589
#[doc(alias = "[T; N]")]
@@ -778,7 +784,8 @@ mod prim_pointer {}
778784
#[stable(feature = "rust1", since = "1.0.0")]
779785
mod prim_array {}
780786

781-
#[doc(primitive = "slice")]
787+
#[cfg_attr(bootstrap, doc(primitive = "slice"))]
788+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "slice")]
782789
#[doc(alias = "[")]
783790
#[doc(alias = "]")]
784791
#[doc(alias = "[]")]
@@ -870,7 +877,8 @@ mod prim_array {}
870877
#[stable(feature = "rust1", since = "1.0.0")]
871878
mod prim_slice {}
872879

873-
#[doc(primitive = "str")]
880+
#[cfg_attr(bootstrap, doc(primitive = "str"))]
881+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "str")]
874882
/// String slices.
875883
///
876884
/// *[See also the `std::str` module](crate::str).*
@@ -937,7 +945,8 @@ mod prim_slice {}
937945
#[stable(feature = "rust1", since = "1.0.0")]
938946
mod prim_str {}
939947

940-
#[doc(primitive = "tuple")]
948+
#[cfg_attr(bootstrap, doc(primitive = "tuple"))]
949+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "tuple")]
941950
#[doc(alias = "(")]
942951
#[doc(alias = ")")]
943952
#[doc(alias = "()")]
@@ -1081,7 +1090,8 @@ impl<T: Copy> Copy for (T,) {
10811090
// empty
10821091
}
10831092

1084-
#[doc(primitive = "f32")]
1093+
#[cfg_attr(bootstrap, doc(primitive = "f32"))]
1094+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f32")]
10851095
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
10861096
///
10871097
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
@@ -1147,7 +1157,8 @@ impl<T: Copy> Copy for (T,) {
11471157
#[stable(feature = "rust1", since = "1.0.0")]
11481158
mod prim_f32 {}
11491159

1150-
#[doc(primitive = "f64")]
1160+
#[cfg_attr(bootstrap, doc(primitive = "f64"))]
1161+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f64")]
11511162
/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
11521163
///
11531164
/// This type is very similar to [`f32`], but has increased
@@ -1162,67 +1173,78 @@ mod prim_f32 {}
11621173
#[stable(feature = "rust1", since = "1.0.0")]
11631174
mod prim_f64 {}
11641175

1165-
#[doc(primitive = "i8")]
1176+
#[cfg_attr(bootstrap, doc(primitive = "i8"))]
1177+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i8")]
11661178
//
11671179
/// The 8-bit signed integer type.
11681180
#[stable(feature = "rust1", since = "1.0.0")]
11691181
mod prim_i8 {}
11701182

1171-
#[doc(primitive = "i16")]
1183+
#[cfg_attr(bootstrap, doc(primitive = "i16"))]
1184+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i16")]
11721185
//
11731186
/// The 16-bit signed integer type.
11741187
#[stable(feature = "rust1", since = "1.0.0")]
11751188
mod prim_i16 {}
11761189

1177-
#[doc(primitive = "i32")]
1190+
#[cfg_attr(bootstrap, doc(primitive = "i32"))]
1191+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i32")]
11781192
//
11791193
/// The 32-bit signed integer type.
11801194
#[stable(feature = "rust1", since = "1.0.0")]
11811195
mod prim_i32 {}
11821196

1183-
#[doc(primitive = "i64")]
1197+
#[cfg_attr(bootstrap, doc(primitive = "i64"))]
1198+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i64")]
11841199
//
11851200
/// The 64-bit signed integer type.
11861201
#[stable(feature = "rust1", since = "1.0.0")]
11871202
mod prim_i64 {}
11881203

1189-
#[doc(primitive = "i128")]
1204+
#[cfg_attr(bootstrap, doc(primitive = "i128"))]
1205+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i128")]
11901206
//
11911207
/// The 128-bit signed integer type.
11921208
#[stable(feature = "i128", since = "1.26.0")]
11931209
mod prim_i128 {}
11941210

1195-
#[doc(primitive = "u8")]
1211+
#[cfg_attr(bootstrap, doc(primitive = "u8"))]
1212+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u8")]
11961213
//
11971214
/// The 8-bit unsigned integer type.
11981215
#[stable(feature = "rust1", since = "1.0.0")]
11991216
mod prim_u8 {}
12001217

1201-
#[doc(primitive = "u16")]
1218+
#[cfg_attr(bootstrap, doc(primitive = "u16"))]
1219+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u16")]
12021220
//
12031221
/// The 16-bit unsigned integer type.
12041222
#[stable(feature = "rust1", since = "1.0.0")]
12051223
mod prim_u16 {}
12061224

1207-
#[doc(primitive = "u32")]
1225+
#[cfg_attr(bootstrap, doc(primitive = "u32"))]
1226+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u32")]
12081227
//
12091228
/// The 32-bit unsigned integer type.
12101229
#[stable(feature = "rust1", since = "1.0.0")]
12111230
mod prim_u32 {}
12121231

1213-
#[doc(primitive = "u64")]
1232+
#[cfg_attr(bootstrap, doc(primitive = "u64"))]
1233+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u64")]
12141234
//
12151235
/// The 64-bit unsigned integer type.
12161236
#[stable(feature = "rust1", since = "1.0.0")]
12171237
mod prim_u64 {}
12181238

1219-
#[doc(primitive = "u128")]
1239+
#[cfg_attr(bootstrap, doc(primitive = "u128"))]
1240+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u128")]
12201241
//
12211242
/// The 128-bit unsigned integer type.
12221243
#[stable(feature = "i128", since = "1.26.0")]
12231244
mod prim_u128 {}
12241245

1225-
#[doc(primitive = "isize")]
1246+
#[cfg_attr(bootstrap, doc(primitive = "isize"))]
1247+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "isize")]
12261248
//
12271249
/// The pointer-sized signed integer type.
12281250
///
@@ -1232,7 +1254,8 @@ mod prim_u128 {}
12321254
#[stable(feature = "rust1", since = "1.0.0")]
12331255
mod prim_isize {}
12341256

1235-
#[doc(primitive = "usize")]
1257+
#[cfg_attr(bootstrap, doc(primitive = "usize"))]
1258+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "usize")]
12361259
//
12371260
/// The pointer-sized unsigned integer type.
12381261
///
@@ -1242,7 +1265,8 @@ mod prim_isize {}
12421265
#[stable(feature = "rust1", since = "1.0.0")]
12431266
mod prim_usize {}
12441267

1245-
#[doc(primitive = "reference")]
1268+
#[cfg_attr(bootstrap, doc(primitive = "reference"))]
1269+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "reference")]
12461270
#[doc(alias = "&")]
12471271
#[doc(alias = "&mut")]
12481272
//
@@ -1373,7 +1397,8 @@ mod prim_usize {}
13731397
#[stable(feature = "rust1", since = "1.0.0")]
13741398
mod prim_ref {}
13751399

1376-
#[doc(primitive = "fn")]
1400+
#[cfg_attr(bootstrap, doc(primitive = "fn"))]
1401+
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "fn")]
13771402
//
13781403
/// Function pointers, like `fn(usize) -> bool`.
13791404
///

0 commit comments

Comments
 (0)