Skip to content

Commit bc5669e

Browse files
authored
Rollup merge of #80189 - jyn514:convert-primitives, r=poliorcetics
Convert primitives in the standard library to intra-doc links Blocked on #80181. I forgot that this needs to wait for the beta bump so the standard library can be documented with `doc --stage 0`. Notably I didn't convert `core::slice` because it's like 50 links and I got scared 😨
2 parents ef0d592 + 4d46735 commit bc5669e

Some content is hidden

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

47 files changed

+174
-210
lines changed

library/alloc/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
#![feature(fundamental)]
105105
#![feature(inplace_iteration)]
106106
#![feature(int_bits_const)]
107+
// Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]`
108+
// blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad
109+
// that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs
110+
// from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
111+
#![feature(intra_doc_pointers)]
107112
#![feature(lang_items)]
108113
#![feature(layout_for_ptr)]
109114
#![feature(maybe_uninit_ref)]

library/alloc/src/slice.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A dynamically-sized view into a contiguous sequence, `[T]`.
22
//!
3-
//! *[See also the slice primitive type](../../std/primitive.slice.html).*
3+
//! *[See also the slice primitive type](slice).*
44
//!
55
//! Slices are a view into a block of memory represented as a pointer and a
66
//! length.
@@ -71,12 +71,12 @@
7171
//! [`.chunks`], [`.windows`] and more.
7272
//!
7373
//! [`Hash`]: core::hash::Hash
74-
//! [`.iter`]: ../../std/primitive.slice.html#method.iter
75-
//! [`.iter_mut`]: ../../std/primitive.slice.html#method.iter_mut
76-
//! [`.split`]: ../../std/primitive.slice.html#method.split
77-
//! [`.splitn`]: ../../std/primitive.slice.html#method.splitn
78-
//! [`.chunks`]: ../../std/primitive.slice.html#method.chunks
79-
//! [`.windows`]: ../../std/primitive.slice.html#method.windows
74+
//! [`.iter`]: slice::iter
75+
//! [`.iter_mut`]: slice::iter_mut
76+
//! [`.split`]: slice::split
77+
//! [`.splitn`]: slice::splitn
78+
//! [`.chunks`]: slice::chunks
79+
//! [`.windows`]: slice::windows
8080
#![stable(feature = "rust1", since = "1.0.0")]
8181
// Many of the usings in this module are only used in the test configuration.
8282
// It's cleaner to just turn off the unused_imports warning than to fix them.
@@ -673,7 +673,7 @@ impl [u8] {
673673
// Extension traits for slices over specific kinds of data
674674
////////////////////////////////////////////////////////////////////////////////
675675

676-
/// Helper trait for [`[T]::concat`](../../std/primitive.slice.html#method.concat).
676+
/// Helper trait for [`[T]::concat`](slice::concat).
677677
///
678678
/// Note: the `Item` type parameter is not used in this trait,
679679
/// but it allows impls to be more generic.
@@ -708,19 +708,19 @@ pub trait Concat<Item: ?Sized> {
708708
/// The resulting type after concatenation
709709
type Output;
710710

711-
/// Implementation of [`[T]::concat`](../../std/primitive.slice.html#method.concat)
711+
/// Implementation of [`[T]::concat`](slice::concat)
712712
#[unstable(feature = "slice_concat_trait", issue = "27747")]
713713
fn concat(slice: &Self) -> Self::Output;
714714
}
715715

716-
/// Helper trait for [`[T]::join`](../../std/primitive.slice.html#method.join)
716+
/// Helper trait for [`[T]::join`](slice::join)
717717
#[unstable(feature = "slice_concat_trait", issue = "27747")]
718718
pub trait Join<Separator> {
719719
#[unstable(feature = "slice_concat_trait", issue = "27747")]
720720
/// The resulting type after concatenation
721721
type Output;
722722

723-
/// Implementation of [`[T]::join`](../../std/primitive.slice.html#method.join)
723+
/// Implementation of [`[T]::join`](slice::join)
724724
#[unstable(feature = "slice_concat_trait", issue = "27747")]
725725
fn join(slice: &Self, sep: Separator) -> Self::Output;
726726
}

library/alloc/src/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Unicode string slices.
22
//!
3-
//! *[See also the `str` primitive type](../../std/primitive.str.html).*
3+
//! *[See also the `str` primitive type](str).*
44
//!
55
//! The `&str` type is one of the two main string types, the other being `String`.
66
//! Unlike its `String` counterpart, its contents are borrowed.

library/alloc/src/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl String {
495495
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
496496
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
497497
///
498-
/// [byteslice]: ../../std/primitive.slice.html
498+
/// [byteslice]: prim@slice
499499
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
500500
///
501501
/// If you are sure that the byte slice is valid UTF-8, and you don't want

library/alloc/src/vec/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ mod spec_extend;
216216
/// # Slicing
217217
///
218218
/// A `Vec` can be mutable. Slices, on the other hand, are read-only objects.
219-
/// To get a [slice], use [`&`]. Example:
219+
/// To get a [slice][prim@slice], use [`&`]. Example:
220220
///
221221
/// ```
222222
/// fn read_slice(slice: &[usize]) {
@@ -369,8 +369,6 @@ mod spec_extend;
369369
/// [`reserve`]: Vec::reserve
370370
/// [`MaybeUninit`]: core::mem::MaybeUninit
371371
/// [owned slice]: Box
372-
/// [slice]: ../../std/primitive.slice.html
373-
/// [`&`]: ../../std/primitive.reference.html
374372
#[stable(feature = "rust1", since = "1.0.0")]
375373
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")]
376374
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
@@ -2517,7 +2515,7 @@ impl<T, A: Allocator> Vec<T, A> {
25172515
/// This implementation is specialized for slice iterators, where it uses [`copy_from_slice`] to
25182516
/// append the entire slice at once.
25192517
///
2520-
/// [`copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
2518+
/// [`copy_from_slice`]: slice::copy_from_slice
25212519
#[stable(feature = "extend_ref", since = "1.2.0")]
25222520
impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
25232521
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {

library/core/src/alloc/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ impl Layout {
164164
/// [`Layout::for_value`] on a reference to an extern type tail.
165165
/// - otherwise, it is conservatively not allowed to call this function.
166166
///
167-
/// [slice]: ../../std/primitive.slice.html
168167
/// [trait object]: ../../book/ch17-02-trait-objects.html
169168
/// [extern type]: ../../unstable-book/language-features/extern-types.html
170169
#[unstable(feature = "layout_for_ptr", issue = "69835")]

library/core/src/array/iter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crate::{
99
};
1010

1111
/// A by-value [array] iterator.
12-
///
13-
/// [array]: ../../std/primitive.array.html
1412
#[stable(feature = "array_value_iter", since = "1.51.0")]
1513
pub struct IntoIter<T, const N: usize> {
1614
/// This is the array we are iterating over.

library/core/src/array/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! up to a certain length. Eventually, we should be able to generalize
33
//! to all lengths.
44
//!
5-
//! *[See also the array primitive type](../../std/primitive.array.html).*
5+
//! *[See also the array primitive type](array).*
66
77
#![stable(feature = "core_array", since = "1.36.0")]
88

library/core/src/char/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
//! [Unicode code point]: http://www.unicode.org/glossary/#code_point
1010
//!
1111
//! This module exists for technical reasons, the primary documentation for
12-
//! `char` is directly on [the `char` primitive type](../../std/primitive.char.html)
13-
//! itself.
12+
//! `char` is directly on [the `char` primitive type][char] itself.
1413
//!
1514
//! This module is the home of the iterator implementations for the iterators
1615
//! implemented on `char`, as well as some useful constants and conversion

library/core/src/convert/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ pub trait TryInto<T>: Sized {
463463
/// ```
464464
///
465465
/// [`try_from`]: TryFrom::try_from
466-
/// [`!`]: ../../std/primitive.never.html
467466
#[rustc_diagnostic_item = "try_from_trait"]
468467
#[stable(feature = "try_from", since = "1.34.0")]
469468
pub trait TryFrom<T>: Sized {
@@ -673,8 +672,6 @@ impl AsMut<str> for str {
673672
/// However when `Infallible` becomes an alias for the never type,
674673
/// the two `impl`s will start to overlap
675674
/// and therefore will be disallowed by the language’s trait coherence rules.
676-
///
677-
/// [never]: ../../std/primitive.never.html
678675
#[stable(feature = "convert_infallible", since = "1.34.0")]
679676
#[derive(Copy)]
680677
pub enum Infallible {}

library/core/src/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::ops::{Deref, DerefMut};
2121
/// compiler down to 1.1.0. After Rust 1.30.0, it was re-exported by
2222
/// this definition. For more information, please read [RFC 2521].
2323
///
24-
/// [pointer]: ../../std/primitive.pointer.html
2524
/// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
2625
/// [RFC 2521]: https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md
2726
// N.B., for LLVM to recognize the void pointer type and by extension

library/core/src/intrinsics.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,7 @@ extern "rust-intrinsic" {
10931093
/// bounds or arithmetic overflow occurs then any further use of the
10941094
/// returned value will result in undefined behavior.
10951095
///
1096-
/// The stabilized version of this intrinsic is
1097-
/// [`std::pointer::offset`](../../std/primitive.pointer.html#method.offset).
1096+
/// The stabilized version of this intrinsic is [`pointer::offset`].
10981097
#[must_use = "returns a new pointer rather than modifying its argument"]
10991098
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
11001099
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
@@ -1111,8 +1110,7 @@ extern "rust-intrinsic" {
11111110
/// object, and it wraps with two's complement arithmetic. The resulting
11121111
/// value is not necessarily valid to be used to actually access memory.
11131112
///
1114-
/// The stabilized version of this intrinsic is
1115-
/// [`std::pointer::wrapping_offset`](../../std/primitive.pointer.html#method.wrapping_offset).
1113+
/// The stabilized version of this intrinsic is [`pointer::wrapping_offset`].
11161114
#[must_use = "returns a new pointer rather than modifying its argument"]
11171115
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
11181116
pub fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
#![feature(extended_key_value_attributes)]
115115
#![feature(extern_types)]
116116
#![feature(fundamental)]
117-
#![cfg_attr(not(bootstrap), feature(intra_doc_pointers))]
117+
#![feature(intra_doc_pointers)]
118118
#![feature(intrinsics)]
119119
#![feature(lang_items)]
120120
#![feature(link_llvm_intrinsics)]

library/core/src/mem/maybe_uninit.rs

-2
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ impl<T> MaybeUninit<T> {
976976
/// ```
977977
///
978978
/// [`write_slice_cloned`]: MaybeUninit::write_slice_cloned
979-
/// [`slice::copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
980979
#[unstable(feature = "maybe_uninit_write_slice", issue = "79995")]
981980
pub fn write_slice<'a>(this: &'a mut [MaybeUninit<T>], src: &[T]) -> &'a mut [T]
982981
where
@@ -1037,7 +1036,6 @@ impl<T> MaybeUninit<T> {
10371036
/// ```
10381037
///
10391038
/// [`write_slice`]: MaybeUninit::write_slice
1040-
/// [`slice::clone_from_slice`]: ../../std/primitive.slice.html#method.clone_from_slice
10411039
#[unstable(feature = "maybe_uninit_write_slice", issue = "79995")]
10421040
pub fn write_slice_cloned<'a>(this: &'a mut [MaybeUninit<T>], src: &[T]) -> &'a mut [T]
10431041
where

library/core/src/mem/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ pub const fn size_of<T>() -> usize {
308308
/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object],
309309
/// then `size_of_val` can be used to get the dynamically-known size.
310310
///
311-
/// [slice]: ../../std/primitive.slice.html
312311
/// [trait object]: ../../book/ch17-02-trait-objects.html
313312
///
314313
/// # Examples
@@ -355,7 +354,6 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
355354
/// [`size_of_val`] on a reference to a type with an extern type tail.
356355
/// - otherwise, it is conservatively not allowed to call this function.
357356
///
358-
/// [slice]: ../../std/primitive.slice.html
359357
/// [trait object]: ../../book/ch17-02-trait-objects.html
360358
/// [extern type]: ../../unstable-book/language-features/extern-types.html
361359
///
@@ -494,7 +492,6 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
494492
/// [`align_of_val`] on a reference to a type with an extern type tail.
495493
/// - otherwise, it is conservatively not allowed to call this function.
496494
///
497-
/// [slice]: ../../std/primitive.slice.html
498495
/// [trait object]: ../../book/ch17-02-trait-objects.html
499496
/// [extern type]: ../../unstable-book/language-features/extern-types.html
500497
///

library/core/src/num/f32.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Constants specific to the `f32` single-precision floating point type.
22
//!
3-
//! *[See also the `f32` primitive type](../../std/primitive.f32.html).*
3+
//! *[See also the `f32` primitive type][f32].*
44
//!
55
//! Mathematically significant numbers are provided in the `consts` sub-module.
66
//!
@@ -35,7 +35,7 @@ use crate::num::FpCategory;
3535
pub const RADIX: u32 = f32::RADIX;
3636

3737
/// Number of significant digits in base 2.
38-
/// Use [`f32::MANTISSA_DIGITS`](../../std/primitive.f32.html#associatedconstant.MANTISSA_DIGITS) instead.
38+
/// Use [`f32::MANTISSA_DIGITS`] instead.
3939
///
4040
/// # Examples
4141
///
@@ -55,7 +55,7 @@ pub const RADIX: u32 = f32::RADIX;
5555
pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
5656

5757
/// Approximate number of significant digits in base 10.
58-
/// Use [`f32::DIGITS`](../../std/primitive.f32.html#associatedconstant.DIGITS) instead.
58+
/// Use [`f32::DIGITS`] instead.
5959
///
6060
/// # Examples
6161
///
@@ -72,7 +72,7 @@ pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
7272
pub const DIGITS: u32 = f32::DIGITS;
7373

7474
/// [Machine epsilon] value for `f32`.
75-
/// Use [`f32::EPSILON`](../../std/primitive.f32.html#associatedconstant.EPSILON) instead.
75+
/// Use [`f32::EPSILON`] instead.
7676
///
7777
/// This is the difference between `1.0` and the next larger representable number.
7878
///
@@ -96,7 +96,7 @@ pub const DIGITS: u32 = f32::DIGITS;
9696
pub const EPSILON: f32 = f32::EPSILON;
9797

9898
/// Smallest finite `f32` value.
99-
/// Use [`f32::MIN`](../../std/primitive.f32.html#associatedconstant.MIN) instead.
99+
/// Use [`f32::MIN`] instead.
100100
///
101101
/// # Examples
102102
///
@@ -113,7 +113,7 @@ pub const EPSILON: f32 = f32::EPSILON;
113113
pub const MIN: f32 = f32::MIN;
114114

115115
/// Smallest positive normal `f32` value.
116-
/// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead.
116+
/// Use [`f32::MIN_POSITIVE`] instead.
117117
///
118118
/// # Examples
119119
///
@@ -133,7 +133,7 @@ pub const MIN: f32 = f32::MIN;
133133
pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
134134

135135
/// Largest finite `f32` value.
136-
/// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead.
136+
/// Use [`f32::MAX`] instead.
137137
///
138138
/// # Examples
139139
///
@@ -150,7 +150,7 @@ pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
150150
pub const MAX: f32 = f32::MAX;
151151

152152
/// One greater than the minimum possible normal power of 2 exponent.
153-
/// Use [`f32::MIN_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_EXP) instead.
153+
/// Use [`f32::MIN_EXP`] instead.
154154
///
155155
/// # Examples
156156
///
@@ -170,7 +170,7 @@ pub const MAX: f32 = f32::MAX;
170170
pub const MIN_EXP: i32 = f32::MIN_EXP;
171171

172172
/// Maximum possible power of 2 exponent.
173-
/// Use [`f32::MAX_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_EXP) instead.
173+
/// Use [`f32::MAX_EXP`] instead.
174174
///
175175
/// # Examples
176176
///
@@ -190,7 +190,7 @@ pub const MIN_EXP: i32 = f32::MIN_EXP;
190190
pub const MAX_EXP: i32 = f32::MAX_EXP;
191191

192192
/// Minimum possible normal power of 10 exponent.
193-
/// Use [`f32::MIN_10_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_10_EXP) instead.
193+
/// Use [`f32::MIN_10_EXP`] instead.
194194
///
195195
/// # Examples
196196
///
@@ -210,7 +210,7 @@ pub const MAX_EXP: i32 = f32::MAX_EXP;
210210
pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
211211

212212
/// Maximum possible power of 10 exponent.
213-
/// Use [`f32::MAX_10_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_10_EXP) instead.
213+
/// Use [`f32::MAX_10_EXP`] instead.
214214
///
215215
/// # Examples
216216
///
@@ -230,7 +230,7 @@ pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
230230
pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
231231

232232
/// Not a Number (NaN).
233-
/// Use [`f32::NAN`](../../std/primitive.f32.html#associatedconstant.NAN) instead.
233+
/// Use [`f32::NAN`] instead.
234234
///
235235
/// # Examples
236236
///
@@ -247,7 +247,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
247247
pub const NAN: f32 = f32::NAN;
248248

249249
/// Infinity (∞).
250-
/// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead.
250+
/// Use [`f32::INFINITY`] instead.
251251
///
252252
/// # Examples
253253
///
@@ -267,7 +267,7 @@ pub const NAN: f32 = f32::NAN;
267267
pub const INFINITY: f32 = f32::INFINITY;
268268

269269
/// Negative infinity (−∞).
270-
/// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead.
270+
/// Use [`f32::NEG_INFINITY`] instead.
271271
///
272272
/// # Examples
273273
///

0 commit comments

Comments
 (0)