From 2d6ab122b7fc4dc94912ec174082cd71c43ea557 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 28 Aug 2020 19:33:53 +0800 Subject: [PATCH 01/17] Liballoc extend use intra doc link --- library/alloc/src/vec.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..b6c172b278e1a 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1610,8 +1610,6 @@ impl Vec { /// vec.extend_from_slice(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` - /// - /// [`extend`]: #method.extend #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] pub fn extend_from_slice(&mut self, other: &[T]) { self.spec_extend(other.iter()) From 7be129e53a8dd2bb84fe99a9e4406099fd181eb0 Mon Sep 17 00:00:00 2001 From: Camelid <37223377+camelid@users.noreply.github.com> Date: Fri, 28 Aug 2020 09:29:06 -0700 Subject: [PATCH 02/17] Add missing hyphen reference counted pointer -> reference-counted pointer --- library/alloc/src/sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 73d2fe74826ed..ff07bf52c0273 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -111,7 +111,7 @@ macro_rules! acquire { /// /// # Cloning references /// -/// Creating a new reference from an existing reference counted pointer is done using the +/// Creating a new reference from an existing reference-counted pointer is done using the /// `Clone` trait implemented for [`Arc`][Arc] and [`Weak`][Weak]. /// /// ``` From c7e428e862384492460872300519bad19ad7c13d Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 16:13:05 +0800 Subject: [PATCH 03/17] Liballoc vec doc use associated function Co-authored-by: Joshua Nelson --- library/alloc/src/vec.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b6c172b278e1a..6fecd8299dcc0 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1610,6 +1610,8 @@ impl Vec { /// vec.extend_from_slice(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` + /// + /// [`extend`]: Vec::extend #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] pub fn extend_from_slice(&mut self, other: &[T]) { self.spec_extend(other.iter()) From 7ee515579ea5230b3fac0b7b33f752e28ff13224 Mon Sep 17 00:00:00 2001 From: asrar Date: Sat, 29 Aug 2020 09:33:41 +0000 Subject: [PATCH 04/17] GH-66816: Removes disable before return Passing --disable-per-crate-search removes the create search inputs so moved code around so that the search input is enabled first before the function returns --- src/librustdoc/html/static/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 881b27a5d6184..1dea27e749113 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2740,6 +2740,10 @@ function defocusSearchBar() { } window.addSearchOptions = function(crates) { + if (search_input) { + search_input.removeAttribute('disabled'); + } + var elem = document.getElementById("crate-search"); if (!elem) { @@ -2781,9 +2785,6 @@ function defocusSearchBar() { } } - if (search_input) { - search_input.removeAttribute('disabled'); - } }; function buildHelperPopup() { From eb2bb9902141e228549c30f39d99f11e0cff4ee4 Mon Sep 17 00:00:00 2001 From: asrar Date: Sat, 29 Aug 2020 10:19:58 +0000 Subject: [PATCH 05/17] GH-66816: Process before enabling search --- src/librustdoc/html/static/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1dea27e749113..8fffcff59d57b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2739,14 +2739,17 @@ function defocusSearchBar() { }); } - window.addSearchOptions = function(crates) { + function enableSearchInput() { if (search_input) { search_input.removeAttribute('disabled'); } + } + window.addSearchOptions = function(crates) { var elem = document.getElementById("crate-search"); if (!elem) { + enableSearchInput(); return; } var crates_text = []; @@ -2784,7 +2787,7 @@ function defocusSearchBar() { elem.value = savedCrate; } } - + enableSearchInput(); }; function buildHelperPopup() { From d504d553f101bd36aebed28122d43e9fcae0b60e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 18:21:47 +0800 Subject: [PATCH 06/17] Keep doc standard for Vec DrainFilter --- library/alloc/src/vec.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..c024ef7c17db2 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -3026,7 +3026,10 @@ impl Drain<'_, T> { } } -/// An iterator produced by calling `drain_filter` on Vec. +/// A draining iterator with filter predicate for `Vec`. +/// +/// This struct is created by [`Vec::drain_filter()`]. +/// See its documentation for more. #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] #[derive(Debug)] pub struct DrainFilter<'a, T, F> From d727442f2d79e746ce0dad2da519bed91ff4ccda Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 18:23:29 +0800 Subject: [PATCH 07/17] Remove brackets in drain filter docs --- library/alloc/src/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index c024ef7c17db2..7be5f97340e66 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -3028,7 +3028,7 @@ impl Drain<'_, T> { /// A draining iterator with filter predicate for `Vec`. /// -/// This struct is created by [`Vec::drain_filter()`]. +/// This struct is created by [`Vec::drain_filter`]. /// See its documentation for more. #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] #[derive(Debug)] From 12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 18:38:18 +0800 Subject: [PATCH 08/17] Use assertions on Vec doc Clarify what the state of Vec after with_capacity on doc. --- library/alloc/src/vec.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..c2b835bcf3383 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -116,8 +116,10 @@ use crate::raw_vec::RawVec; /// assert_eq!(vec, [0, 0, 0, 0, 0]); /// /// // The following is equivalent, but potentially slower: -/// let mut vec1 = Vec::with_capacity(5); -/// vec1.resize(5, 0); +/// let mut vec = Vec::with_capacity(5); +/// assert_eq!(vec, []); +/// vec.resize(5, 0); +/// assert_eq!(vec, [0, 0, 0, 0, 0]); /// ``` /// /// Use a `Vec` as an efficient stack: From 237c5005d65b28ea135821b2e0e7c66cf2cefa4c Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 20:40:05 +0800 Subject: [PATCH 09/17] Use explicit intra-doc link in path for Vec resize --- library/alloc/src/vec.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..2644ec7f6d90e 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1567,7 +1567,7 @@ impl Vec { /// This method requires `T` to implement [`Clone`], /// in order to be able to clone the passed value. /// If you need more flexibility (or want to rely on [`Default`] instead of - /// [`Clone`]), use [`resize_with`]. + /// [`Clone`]), use [`Vec::resize_with`]. /// /// # Examples /// @@ -1580,8 +1580,6 @@ impl Vec { /// vec.resize(2, 0); /// assert_eq!(vec, [1, 2]); /// ``` - /// - /// [`resize_with`]: Vec::resize_with #[stable(feature = "vec_resize", since = "1.5.0")] pub fn resize(&mut self, new_len: usize, value: T) { let len = self.len(); From be8b5eb529adbb0e62dcc8872918e9c09aba56a4 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 22:39:34 +0800 Subject: [PATCH 10/17] Reuse description from drain_filter Co-authored-by: Joshua Nelson --- library/alloc/src/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 7be5f97340e66..12441ccd41f24 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -3026,7 +3026,7 @@ impl Drain<'_, T> { } } -/// A draining iterator with filter predicate for `Vec`. +/// An iterator which uses a closure to determine if an element should be removed. /// /// This struct is created by [`Vec::drain_filter`]. /// See its documentation for more. From 2d1ab838342c880892a5243bf338b7ead7472928 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 23:07:40 +0800 Subject: [PATCH 11/17] Remove empty vec assertion flow distrupt Co-authored-by: Joshua Nelson --- library/alloc/src/vec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index c2b835bcf3383..277183c120d61 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -117,7 +117,6 @@ use crate::raw_vec::RawVec; /// /// // The following is equivalent, but potentially slower: /// let mut vec = Vec::with_capacity(5); -/// assert_eq!(vec, []); /// vec.resize(5, 0); /// assert_eq!(vec, [0, 0, 0, 0, 0]); /// ``` From 8a92718b64307236514a16c5f69cd5c02d40dd6b Mon Sep 17 00:00:00 2001 From: Prabakaran Kumaresshan <4676330+nixphix@users.noreply.github.com> Date: Thu, 27 Aug 2020 06:43:19 +0530 Subject: [PATCH 12/17] Switch to intra-doc links in core/src/{convert,iter}/mod.rs --- library/core/src/convert/mod.rs | 58 ++++++++++----------------------- library/core/src/iter/mod.rs | 35 +++++--------------- 2 files changed, 26 insertions(+), 67 deletions(-) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 5f10a2eb023a0..31761017dcf4a 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -31,13 +31,6 @@ //! `into` themselves and `from` themselves //! //! See each trait for usage examples. -//! -//! [`Into`]: trait.Into.html -//! [`From`]: trait.From.html -//! [`TryFrom`]: trait.TryFrom.html -//! [`TryInto`]: trait.TryInto.html -//! [`AsRef`]: trait.AsRef.html -//! [`AsMut`]: trait.AsMut.html #![stable(feature = "rust1", since = "1.0.0")] @@ -141,13 +134,11 @@ pub const fn identity(x: T) -> T { /// want to accept all references that can be converted to [`&str`] as an argument. /// Since both [`String`] and [`&str`] implement `AsRef` we can accept both as input argument. /// -/// [`Option`]: ../../std/option/enum.Option.html -/// [`Result`]: ../../std/result/enum.Result.html -/// [`Borrow`]: ../../std/borrow/trait.Borrow.html -/// [`Hash`]: ../../std/hash/trait.Hash.html -/// [`Eq`]: ../../std/cmp/trait.Eq.html -/// [`Ord`]: ../../std/cmp/trait.Ord.html -/// [`&str`]: ../../std/primitive.str.html +/// [`Option`]: crate::option::Option +/// [`Result`]: crate::result::Result +/// [`Borrow`]: crate::borrow::Borrow +/// [`Eq`]: crate::cmp::Eq +/// [`Ord`]: crate::cmp::Ord /// [`String`]: ../../std/string/struct.String.html /// /// ``` @@ -177,8 +168,8 @@ pub trait AsRef { /// **Note: This trait must not fail**. If the conversion can fail, use a /// dedicated method which returns an [`Option`] or a [`Result`]. /// -/// [`Option`]: ../../std/option/enum.Option.html -/// [`Result`]: ../../std/result/enum.Result.html +/// [`Option`]: crate::option::Option +/// [`Result`]: crate::result::Result /// /// # Generic Implementations /// @@ -204,7 +195,7 @@ pub trait AsRef { /// assert_eq!(*boxed_num, 1); /// ``` /// -/// [`Box`]: ../../std/boxed/struct.Box.html +/// [`Box`]: crate::boxed::Box #[stable(feature = "rust1", since = "1.0.0")] pub trait AsMut { /// Performs the conversion. @@ -278,13 +269,10 @@ pub trait AsMut { /// is_hello(s); /// ``` /// -/// [`TryInto`]: trait.TryInto.html -/// [`Option`]: ../../std/option/enum.Option.html -/// [`Result`]: ../../std/result/enum.Result.html +/// [`Option`]: crate::option::Option +/// [`Result`]: crate::result::Result /// [`String`]: ../../std/string/struct.String.html -/// [`From`]: trait.From.html -/// [`Into`]: trait.Into.html -/// [`Vec`]: ../../std/vec/struct.Vec.html +/// [`Vec`]: crate::vec::Vec #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { /// Performs the conversion. @@ -370,12 +358,9 @@ pub trait Into: Sized { /// } /// ``` /// -/// [`TryFrom`]: trait.TryFrom.html -/// [`Option`]: ../../std/option/enum.Option.html -/// [`Result`]: ../../std/result/enum.Result.html +/// [`Option`]: crate::option::Option +/// [`Result`]: crate::result::Result /// [`String`]: ../../std/string/struct.String.html -/// [`Into`]: trait.Into.html -/// [`from`]: trait.From.html#tymethod.from /// [book]: ../../book/ch09-00-error-handling.html #[rustc_diagnostic_item = "from_trait"] #[stable(feature = "rust1", since = "1.0.0")] @@ -404,9 +389,6 @@ pub trait From: Sized { /// /// This suffers the same restrictions and reasoning as implementing /// [`Into`], see there for details. -/// -/// [`TryFrom`]: trait.TryFrom.html -/// [`Into`]: trait.Into.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryInto: Sized { /// The type returned in the event of a conversion error. @@ -436,7 +418,7 @@ pub trait TryInto: Sized { /// # Generic Implementations /// /// - `TryFrom for U` implies [`TryInto`]` for T` -/// - [`try_from`] is reflexive, which means that `TryFrom for T` +/// - [`TryFrom::try_from`] is reflexive, which means that `TryFrom for T` /// is implemented and cannot fail -- the associated `Error` type for /// calling `T::try_from()` on a value of type `T` is [`Infallible`]. /// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be @@ -485,11 +467,8 @@ pub trait TryInto: Sized { /// assert!(try_successful_smaller_number.is_ok()); /// ``` /// -/// [`try_from`]: trait.TryFrom.html#tymethod.try_from -/// [`TryInto`]: trait.TryInto.html -/// [`i32::MAX`]: ../../std/i32/constant.MAX.html +/// [`i32::MAX`]: crate::i32::MAX /// [`!`]: ../../std/primitive.never.html -/// [`Infallible`]: enum.Infallible.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryFrom: Sized { /// The type returned in the event of a conversion error. @@ -676,7 +655,6 @@ impl AsRef for str { /// /// … and eventually deprecate `Infallible`. /// -/// /// However there is one case where `!` syntax can be used /// before `!` is stabilized as a full-fledged type: in the position of a function’s return type. /// Specifically, it is possible implementations for two different function pointer types: @@ -692,10 +670,8 @@ impl AsRef for str { /// the two `impl`s will start to overlap /// and therefore will be disallowed by the language’s trait coherence rules. /// -/// [`Ok`]: ../result/enum.Result.html#variant.Ok -/// [`Result`]: ../result/enum.Result.html -/// [`TryFrom`]: trait.TryFrom.html -/// [`Into`]: trait.Into.html +/// [`Ok`]: super::result::Result::Ok +/// [`Result`]: super::result::Result /// [never]: ../../std/primitive.never.html #[stable(feature = "convert_infallible", since = "1.34.0")] #[derive(Copy)] diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index 9b528cdbe30c4..a2e200ef63d22 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -53,9 +53,7 @@ //! more complex forms of processing. See the [Adapters](#adapters) section //! below for more details. //! -//! [`Some(Item)`]: Some -//! [`Iterator`]: trait.Iterator.html -//! [`next`]: trait.Iterator.html#tymethod.next +//! [`next`]: Iterator::next //! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html //! //! # The three forms of iteration @@ -154,14 +152,11 @@ //! produce an iterator. What gives? //! //! There's a trait in the standard library for converting something into an -//! iterator: [`IntoIterator`]. This trait has one method, [`into_iter`], +//! iterator: [`IntoIterator`]. This trait has one method, [`IntoIterator::into_iter`], //! which converts the thing implementing [`IntoIterator`] into an iterator. //! Let's take a look at that `for` loop again, and what the compiler converts //! it into: //! -//! [`IntoIterator`]: trait.IntoIterator.html -//! [`into_iter`]: trait.IntoIterator.html#tymethod.into_iter -//! //! ``` //! let values = vec![1, 2, 3, 4, 5]; //! @@ -214,7 +209,7 @@ //! often called 'iterator adapters', as they're a form of the 'adapter //! pattern'. //! -//! Common iterator adapters include [`map`], [`take`], and [`filter`]. +//! Common iterator adapters include [`Iterator::map`], [`Iterator::take`], and [`Iterator::filter`]. //! For more, see their documentation. //! //! If an iterator adapter panics, the iterator will be in an unspecified (but @@ -222,16 +217,12 @@ //! across versions of Rust, so you should avoid relying on the exact values //! returned by an iterator which panicked. //! -//! [`map`]: trait.Iterator.html#method.map -//! [`take`]: trait.Iterator.html#method.take -//! [`filter`]: trait.Iterator.html#method.filter -//! //! # Laziness //! //! Iterators (and iterator [adapters](#adapters)) are *lazy*. This means that //! just creating an iterator doesn't _do_ a whole lot. Nothing really happens //! until you call [`next`]. This is sometimes a source of confusion when -//! creating an iterator solely for its side effects. For example, the [`map`] +//! creating an iterator solely for its side effects. For example, the [`Iterator::map`] //! method calls a closure on each element it iterates over: //! //! ``` @@ -248,8 +239,8 @@ //! do nothing unless consumed //! ``` //! -//! The idiomatic way to write a [`map`] for its side effects is to use a -//! `for` loop or call the [`for_each`] method: +//! The idiomatic way to write a [`Iterator::map`] for its side effects is to use a +//! `for` loop or call the [`Iterator::for_each`] method: //! //! ``` //! let v = vec![1, 2, 3, 4, 5]; @@ -261,14 +252,9 @@ //! } //! ``` //! -//! [`map`]: trait.Iterator.html#method.map -//! [`for_each`]: trait.Iterator.html#method.for_each -//! -//! Another common way to evaluate an iterator is to use the [`collect`] +//! Another common way to evaluate an iterator is to use the [`Iterator::collect`] //! method to produce a new collection. //! -//! [`collect`]: trait.Iterator.html#method.collect -//! //! # Infinity //! //! Iterators do not have to be finite. As an example, an open-ended range is @@ -278,7 +264,7 @@ //! let numbers = 0..; //! ``` //! -//! It is common to use the [`take`] iterator adapter to turn an infinite +//! It is common to use the [`Iterator::take`] iterator adapter to turn an infinite //! iterator into a finite one: //! //! ``` @@ -294,7 +280,7 @@ //! //! Bear in mind that methods on infinite iterators, even those for which a //! result can be determined mathematically in finite time, may not terminate. -//! Specifically, methods such as [`min`], which in the general case require +//! Specifically, methods such as [`Iterator::min`], which in the general case require //! traversing every element in the iterator, are likely not to return //! successfully for any infinite iterators. //! @@ -304,9 +290,6 @@ //! // `ones.min()` causes an infinite loop, so we won't reach this point! //! println!("The smallest number one is {}.", least); //! ``` -//! -//! [`take`]: trait.Iterator.html#method.take -//! [`min`]: trait.Iterator.html#method.min #![stable(feature = "rust1", since = "1.0.0")] From 01d95f241bfe4c4c1550beaf81b7c7df007696a9 Mon Sep 17 00:00:00 2001 From: Prabakaran Kumaresshan <4676330+nixphix@users.noreply.github.com> Date: Thu, 27 Aug 2020 08:45:07 +0530 Subject: [PATCH 13/17] resolve comments --- library/core/src/convert/mod.rs | 27 +++++++++++++-------------- library/core/src/iter/mod.rs | 30 ++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 31761017dcf4a..7849d267ccac0 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -134,8 +134,8 @@ pub const fn identity(x: T) -> T { /// want to accept all references that can be converted to [`&str`] as an argument. /// Since both [`String`] and [`&str`] implement `AsRef` we can accept both as input argument. /// -/// [`Option`]: crate::option::Option -/// [`Result`]: crate::result::Result +/// [`Option`]: Option +/// [`Result`]: Result /// [`Borrow`]: crate::borrow::Borrow /// [`Eq`]: crate::cmp::Eq /// [`Ord`]: crate::cmp::Ord @@ -168,8 +168,8 @@ pub trait AsRef { /// **Note: This trait must not fail**. If the conversion can fail, use a /// dedicated method which returns an [`Option`] or a [`Result`]. /// -/// [`Option`]: crate::option::Option -/// [`Result`]: crate::result::Result +/// [`Option`]: Option +/// [`Result`]: Result /// /// # Generic Implementations /// @@ -195,7 +195,7 @@ pub trait AsRef { /// assert_eq!(*boxed_num, 1); /// ``` /// -/// [`Box`]: crate::boxed::Box +/// [`Box`]: ../../std/boxed/struct.Box.html #[stable(feature = "rust1", since = "1.0.0")] pub trait AsMut { /// Performs the conversion. @@ -269,10 +269,10 @@ pub trait AsMut { /// is_hello(s); /// ``` /// -/// [`Option`]: crate::option::Option -/// [`Result`]: crate::result::Result +/// [`Option`]: Option +/// [`Result`]: Result /// [`String`]: ../../std/string/struct.String.html -/// [`Vec`]: crate::vec::Vec +/// [`Vec`]: ../../std/vec/struct.Vec.html #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { /// Performs the conversion. @@ -358,9 +358,10 @@ pub trait Into: Sized { /// } /// ``` /// -/// [`Option`]: crate::option::Option -/// [`Result`]: crate::result::Result +/// [`Option`]: Option +/// [`Result`]: Result /// [`String`]: ../../std/string/struct.String.html +/// [`from`]: From::from /// [book]: ../../book/ch09-00-error-handling.html #[rustc_diagnostic_item = "from_trait"] #[stable(feature = "rust1", since = "1.0.0")] @@ -418,7 +419,7 @@ pub trait TryInto: Sized { /// # Generic Implementations /// /// - `TryFrom for U` implies [`TryInto`]` for T` -/// - [`TryFrom::try_from`] is reflexive, which means that `TryFrom for T` +/// - [`try_from`] is reflexive, which means that `TryFrom for T` /// is implemented and cannot fail -- the associated `Error` type for /// calling `T::try_from()` on a value of type `T` is [`Infallible`]. /// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be @@ -467,7 +468,7 @@ pub trait TryInto: Sized { /// assert!(try_successful_smaller_number.is_ok()); /// ``` /// -/// [`i32::MAX`]: crate::i32::MAX +/// [`try_from`]: TryFrom::try_from /// [`!`]: ../../std/primitive.never.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryFrom: Sized { @@ -670,8 +671,6 @@ impl AsRef for str { /// the two `impl`s will start to overlap /// and therefore will be disallowed by the language’s trait coherence rules. /// -/// [`Ok`]: super::result::Result::Ok -/// [`Result`]: super::result::Result /// [never]: ../../std/primitive.never.html #[stable(feature = "convert_infallible", since = "1.34.0")] #[derive(Copy)] diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index a2e200ef63d22..e482eab5b3de2 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -152,11 +152,13 @@ //! produce an iterator. What gives? //! //! There's a trait in the standard library for converting something into an -//! iterator: [`IntoIterator`]. This trait has one method, [`IntoIterator::into_iter`], +//! iterator: [`IntoIterator`]. This trait has one method, [`into_iter`], //! which converts the thing implementing [`IntoIterator`] into an iterator. //! Let's take a look at that `for` loop again, and what the compiler converts //! it into: //! +//! [`into_iter`]: IntoIterator::into_iter +//! //! ``` //! let values = vec![1, 2, 3, 4, 5]; //! @@ -209,7 +211,7 @@ //! often called 'iterator adapters', as they're a form of the 'adapter //! pattern'. //! -//! Common iterator adapters include [`Iterator::map`], [`Iterator::take`], and [`Iterator::filter`]. +//! Common iterator adapters include [`map`], [`take`], and [`filter`]. //! For more, see their documentation. //! //! If an iterator adapter panics, the iterator will be in an unspecified (but @@ -217,12 +219,16 @@ //! across versions of Rust, so you should avoid relying on the exact values //! returned by an iterator which panicked. //! +//! [`map`]: Iterator::map +//! [`take`]: Iterator::take +//! [`filter`]: Iterator::filter +//! //! # Laziness //! //! Iterators (and iterator [adapters](#adapters)) are *lazy*. This means that //! just creating an iterator doesn't _do_ a whole lot. Nothing really happens //! until you call [`next`]. This is sometimes a source of confusion when -//! creating an iterator solely for its side effects. For example, the [`Iterator::map`] +//! creating an iterator solely for its side effects. For example, the [`map`] //! method calls a closure on each element it iterates over: //! //! ``` @@ -239,8 +245,8 @@ //! do nothing unless consumed //! ``` //! -//! The idiomatic way to write a [`Iterator::map`] for its side effects is to use a -//! `for` loop or call the [`Iterator::for_each`] method: +//! The idiomatic way to write a [`map`] for its side effects is to use a +//! `for` loop or call the [`for_each`] method: //! //! ``` //! let v = vec![1, 2, 3, 4, 5]; @@ -252,9 +258,14 @@ //! } //! ``` //! -//! Another common way to evaluate an iterator is to use the [`Iterator::collect`] +//! [`map`]: Iterator::map +//! [`for_each`]: Iterator::for_each +//! +//! Another common way to evaluate an iterator is to use the [`collect`] //! method to produce a new collection. //! +//! [`collect`]: Iterator::collect +//! //! # Infinity //! //! Iterators do not have to be finite. As an example, an open-ended range is @@ -264,7 +275,7 @@ //! let numbers = 0..; //! ``` //! -//! It is common to use the [`Iterator::take`] iterator adapter to turn an infinite +//! It is common to use the [`take`] iterator adapter to turn an infinite //! iterator into a finite one: //! //! ``` @@ -280,7 +291,7 @@ //! //! Bear in mind that methods on infinite iterators, even those for which a //! result can be determined mathematically in finite time, may not terminate. -//! Specifically, methods such as [`Iterator::min`], which in the general case require +//! Specifically, methods such as [`min`], which in the general case require //! traversing every element in the iterator, are likely not to return //! successfully for any infinite iterators. //! @@ -290,6 +301,9 @@ //! // `ones.min()` causes an infinite loop, so we won't reach this point! //! println!("The smallest number one is {}.", least); //! ``` +//! +//! [`take`]: Iterator::take +//! [`min`]: Iterator::min #![stable(feature = "rust1", since = "1.0.0")] From 7ea4c28af238883884deddbe5c411d01355fd12b Mon Sep 17 00:00:00 2001 From: Prabakaran Kumaresshan <4676330+nixphix@users.noreply.github.com> Date: Sun, 30 Aug 2020 17:07:50 +0530 Subject: [PATCH 14/17] add i32::MAX link --- library/core/src/convert/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 7849d267ccac0..2bfeb49b5fab7 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -468,6 +468,7 @@ pub trait TryInto: Sized { /// assert!(try_successful_smaller_number.is_ok()); /// ``` /// +/// [`i32::MAX`]: crate::i32::MAX /// [`try_from`]: TryFrom::try_from /// [`!`]: ../../std/primitive.never.html #[stable(feature = "try_from", since = "1.34.0")] From 523fea4d1405c4e2d4a96d126f4d990d342de6cc Mon Sep 17 00:00:00 2001 From: Prabakaran Kumaresshan <4676330+nixphix@users.noreply.github.com> Date: Sun, 30 Aug 2020 19:19:20 +0530 Subject: [PATCH 15/17] revert Some(Item) link --- library/core/src/iter/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index e482eab5b3de2..28b22f80e2c1b 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -53,6 +53,7 @@ //! more complex forms of processing. See the [Adapters](#adapters) section //! below for more details. //! +//! [`Some(Item)`]: Some //! [`next`]: Iterator::next //! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html //! From 0175c437e2a94dc33e2b54a6148587ffa7e68e82 Mon Sep 17 00:00:00 2001 From: Who? Me?! Date: Sun, 30 Aug 2020 13:40:11 -0500 Subject: [PATCH 16/17] Update README.md --- src/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/README.md b/src/README.md index 2f8e9da179afa..ef0dec1c45be2 100644 --- a/src/README.md +++ b/src/README.md @@ -1,5 +1,5 @@ This directory contains the source code of the rust project, including: -- `rustc` and its tests +- The test suite - The bootstrapping build system - Various submodules for tools, like rustdoc, rls, etc. From 00d459a93fb5043d82f8b1893aa5b6f55c2fed5c Mon Sep 17 00:00:00 2001 From: CDirkx Date: Mon, 31 Aug 2020 01:22:25 +0200 Subject: [PATCH 17/17] Update MinGW instructions to include ninja Added the `mingw-w64-x86_64-ninja` package to the build guide for MinGW, as well as a note not to use the `ninja` package from the `msys2` subsystem (doesn't handle paths correctly on windows). --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe9776bc5f8fe..095ffdd04b982 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ build. # Install build tools needed for Rust. If you're building a 32-bit compiler, # then replace "x86_64" below with "i686". If you've already got git, python, # or CMake installed and in PATH you can remove them from this list. Note - # that it is important that you do **not** use the 'python2' and 'cmake' + # that it is important that you do **not** use the 'python2', 'cmake' and 'ninja' # packages from the 'msys2' subsystem. The build has historically been known # to fail with these packages. $ pacman -S git \ @@ -121,7 +121,8 @@ build. tar \ mingw-w64-x86_64-python \ mingw-w64-x86_64-cmake \ - mingw-w64-x86_64-gcc + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-ninja ``` 4. Navigate to Rust's source code (or clone it), then build it: