Skip to content

Commit

Permalink
Rollup merge of rust-lang#80189 - jyn514:convert-primitives, r=polior…
Browse files Browse the repository at this point in the history
…cetics

Convert primitives in the standard library to intra-doc links

Blocked on rust-lang#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 😨
  • Loading branch information
JohnTitor authored Mar 2, 2021
2 parents ef0d592 + 4d46735 commit bc5669e
Show file tree
Hide file tree
Showing 47 changed files with 174 additions and 210 deletions.
5 changes: 5 additions & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
#![feature(fundamental)]
#![feature(inplace_iteration)]
#![feature(int_bits_const)]
// Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]`
// blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad
// that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs
// from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
#![feature(intra_doc_pointers)]
#![feature(lang_items)]
#![feature(layout_for_ptr)]
#![feature(maybe_uninit_ref)]
Expand Down
22 changes: 11 additions & 11 deletions library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A dynamically-sized view into a contiguous sequence, `[T]`.
//!
//! *[See also the slice primitive type](../../std/primitive.slice.html).*
//! *[See also the slice primitive type](slice).*
//!
//! Slices are a view into a block of memory represented as a pointer and a
//! length.
Expand Down Expand Up @@ -71,12 +71,12 @@
//! [`.chunks`], [`.windows`] and more.
//!
//! [`Hash`]: core::hash::Hash
//! [`.iter`]: ../../std/primitive.slice.html#method.iter
//! [`.iter_mut`]: ../../std/primitive.slice.html#method.iter_mut
//! [`.split`]: ../../std/primitive.slice.html#method.split
//! [`.splitn`]: ../../std/primitive.slice.html#method.splitn
//! [`.chunks`]: ../../std/primitive.slice.html#method.chunks
//! [`.windows`]: ../../std/primitive.slice.html#method.windows
//! [`.iter`]: slice::iter
//! [`.iter_mut`]: slice::iter_mut
//! [`.split`]: slice::split
//! [`.splitn`]: slice::splitn
//! [`.chunks`]: slice::chunks
//! [`.windows`]: slice::windows
#![stable(feature = "rust1", since = "1.0.0")]
// Many of the usings in this module are only used in the test configuration.
// It's cleaner to just turn off the unused_imports warning than to fix them.
Expand Down Expand Up @@ -673,7 +673,7 @@ impl [u8] {
// Extension traits for slices over specific kinds of data
////////////////////////////////////////////////////////////////////////////////

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

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

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

/// Implementation of [`[T]::join`](../../std/primitive.slice.html#method.join)
/// Implementation of [`[T]::join`](slice::join)
#[unstable(feature = "slice_concat_trait", issue = "27747")]
fn join(slice: &Self, sep: Separator) -> Self::Output;
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/str.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Unicode string slices.
//!
//! *[See also the `str` primitive type](../../std/primitive.str.html).*
//! *[See also the `str` primitive type](str).*
//!
//! The `&str` type is one of the two main string types, the other being `String`.
//! Unlike its `String` counterpart, its contents are borrowed.
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl String {
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
///
/// [byteslice]: ../../std/primitive.slice.html
/// [byteslice]: prim@slice
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
///
/// If you are sure that the byte slice is valid UTF-8, and you don't want
Expand Down
6 changes: 2 additions & 4 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mod spec_extend;
/// # Slicing
///
/// A `Vec` can be mutable. Slices, on the other hand, are read-only objects.
/// To get a [slice], use [`&`]. Example:
/// To get a [slice][prim@slice], use [`&`]. Example:
///
/// ```
/// fn read_slice(slice: &[usize]) {
Expand Down Expand Up @@ -369,8 +369,6 @@ mod spec_extend;
/// [`reserve`]: Vec::reserve
/// [`MaybeUninit`]: core::mem::MaybeUninit
/// [owned slice]: Box
/// [slice]: ../../std/primitive.slice.html
/// [`&`]: ../../std/primitive.reference.html
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")]
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
Expand Down Expand Up @@ -2517,7 +2515,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// This implementation is specialized for slice iterators, where it uses [`copy_from_slice`] to
/// append the entire slice at once.
///
/// [`copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
/// [`copy_from_slice`]: slice::copy_from_slice
#[stable(feature = "extend_ref", since = "1.2.0")]
impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
Expand Down
1 change: 0 additions & 1 deletion library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ impl Layout {
/// [`Layout::for_value`] on a reference to an extern type tail.
/// - otherwise, it is conservatively not allowed to call this function.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
/// [extern type]: ../../unstable-book/language-features/extern-types.html
#[unstable(feature = "layout_for_ptr", issue = "69835")]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use crate::{
};

/// A by-value [array] iterator.
///
/// [array]: ../../std/primitive.array.html
#[stable(feature = "array_value_iter", since = "1.51.0")]
pub struct IntoIter<T, const N: usize> {
/// This is the array we are iterating over.
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! up to a certain length. Eventually, we should be able to generalize
//! to all lengths.
//!
//! *[See also the array primitive type](../../std/primitive.array.html).*
//! *[See also the array primitive type](array).*
#![stable(feature = "core_array", since = "1.36.0")]

Expand Down
3 changes: 1 addition & 2 deletions library/core/src/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//! [Unicode code point]: http://www.unicode.org/glossary/#code_point
//!
//! This module exists for technical reasons, the primary documentation for
//! `char` is directly on [the `char` primitive type](../../std/primitive.char.html)
//! itself.
//! `char` is directly on [the `char` primitive type][char] itself.
//!
//! This module is the home of the iterator implementations for the iterators
//! implemented on `char`, as well as some useful constants and conversion
Expand Down
3 changes: 0 additions & 3 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ pub trait TryInto<T>: Sized {
/// ```
///
/// [`try_from`]: TryFrom::try_from
/// [`!`]: ../../std/primitive.never.html
#[rustc_diagnostic_item = "try_from_trait"]
#[stable(feature = "try_from", since = "1.34.0")]
pub trait TryFrom<T>: Sized {
Expand Down Expand Up @@ -673,8 +672,6 @@ impl AsMut<str> for str {
/// However when `Infallible` becomes an alias for the never type,
/// the two `impl`s will start to overlap
/// and therefore will be disallowed by the language’s trait coherence rules.
///
/// [never]: ../../std/primitive.never.html
#[stable(feature = "convert_infallible", since = "1.34.0")]
#[derive(Copy)]
pub enum Infallible {}
Expand Down
1 change: 0 additions & 1 deletion library/core/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::ops::{Deref, DerefMut};
/// compiler down to 1.1.0. After Rust 1.30.0, it was re-exported by
/// this definition. For more information, please read [RFC 2521].
///
/// [pointer]: ../../std/primitive.pointer.html
/// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
/// [RFC 2521]: https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md
// N.B., for LLVM to recognize the void pointer type and by extension
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,7 @@ extern "rust-intrinsic" {
/// bounds or arithmetic overflow occurs then any further use of the
/// returned value will result in undefined behavior.
///
/// The stabilized version of this intrinsic is
/// [`std::pointer::offset`](../../std/primitive.pointer.html#method.offset).
/// The stabilized version of this intrinsic is [`pointer::offset`].
#[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
Expand All @@ -1111,8 +1110,7 @@ extern "rust-intrinsic" {
/// object, and it wraps with two's complement arithmetic. The resulting
/// value is not necessarily valid to be used to actually access memory.
///
/// The stabilized version of this intrinsic is
/// [`std::pointer::wrapping_offset`](../../std/primitive.pointer.html#method.wrapping_offset).
/// The stabilized version of this intrinsic is [`pointer::wrapping_offset`].
#[must_use = "returns a new pointer rather than modifying its argument"]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
pub fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#![feature(extended_key_value_attributes)]
#![feature(extern_types)]
#![feature(fundamental)]
#![cfg_attr(not(bootstrap), feature(intra_doc_pointers))]
#![feature(intra_doc_pointers)]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ impl<T> MaybeUninit<T> {
/// ```
///
/// [`write_slice_cloned`]: MaybeUninit::write_slice_cloned
/// [`slice::copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
#[unstable(feature = "maybe_uninit_write_slice", issue = "79995")]
pub fn write_slice<'a>(this: &'a mut [MaybeUninit<T>], src: &[T]) -> &'a mut [T]
where
Expand Down Expand Up @@ -1037,7 +1036,6 @@ impl<T> MaybeUninit<T> {
/// ```
///
/// [`write_slice`]: MaybeUninit::write_slice
/// [`slice::clone_from_slice`]: ../../std/primitive.slice.html#method.clone_from_slice
#[unstable(feature = "maybe_uninit_write_slice", issue = "79995")]
pub fn write_slice_cloned<'a>(this: &'a mut [MaybeUninit<T>], src: &[T]) -> &'a mut [T]
where
Expand Down
3 changes: 0 additions & 3 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ pub const fn size_of<T>() -> usize {
/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object],
/// then `size_of_val` can be used to get the dynamically-known size.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
///
/// # Examples
Expand Down Expand Up @@ -355,7 +354,6 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
/// [`size_of_val`] on a reference to a type with an extern type tail.
/// - otherwise, it is conservatively not allowed to call this function.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
/// [extern type]: ../../unstable-book/language-features/extern-types.html
///
Expand Down Expand Up @@ -494,7 +492,6 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
/// [`align_of_val`] on a reference to a type with an extern type tail.
/// - otherwise, it is conservatively not allowed to call this function.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
/// [extern type]: ../../unstable-book/language-features/extern-types.html
///
Expand Down
28 changes: 14 additions & 14 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Constants specific to the `f32` single-precision floating point type.
//!
//! *[See also the `f32` primitive type](../../std/primitive.f32.html).*
//! *[See also the `f32` primitive type][f32].*
//!
//! Mathematically significant numbers are provided in the `consts` sub-module.
//!
Expand Down Expand Up @@ -35,7 +35,7 @@ use crate::num::FpCategory;
pub const RADIX: u32 = f32::RADIX;

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

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

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

/// Smallest finite `f32` value.
/// Use [`f32::MIN`](../../std/primitive.f32.html#associatedconstant.MIN) instead.
/// Use [`f32::MIN`] instead.
///
/// # Examples
///
Expand All @@ -113,7 +113,7 @@ pub const EPSILON: f32 = f32::EPSILON;
pub const MIN: f32 = f32::MIN;

/// Smallest positive normal `f32` value.
/// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead.
/// Use [`f32::MIN_POSITIVE`] instead.
///
/// # Examples
///
Expand All @@ -133,7 +133,7 @@ pub const MIN: f32 = f32::MIN;
pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;

/// Largest finite `f32` value.
/// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead.
/// Use [`f32::MAX`] instead.
///
/// # Examples
///
Expand All @@ -150,7 +150,7 @@ pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
pub const MAX: f32 = f32::MAX;

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

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

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

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

/// Not a Number (NaN).
/// Use [`f32::NAN`](../../std/primitive.f32.html#associatedconstant.NAN) instead.
/// Use [`f32::NAN`] instead.
///
/// # Examples
///
Expand All @@ -247,7 +247,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
pub const NAN: f32 = f32::NAN;

/// Infinity (∞).
/// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead.
/// Use [`f32::INFINITY`] instead.
///
/// # Examples
///
Expand All @@ -267,7 +267,7 @@ pub const NAN: f32 = f32::NAN;
pub const INFINITY: f32 = f32::INFINITY;

/// Negative infinity (−∞).
/// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead.
/// Use [`f32::NEG_INFINITY`] instead.
///
/// # Examples
///
Expand Down
Loading

0 comments on commit bc5669e

Please sign in to comment.