diff options
| author | bors <bors@rust-lang.org> | 2021-09-25 20:08:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-25 20:08:11 +0000 |
| commit | addb4da686a97da46159f0123cb6cdc2ce3d7fdb (patch) | |
| tree | e7e29d87736398b7d7c7884b7ec17552c770a243 /library/core/src | |
| parent | 9620f3a84b079decfdc2e557be007580b097fe43 (diff) | |
| parent | 67065fe93366cfdd9e88440b6f876c3dfeb1f937 (diff) | |
| download | rust-addb4da686a97da46159f0123cb6cdc2ce3d7fdb.tar.gz rust-addb4da686a97da46159f0123cb6cdc2ce3d7fdb.zip | |
Auto merge of #88343 - steffahn:fix_code_spacing, r=jyn514
Fix spacing of links in inline code. Similar to #80733, but the focus is different. This PR eliminates all occurrences of pieced-together inline code blocks like [`Box`]`<`[`Option`]`<T>>` and replaces them with good-looking ones (using HTML-syntax), like <code>[Box]<[Option]\<T>></code>. As far as I can tell, I should’ve found all of these in the standard library (regex search with `` r"`\]`|`\[`" ``) \[except for in `core::convert` where I’ve noticed other things in the docs that I want to fix in a separate PR]. In particular, unlike #80733, I’ve added almost no new instance of inline code that’s broken up into multiple links (or some link and some link-free part). I also added tooltips (the stuff in quotes for the markdown link listings) in places that caught my eye, but that’s by no means systematic, just opportunistic. [Box]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box" [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box" [Option]: https://doc.rust-lang.org/std/option/enum.Option.html "Option" [`Option`]: https://doc.rust-lang.org/std/option/enum.Option.html "Option" Context: I got annoyed by repeatedly running into new misformatted inline code while reading the standard library docs. I know that once issue #83997 (and/or related ones) are resolved, these changes become somewhat obsolete, but I fail to notice much progress on that end right now. r? `@jyn514`
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/iter/mod.rs | 2 | ||||
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 7 | ||||
| -rw-r--r-- | library/core/src/option.rs | 61 | ||||
| -rw-r--r-- | library/core/src/pin.rs | 6 | ||||
| -rw-r--r-- | library/core/src/result.rs | 10 | ||||
| -rw-r--r-- | library/core/src/stream/stream/mod.rs | 4 | ||||
| -rw-r--r-- | library/core/src/task/poll.rs | 5 |
7 files changed, 51 insertions, 44 deletions
diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index d6f9edaa046..39c0b1b522c 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -39,7 +39,7 @@ //! ``` //! //! An iterator has a method, [`next`], which when called, returns an -//! [`Option`]`<Item>`. [`next`] will return [`Some(Item)`] as long as there +//! <code>[Option]\<Item></code>. Calling [`next`] will return [`Some(Item)`] as long as there //! are elements, and once they've all been exhausted, will return `None` to //! indicate that iteration is finished. Individual iterators may choose to //! resume iteration, and so calling [`next`] again may or may not eventually diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f884340f4e0..fa71a1e73a2 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -96,7 +96,7 @@ pub trait Iterator { /// Specifically, `size_hint()` returns a tuple where the first element /// is the lower bound, and the second element is the upper bound. /// - /// The second half of the tuple that is returned is an [`Option`]`<`[`usize`]`>`. + /// The second half of the tuple that is returned is an <code>[Option]<[usize]></code>. /// A [`None`] here means that either there is no known upper bound, or the /// upper bound is larger than [`usize`]. /// @@ -115,11 +115,9 @@ pub trait Iterator { /// That said, the implementation should provide a correct estimation, /// because otherwise it would be a violation of the trait's protocol. /// - /// The default implementation returns `(0, `[`None`]`)` which is correct for any + /// The default implementation returns <code>(0, [None])</code> which is correct for any /// iterator. /// - /// [`usize`]: type@usize - /// /// # Examples /// /// Basic usage: @@ -864,7 +862,6 @@ pub trait Iterator { /// The returned iterator might panic if the to-be-returned index would /// overflow a [`usize`]. /// - /// [`usize`]: type@usize /// [`zip`]: Iterator::zip /// /// # Examples diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 907726f0c34..94d892dd787 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -47,9 +47,9 @@ //! //! Rust's pointer types must always point to a valid location; there are //! no "null" references. Instead, Rust has *optional* pointers, like -//! the optional owned box, [`Option`]`<`[`Box<T>`]`>`. +//! the optional owned box, <code>[Option]<[Box\<T>]></code>. //! -//! [`Box<T>`]: ../../std/boxed/struct.Box.html +//! [Box\<T>]: ../../std/boxed/struct.Box.html //! //! The following example uses [`Option`] to create an optional box of //! [`i32`]. Notice that in order to use the inner [`i32`] value, the @@ -111,16 +111,20 @@ //! //! ## Adapters for working with references //! -//! * [`as_ref`] converts from `&Option<T>` to `Option<&T>` -//! * [`as_mut`] converts from `&mut Option<T>` to `Option<&mut T>` -//! * [`as_deref`] converts from `&Option<T>` to `Option<&T::Target>` -//! * [`as_deref_mut`] converts from `&mut Option<T>` to -//! `Option<&mut T::Target>` -//! * [`as_pin_ref`] converts from [`Pin`]`<&Option<T>>` to -//! `Option<`[`Pin`]`<&T>>` -//! * [`as_pin_mut`] converts from [`Pin`]`<&mut Option<T>>` to -//! `Option<`[`Pin`]`<&mut T>>` -//! +//! * [`as_ref`] converts from <code>[&][][Option]\<T></code> to <code>[Option]<[&]T></code> +//! * [`as_mut`] converts from <code>[&mut] [Option]\<T></code> to <code>[Option]<[&mut] T></code> +//! * [`as_deref`] converts from <code>[&][][Option]\<T></code> to +//! <code>[Option]<[&]T::[Target]></code> +//! * [`as_deref_mut`] converts from <code>[&mut] [Option]\<T></code> to +//! <code>[Option]<[&mut] T::[Target]></code> +//! * [`as_pin_ref`] converts from <code>[Pin]<[&][][Option]\<T>></code> to +//! <code>[Option]<[Pin]<[&]T>></code> +//! * [`as_pin_mut`] converts from <code>[Pin]<[&mut] [Option]\<T>></code> to +//! <code>[Option]<[Pin]<[&mut] T>></code> +//! +//! [&]: reference "shared reference" +//! [&mut]: reference "mutable reference" +//! [Target]: Deref::Target "ops::Deref::Target" //! [`as_deref`]: Option::as_deref //! [`as_deref_mut`]: Option::as_deref_mut //! [`as_mut`]: Option::as_mut @@ -603,13 +607,13 @@ impl<T> Option<T> { /// /// # Examples /// - /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. - /// The [`map`] method takes the `self` argument by value, consuming the original, + /// Converts an <code>Option<[String]></code> into an <code>Option<[usize]></code>, preserving + /// the original. The [`map`] method takes the `self` argument by value, consuming the original, /// so this technique uses `as_ref` to first take an `Option` to a reference /// to the value inside the original. /// /// [`map`]: Option::map - /// [`String`]: ../../std/string/struct.String.html + /// [String]: ../../std/string/struct.String.html "String" /// /// ``` /// let text: Option<String> = Some("Hello, world!".to_string()); @@ -649,7 +653,9 @@ impl<T> Option<T> { } } - /// Converts from [`Pin`]`<&Option<T>>` to `Option<`[`Pin`]`<&T>>`. + /// Converts from <code>[Pin]<[&]Option\<T>></code> to <code>Option<[Pin]<[&]T>></code>. + /// + /// [&]: reference "shared reference" #[inline] #[stable(feature = "pin", since = "1.33.0")] pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> { @@ -658,7 +664,9 @@ impl<T> Option<T> { unsafe { Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x)) } } - /// Converts from [`Pin`]`<&mut Option<T>>` to `Option<`[`Pin`]`<&mut T>>`. + /// Converts from <code>[Pin]<[&mut] Option\<T>></code> to <code>Option<[Pin]<[&mut] T>></code>. + /// + /// [&mut]: reference "mutable reference" #[inline] #[stable(feature = "pin", since = "1.33.0")] pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> { @@ -819,9 +827,10 @@ impl<T> Option<T> { /// /// # Examples /// - /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, consuming the original: + /// Converts an <code>Option<[String]></code> into an <code>Option<[usize]></code>, consuming + /// the original: /// - /// [`String`]: ../../std/string/struct.String.html + /// [String]: ../../std/string/struct.String.html "String" /// ``` /// let maybe_some_string = Some(String::from("Hello, World!")); /// // `Option::map` takes self *by value*, consuming `maybe_some_string` @@ -1581,9 +1590,9 @@ impl<T: DerefMut> Option<T> { impl<T, E> Option<Result<T, E>> { /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`. /// - /// [`None`] will be mapped to [`Ok`]`(`[`None`]`)`. - /// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to - /// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`. + /// [`None`] will be mapped to <code>[Ok]\([None])</code>. + /// <code>[Some]\([Ok]\(\_))</code> and <code>[Some]\([Err]\(\_))</code> will be mapped to + /// <code>[Ok]\([Some]\(\_))</code> and <code>[Err]\(\_)</code>. /// /// # Examples /// @@ -1721,13 +1730,13 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> { /// /// # Examples /// - /// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original. - /// The [`map`] method takes the `self` argument by value, consuming the original, - /// so this technique uses `from` to first take an `Option` to a reference + /// Converts an <code>[Option]<[String]></code> into an <code>[Option]<[usize]></code>, preserving + /// the original. The [`map`] method takes the `self` argument by value, consuming the original, + /// so this technique uses `from` to first take an [`Option`] to a reference /// to the value inside the original. /// /// [`map`]: Option::map - /// [`String`]: ../../std/string/struct.String.html + /// [String]: ../../std/string/struct.String.html "String" /// /// ``` /// let s: Option<String> = Some(String::from("Hello, Rustaceans!")); diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 6a1a84bafa3..8b645792169 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -368,15 +368,15 @@ //! [Vec::push]: ../../std/vec/struct.Vec.html#method.push "Vec::push" //! [Rc]: ../../std/rc/struct.Rc.html "rc::Rc" //! [RefCell]: crate::cell::RefCell "cell::RefCell" -//! [`drop`]: Drop::drop "Drop::drop" +//! [`drop`]: Drop::drop //! [VecDeque]: ../../std/collections/struct.VecDeque.html "collections::VecDeque" //! [`ptr::write`]: crate::ptr::write "ptr::write" //! [`Future`]: crate::future::Future "future::Future" //! [drop-impl]: #drop-implementation //! [drop-guarantee]: #drop-guarantee //! [`poll`]: crate::future::Future::poll "future::Future::poll" -//! [&]: ../../std/primitive.reference.html "shared reference" -//! [&mut]: ../../std/primitive.reference.html "mutable reference" +//! [&]: reference "shared reference" +//! [&mut]: reference "mutable reference" //! [`unsafe`]: ../../std/keyword.unsafe.html "keyword unsafe" #![stable(feature = "pin", since = "1.33.0")] diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 092e6544342..4a300f857e9 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -88,7 +88,7 @@ //! ``` //! //! *Note: The actual definition of [`Write`] uses [`io::Result`], which -//! is just a synonym for [`Result`]`<T, `[`io::Error`]`>`.* +//! is just a synonym for <code>[Result]<T, [io::Error]></code>.* //! //! This method doesn't produce a value, but the write may //! fail. It's crucial to handle the error case, and *not* write @@ -217,13 +217,13 @@ //! early return of [`Err`] that it provides. //! //! [`expect`]: Result::expect -//! [`Write`]: ../../std/io/trait.Write.html -//! [`write_all`]: ../../std/io/trait.Write.html#method.write_all -//! [`io::Result`]: ../../std/io/type.Result.html +//! [`Write`]: ../../std/io/trait.Write.html "io::Write" +//! [`write_all`]: ../../std/io/trait.Write.html#method.write_all "io::Write::write_all" +//! [`io::Result`]: ../../std/io/type.Result.html "io::Result" //! [`?`]: crate::ops::Try //! [`Ok(T)`]: Ok //! [`Err(E)`]: Err -//! [`io::Error`]: ../../std/io/struct.Error.html +//! [io::Error]: ../../std/io/struct.Error.html "io::Error" //! //! # Method overview //! diff --git a/library/core/src/stream/stream/mod.rs b/library/core/src/stream/stream/mod.rs index e37902dae1f..d102619b8e5 100644 --- a/library/core/src/stream/stream/mod.rs +++ b/library/core/src/stream/stream/mod.rs @@ -52,7 +52,7 @@ pub trait Stream { /// Specifically, `size_hint()` returns a tuple where the first element /// is the lower bound, and the second element is the upper bound. /// - /// The second half of the tuple that is returned is an [`Option`]`<`[`usize`]`>`. + /// The second half of the tuple that is returned is an <code>[Option]<[usize]></code>. /// A [`None`] here means that either there is no known upper bound, or the /// upper bound is larger than [`usize`]. /// @@ -71,7 +71,7 @@ pub trait Stream { /// That said, the implementation should provide a correct estimation, /// because otherwise it would be a violation of the trait's protocol. /// - /// The default implementation returns `(0, `[`None`]`)` which is correct for any + /// The default implementation returns <code>(0, [None])</code> which is correct for any /// stream. #[inline] fn size_hint(&self) -> (usize, Option<usize>) { diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs index 25070460996..57416aeb701 100644 --- a/library/core/src/task/poll.rs +++ b/library/core/src/task/poll.rs @@ -30,9 +30,10 @@ impl<T> Poll<T> { /// /// # Examples /// - /// Converts a `Poll<`[`String`]`>` into an `Poll<`[`usize`]`>`, consuming the original: + /// Converts a <code>Poll<[String]></code> into a <code>Poll<[usize]></code>, consuming + /// the original: /// - /// [`String`]: ../../std/string/struct.String.html + /// [String]: ../../std/string/struct.String.html "String" /// ``` /// # use core::task::Poll; /// let poll_some_string = Poll::Ready(String::from("Hello, World!")); |
