Replace doc(primitive) with rustc_doc_primitive
This commit is contained in:
parent
3ef8d2d607
commit
364e961417
@ -1,7 +1,8 @@
|
||||
// `library/{std,core}/src/primitive_docs.rs` should have the same contents.
|
||||
// These are different files so that relative links work properly without
|
||||
// having to have `CARGO_PKG_NAME` set, but conceptually they should always be the same.
|
||||
#[doc(primitive = "bool")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "bool"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "bool")]
|
||||
#[doc(alias = "true")]
|
||||
#[doc(alias = "false")]
|
||||
/// The boolean type.
|
||||
@ -63,7 +64,8 @@
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_bool {}
|
||||
|
||||
#[doc(primitive = "never")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "never"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "never")]
|
||||
#[doc(alias = "!")]
|
||||
//
|
||||
/// The `!` type, also called "never".
|
||||
@ -274,7 +276,8 @@ mod prim_bool {}
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
mod prim_never {}
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "char"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "char")]
|
||||
#[allow(rustdoc::invalid_rust_codeblocks)]
|
||||
/// A character type.
|
||||
///
|
||||
@ -398,7 +401,8 @@ mod prim_never {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_char {}
|
||||
|
||||
#[doc(primitive = "unit")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "unit"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "unit")]
|
||||
#[doc(alias = "(")]
|
||||
#[doc(alias = ")")]
|
||||
#[doc(alias = "()")]
|
||||
@ -460,7 +464,8 @@ impl Copy for () {
|
||||
// empty
|
||||
}
|
||||
|
||||
#[doc(primitive = "pointer")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "pointer"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "pointer")]
|
||||
#[doc(alias = "ptr")]
|
||||
#[doc(alias = "*")]
|
||||
#[doc(alias = "*const")]
|
||||
@ -577,7 +582,8 @@ impl Copy for () {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_pointer {}
|
||||
|
||||
#[doc(primitive = "array")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "array"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "array")]
|
||||
#[doc(alias = "[]")]
|
||||
#[doc(alias = "[T;N]")] // unfortunately, rustdoc doesn't have fuzzy search for aliases
|
||||
#[doc(alias = "[T; N]")]
|
||||
@ -778,7 +784,8 @@ mod prim_pointer {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_array {}
|
||||
|
||||
#[doc(primitive = "slice")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "slice"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "slice")]
|
||||
#[doc(alias = "[")]
|
||||
#[doc(alias = "]")]
|
||||
#[doc(alias = "[]")]
|
||||
@ -870,7 +877,8 @@ mod prim_array {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_slice {}
|
||||
|
||||
#[doc(primitive = "str")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "str"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "str")]
|
||||
/// String slices.
|
||||
///
|
||||
/// *[See also the `std::str` module](crate::str).*
|
||||
@ -937,7 +945,8 @@ mod prim_slice {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_str {}
|
||||
|
||||
#[doc(primitive = "tuple")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "tuple"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "tuple")]
|
||||
#[doc(alias = "(")]
|
||||
#[doc(alias = ")")]
|
||||
#[doc(alias = "()")]
|
||||
@ -1081,7 +1090,8 @@ impl<T: Copy> Copy for (T,) {
|
||||
// empty
|
||||
}
|
||||
|
||||
#[doc(primitive = "f32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "f32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f32")]
|
||||
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
|
||||
///
|
||||
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
|
||||
@ -1147,7 +1157,8 @@ impl<T: Copy> Copy for (T,) {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_f32 {}
|
||||
|
||||
#[doc(primitive = "f64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "f64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f64")]
|
||||
/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
|
||||
///
|
||||
/// This type is very similar to [`f32`], but has increased
|
||||
@ -1162,67 +1173,78 @@ mod prim_f32 {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_f64 {}
|
||||
|
||||
#[doc(primitive = "i8")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i8"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i8")]
|
||||
//
|
||||
/// The 8-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i8 {}
|
||||
|
||||
#[doc(primitive = "i16")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i16"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i16")]
|
||||
//
|
||||
/// The 16-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i16 {}
|
||||
|
||||
#[doc(primitive = "i32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i32")]
|
||||
//
|
||||
/// The 32-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i32 {}
|
||||
|
||||
#[doc(primitive = "i64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i64")]
|
||||
//
|
||||
/// The 64-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i64 {}
|
||||
|
||||
#[doc(primitive = "i128")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i128"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i128")]
|
||||
//
|
||||
/// The 128-bit signed integer type.
|
||||
#[stable(feature = "i128", since = "1.26.0")]
|
||||
mod prim_i128 {}
|
||||
|
||||
#[doc(primitive = "u8")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u8"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u8")]
|
||||
//
|
||||
/// The 8-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u8 {}
|
||||
|
||||
#[doc(primitive = "u16")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u16"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u16")]
|
||||
//
|
||||
/// The 16-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u16 {}
|
||||
|
||||
#[doc(primitive = "u32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u32")]
|
||||
//
|
||||
/// The 32-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u32 {}
|
||||
|
||||
#[doc(primitive = "u64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u64")]
|
||||
//
|
||||
/// The 64-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u64 {}
|
||||
|
||||
#[doc(primitive = "u128")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u128"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u128")]
|
||||
//
|
||||
/// The 128-bit unsigned integer type.
|
||||
#[stable(feature = "i128", since = "1.26.0")]
|
||||
mod prim_u128 {}
|
||||
|
||||
#[doc(primitive = "isize")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "isize"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "isize")]
|
||||
//
|
||||
/// The pointer-sized signed integer type.
|
||||
///
|
||||
@ -1232,7 +1254,8 @@ mod prim_u128 {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_isize {}
|
||||
|
||||
#[doc(primitive = "usize")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "usize"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "usize")]
|
||||
//
|
||||
/// The pointer-sized unsigned integer type.
|
||||
///
|
||||
@ -1242,7 +1265,8 @@ mod prim_isize {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_usize {}
|
||||
|
||||
#[doc(primitive = "reference")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "reference"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "reference")]
|
||||
#[doc(alias = "&")]
|
||||
#[doc(alias = "&mut")]
|
||||
//
|
||||
@ -1373,7 +1397,8 @@ mod prim_usize {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_ref {}
|
||||
|
||||
#[doc(primitive = "fn")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "fn"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "fn")]
|
||||
//
|
||||
/// Function pointers, like `fn(usize) -> bool`.
|
||||
///
|
||||
|
@ -1,7 +1,8 @@
|
||||
// `library/{std,core}/src/primitive_docs.rs` should have the same contents.
|
||||
// These are different files so that relative links work properly without
|
||||
// having to have `CARGO_PKG_NAME` set, but conceptually they should always be the same.
|
||||
#[doc(primitive = "bool")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "bool"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "bool")]
|
||||
#[doc(alias = "true")]
|
||||
#[doc(alias = "false")]
|
||||
/// The boolean type.
|
||||
@ -63,7 +64,8 @@
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_bool {}
|
||||
|
||||
#[doc(primitive = "never")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "never"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "never")]
|
||||
#[doc(alias = "!")]
|
||||
//
|
||||
/// The `!` type, also called "never".
|
||||
@ -274,7 +276,8 @@ mod prim_bool {}
|
||||
#[unstable(feature = "never_type", issue = "35121")]
|
||||
mod prim_never {}
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "char"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "char")]
|
||||
#[allow(rustdoc::invalid_rust_codeblocks)]
|
||||
/// A character type.
|
||||
///
|
||||
@ -398,7 +401,8 @@ mod prim_never {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_char {}
|
||||
|
||||
#[doc(primitive = "unit")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "unit"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "unit")]
|
||||
#[doc(alias = "(")]
|
||||
#[doc(alias = ")")]
|
||||
#[doc(alias = "()")]
|
||||
@ -460,7 +464,8 @@ impl Copy for () {
|
||||
// empty
|
||||
}
|
||||
|
||||
#[doc(primitive = "pointer")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "pointer"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "pointer")]
|
||||
#[doc(alias = "ptr")]
|
||||
#[doc(alias = "*")]
|
||||
#[doc(alias = "*const")]
|
||||
@ -577,7 +582,8 @@ impl Copy for () {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_pointer {}
|
||||
|
||||
#[doc(primitive = "array")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "array"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "array")]
|
||||
#[doc(alias = "[]")]
|
||||
#[doc(alias = "[T;N]")] // unfortunately, rustdoc doesn't have fuzzy search for aliases
|
||||
#[doc(alias = "[T; N]")]
|
||||
@ -778,7 +784,8 @@ mod prim_pointer {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_array {}
|
||||
|
||||
#[doc(primitive = "slice")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "slice"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "slice")]
|
||||
#[doc(alias = "[")]
|
||||
#[doc(alias = "]")]
|
||||
#[doc(alias = "[]")]
|
||||
@ -870,7 +877,8 @@ mod prim_array {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_slice {}
|
||||
|
||||
#[doc(primitive = "str")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "str"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "str")]
|
||||
/// String slices.
|
||||
///
|
||||
/// *[See also the `std::str` module](crate::str).*
|
||||
@ -937,7 +945,8 @@ mod prim_slice {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_str {}
|
||||
|
||||
#[doc(primitive = "tuple")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "tuple"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "tuple")]
|
||||
#[doc(alias = "(")]
|
||||
#[doc(alias = ")")]
|
||||
#[doc(alias = "()")]
|
||||
@ -1081,7 +1090,8 @@ impl<T: Copy> Copy for (T,) {
|
||||
// empty
|
||||
}
|
||||
|
||||
#[doc(primitive = "f32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "f32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f32")]
|
||||
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
|
||||
///
|
||||
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
|
||||
@ -1147,7 +1157,8 @@ impl<T: Copy> Copy for (T,) {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_f32 {}
|
||||
|
||||
#[doc(primitive = "f64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "f64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "f64")]
|
||||
/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
|
||||
///
|
||||
/// This type is very similar to [`f32`], but has increased
|
||||
@ -1162,67 +1173,78 @@ mod prim_f32 {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_f64 {}
|
||||
|
||||
#[doc(primitive = "i8")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i8"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i8")]
|
||||
//
|
||||
/// The 8-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i8 {}
|
||||
|
||||
#[doc(primitive = "i16")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i16"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i16")]
|
||||
//
|
||||
/// The 16-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i16 {}
|
||||
|
||||
#[doc(primitive = "i32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i32")]
|
||||
//
|
||||
/// The 32-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i32 {}
|
||||
|
||||
#[doc(primitive = "i64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i64")]
|
||||
//
|
||||
/// The 64-bit signed integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_i64 {}
|
||||
|
||||
#[doc(primitive = "i128")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "i128"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "i128")]
|
||||
//
|
||||
/// The 128-bit signed integer type.
|
||||
#[stable(feature = "i128", since = "1.26.0")]
|
||||
mod prim_i128 {}
|
||||
|
||||
#[doc(primitive = "u8")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u8"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u8")]
|
||||
//
|
||||
/// The 8-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u8 {}
|
||||
|
||||
#[doc(primitive = "u16")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u16"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u16")]
|
||||
//
|
||||
/// The 16-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u16 {}
|
||||
|
||||
#[doc(primitive = "u32")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u32"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u32")]
|
||||
//
|
||||
/// The 32-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u32 {}
|
||||
|
||||
#[doc(primitive = "u64")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u64"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u64")]
|
||||
//
|
||||
/// The 64-bit unsigned integer type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_u64 {}
|
||||
|
||||
#[doc(primitive = "u128")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "u128"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "u128")]
|
||||
//
|
||||
/// The 128-bit unsigned integer type.
|
||||
#[stable(feature = "i128", since = "1.26.0")]
|
||||
mod prim_u128 {}
|
||||
|
||||
#[doc(primitive = "isize")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "isize"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "isize")]
|
||||
//
|
||||
/// The pointer-sized signed integer type.
|
||||
///
|
||||
@ -1232,7 +1254,8 @@ mod prim_u128 {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_isize {}
|
||||
|
||||
#[doc(primitive = "usize")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "usize"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "usize")]
|
||||
//
|
||||
/// The pointer-sized unsigned integer type.
|
||||
///
|
||||
@ -1242,7 +1265,8 @@ mod prim_isize {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_usize {}
|
||||
|
||||
#[doc(primitive = "reference")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "reference"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "reference")]
|
||||
#[doc(alias = "&")]
|
||||
#[doc(alias = "&mut")]
|
||||
//
|
||||
@ -1373,7 +1397,8 @@ mod prim_usize {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
mod prim_ref {}
|
||||
|
||||
#[doc(primitive = "fn")]
|
||||
#[cfg_attr(bootstrap, doc(primitive = "fn"))]
|
||||
#[cfg_attr(not(bootstrap), rustc_doc_primitive = "fn")]
|
||||
//
|
||||
/// Function pointers, like `fn(usize) -> bool`.
|
||||
///
|
||||
|
@ -249,13 +249,13 @@ impl ExternalCrate {
|
||||
//
|
||||
// Note that this loop only searches the top-level items of the crate,
|
||||
// and this is intentional. If we were to search the entire crate for an
|
||||
// item tagged with `#[doc(primitive)]` then we would also have to
|
||||
// item tagged with `#[rustc_doc_primitive]` then we would also have to
|
||||
// search the entirety of external modules for items tagged
|
||||
// `#[doc(primitive)]`, which is a pretty inefficient process (decoding
|
||||
// `#[rustc_doc_primitive]`, which is a pretty inefficient process (decoding
|
||||
// all that metadata unconditionally).
|
||||
//
|
||||
// In order to keep the metadata load under control, the
|
||||
// `#[doc(primitive)]` feature is explicitly designed to only allow the
|
||||
// `#[rustc_doc_primitive]` feature is explicitly designed to only allow the
|
||||
// primitive tags to show up as the top level items in a crate.
|
||||
//
|
||||
// Also note that this does not attempt to deal with modules tagged
|
||||
@ -264,18 +264,13 @@ impl ExternalCrate {
|
||||
let as_primitive = |res: Res<!>| {
|
||||
if let Res::Def(DefKind::Mod, def_id) = res {
|
||||
let mut prim = None;
|
||||
let meta_items = tcx
|
||||
.get_attrs(def_id, sym::doc)
|
||||
.flat_map(|attr| attr.meta_item_list().unwrap_or_default());
|
||||
for meta in meta_items {
|
||||
if let Some(v) = meta.value_str() {
|
||||
if meta.has_name(sym::primitive) {
|
||||
prim = PrimitiveType::from_symbol(v);
|
||||
if prim.is_some() {
|
||||
break;
|
||||
}
|
||||
// FIXME: should warn on unknown primitives?
|
||||
for attr in tcx.get_attrs(def_id, sym::rustc_doc_primitive) {
|
||||
if let Some(v) = attr.value_str() {
|
||||
prim = PrimitiveType::from_symbol(v);
|
||||
if prim.is_some() {
|
||||
break;
|
||||
}
|
||||
// FIXME: should warn on unknown primitives?
|
||||
}
|
||||
}
|
||||
return prim.map(|p| (def_id, p));
|
||||
@ -1829,13 +1824,17 @@ impl PrimitiveType {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the DefId of the module with `doc(primitive)` for this primitive type.
|
||||
/// Returns the DefId of the module with `rustc_doc_primitive` for this primitive type.
|
||||
/// Panics if there is no such module.
|
||||
///
|
||||
/// This gives precedence to primitives defined in the current crate, and deprioritizes primitives defined in `core`,
|
||||
/// but otherwise, if multiple crates define the same primitive, there is no guarantee of which will be picked.
|
||||
/// In particular, if a crate depends on both `std` and another crate that also defines `doc(primitive)`, then
|
||||
/// it's entirely random whether `std` or the other crate is picked. (no_std crates are usually fine unless multiple dependencies define a primitive.)
|
||||
/// This gives precedence to primitives defined in the current crate, and deprioritizes
|
||||
/// primitives defined in `core`,
|
||||
/// but otherwise, if multiple crates define the same primitive, there is no guarantee of which
|
||||
/// will be picked.
|
||||
///
|
||||
/// In particular, if a crate depends on both `std` and another crate that also defines
|
||||
/// `rustc_doc_primitive`, then it's entirely random whether `std` or the other crate is picked.
|
||||
/// (no_std crates are usually fine unless multiple dependencies define a primitive.)
|
||||
pub(crate) fn primitive_locations(tcx: TyCtxt<'_>) -> &FxHashMap<PrimitiveType, DefId> {
|
||||
static PRIMITIVE_LOCATIONS: OnceCell<FxHashMap<PrimitiveType, DefId>> = OnceCell::new();
|
||||
PRIMITIVE_LOCATIONS.get_or_init(|| {
|
||||
|
@ -249,9 +249,7 @@ pub(crate) fn id_from_item_inner(
|
||||
// instead, we directly get the primitive symbol and convert it to u32 to
|
||||
// generate the ID.
|
||||
if matches!(tcx.def_kind(def_id), DefKind::Mod) &&
|
||||
let Some(prim) = tcx.get_attrs(*def_id, sym::doc)
|
||||
.flat_map(|attr| attr.meta_item_list().unwrap_or_default())
|
||||
.filter(|attr| attr.has_name(sym::primitive))
|
||||
let Some(prim) = tcx.get_attrs(*def_id, sym::rustc_doc_primitive)
|
||||
.find_map(|attr| attr.value_str()) {
|
||||
format!(":{}", prim.as_u32())
|
||||
} else {
|
||||
|
@ -78,7 +78,7 @@ impl<'tcx> JsonRenderer<'tcx> {
|
||||
// HACK(hkmatsumoto): For impls of primitive types, we index them
|
||||
// regardless of whether they're local. This is because users can
|
||||
// document primitive items in an arbitrary crate by using
|
||||
// `doc(primitive)`.
|
||||
// `rustc_doc_primitive`.
|
||||
let mut is_primitive_impl = false;
|
||||
if let clean::types::ItemKind::ImplItem(ref impl_) = *item.kind &&
|
||||
impl_.trait_.is_none() &&
|
||||
|
@ -433,8 +433,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||
})?;
|
||||
|
||||
// FIXME(#83862): this arbitrarily gives precedence to primitives over modules to support
|
||||
// links to primitives when `#[doc(primitive)]` is present. It should give an ambiguity
|
||||
// error instead and special case *only* modules with `#[doc(primitive)]`, not all
|
||||
// links to primitives when `#[rustc_doc_primitive]` is present. It should give an ambiguity
|
||||
// error instead and special case *only* modules with `#[rustc_doc_primitive]`, not all
|
||||
// primitives.
|
||||
resolve_primitive(&path_root, TypeNS)
|
||||
.or_else(|| self.resolve_path(&path_root, TypeNS, item_id, module_id))
|
||||
@ -1102,7 +1102,7 @@ impl LinkCollector<'_, '_> {
|
||||
}
|
||||
}
|
||||
|
||||
// item can be non-local e.g. when using #[doc(primitive = "pointer")]
|
||||
// item can be non-local e.g. when using `#[rustc_doc_primitive = "pointer"]`
|
||||
if let Some((src_id, dst_id)) = id.as_local().and_then(|dst_id| {
|
||||
item.item_id.expect_def_id().as_local().map(|src_id| (src_id, dst_id))
|
||||
}) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user