From 25c62ebfdd53c3a41c5bd55b1dd3a5515d107f21 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Feb 2016 19:46:00 +0100 Subject: [PATCH 1/5] Add f32 and f64 examples warning --- src/libstd/primitive_docs.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index e5819522123..839287d1321 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -488,6 +488,9 @@ mod prim_tuple { } /// /// *[See also the `std::f32` module](f32/index.html).* /// +/// However, please note that examples are shared between the `f64` and `f32` +/// primitive types. So it's normal if you see usage of `f64` in there. +/// mod prim_f32 { } #[doc(primitive = "f64")] @@ -496,6 +499,9 @@ mod prim_f32 { } /// /// *[See also the `std::f64` module](f64/index.html).* /// +/// However, please note that examples are shared between the `f64` and `f32` +/// primitive types. So it's normal if you see usage of `f32` in there. +/// mod prim_f64 { } #[doc(primitive = "i8")] From 7a549598bb35601dae25eab8dacb0a053ec3fcae Mon Sep 17 00:00:00 2001 From: Katze Date: Fri, 26 Feb 2016 09:45:32 +0100 Subject: [PATCH 2/5] documentation fix `continue` expression's description mentioned `break` instead of `continue` Signed-off-by: benaryorg --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 228af394838..ebad8c6c75e 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3036,7 +3036,7 @@ the case of a `while` loop, the head is the conditional expression controlling the loop. In the case of a `for` loop, the head is the call-expression controlling the loop. If the label is present, then `continue 'foo` returns control to the head of the loop with label `'foo`, which need not be the -innermost label enclosing the `break` expression, but must enclose it. +innermost label enclosing the `continue` expression, but must enclose it. A `continue` expression is only permitted in the body of a loop. From 77c1e11249703904adccdf7d5b52435a45e7f2db Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 26 Feb 2016 21:21:02 +0000 Subject: [PATCH 3/5] Fix typo in release notes --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index a247eb2e955..d279378a2dd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -75,8 +75,8 @@ Libraries improved by using `memchr` to search for newlines][1.7m]. * [`f32::to_degrees` and `f32::to_radians` are stable][1.7f]. The `f64` variants were stabilized previously. -* [`BTreeMap` was rewritten to use less memory improve performance of - insertion and iteration, the latter by as much as 5x`][1.7bm]. +* [`BTreeMap` was rewritten to use less memory and improve the performance + of insertion and iteration, the latter by as much as 5x`][1.7bm]. * [`BTreeSet` and its iterators, `Iter`, `IntoIter`, and `Range` are covariant over their contained type][1.7bt]. * [`LinkedList` and its iterators, `Iter` and `IntoIter` are covariant From 31fef237b639fac3a1b719110fa0cfad3df44332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 27 Feb 2016 00:53:33 +0100 Subject: [PATCH 4/5] Avoid excessive reallocations during item-bodies checking When foldings Substs, we map over VecPerParamSpace instances using EnumeratedItems which does not provide an accurate size_hint() in its Iterator implementation. This leads to quite a large number or reallocations. Providing a suitable size_hint() implementation reduces the time spent in item-bodies checking quite a bit. ``` crate | before | after | ~change -------|------------------------- core | 7.28s | 5.44s | -25% std | 2.07s | 1.88s | -9.2% syntax | 8.86s | 8.30s | -6.3% ``` --- src/librustc/middle/subst.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index ddc817ffc02..f8c6d3d9341 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -555,6 +555,11 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> { None } } + + fn size_hint(&self) -> (usize, Option) { + let size = self.vec.as_slice().len(); + (size, Some(size)) + } } impl IntoIterator for VecPerParamSpace { From d41d3a5b9873034a973efcec70a838f3bfd6066e Mon Sep 17 00:00:00 2001 From: Michael Huynh Date: Sat, 27 Feb 2016 08:25:31 +0800 Subject: [PATCH 5/5] Improve formatting of the primitive str documentation Adds extra documentation links for library types and methods to be consistent with similar items already linked. Also includes minor formatting fixes. --- src/libcollections/str.rs | 52 ++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 89b5e5b3075..5f3df398f16 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -267,9 +267,11 @@ impl str { /// Converts a string slice to a raw pointer. /// /// As string slices are a slice of bytes, the raw pointer points to a - /// `u8`. This pointer will be pointing to the first byte of the string + /// [`u8`]. This pointer will be pointing to the first byte of the string /// slice. /// + /// [`u8`]: primitive.u8.html + /// /// # Examples /// /// Basic usage: @@ -661,7 +663,7 @@ impl str { /// assert_eq!(None, chars.next()); /// ``` /// - /// Remember, `char`s may not match your human intuition about characters: + /// Remember, [`char`]s may not match your human intuition about characters: /// /// ``` /// let y = "y̆"; @@ -678,16 +680,18 @@ impl str { pub fn chars(&self) -> Chars { core_str::StrExt::chars(self) } - /// Returns an iterator over the `char`s of a string slice, and their + /// Returns an iterator over the [`char`]s of a string slice, and their /// positions. /// /// As a string slice consists of valid UTF-8, we can iterate through a - /// string slice by `char`. This method returns an iterator of both - /// these `char`s, as well as their byte positions. + /// string slice by [`char`]. This method returns an iterator of both + /// these [`char`]s, as well as their byte positions. /// - /// The iterator yields tuples. The position is first, the `char` is + /// The iterator yields tuples. The position is first, the [`char`] is /// second. /// + /// [`char`]: primitive.char.html + /// /// # Examples /// /// Basic usage: @@ -711,7 +715,7 @@ impl str { /// assert_eq!(None, char_indices.next()); /// ``` /// - /// Remember, `char`s may not match your human intuition about characters: + /// Remember, [`char`]s may not match your human intuition about characters: /// /// ``` /// let y = "y̆"; @@ -918,12 +922,13 @@ impl str { /// Returns the byte index of the first character of this string slice that /// matches the pattern. /// - /// Returns `None` if the pattern doesn't match. + /// Returns [`None`] if the pattern doesn't match. /// /// The pattern can be a `&str`, [`char`], or a closure that determines if /// a character matches. /// /// [`char`]: primitive.char.html + /// [`None`]: option/enum.Option.html#variant.None /// /// # Examples /// @@ -962,12 +967,13 @@ impl str { /// Returns the byte index of the last character of this string slice that /// matches the pattern. /// - /// Returns `None` if the pattern doesn't match. + /// Returns [`None`] if the pattern doesn't match. /// /// The pattern can be a `&str`, [`char`], or a closure that determines if /// a character matches. /// /// [`char`]: primitive.char.html + /// [`None`]: option/enum.Option.html#variant.None /// /// # Examples /// @@ -1187,14 +1193,18 @@ impl str { /// An iterator over substrings of `self`, separated by characters /// matched by a pattern and yielded in reverse order. /// - /// The pattern can be a simple `&str`, `char`, or a closure that + /// The pattern can be a simple `&str`, [`char`], or a closure that /// determines the split. /// Additional libraries might provide more complex patterns like /// regular expressions. /// - /// Equivalent to `split`, except that the trailing substring is + /// [`char`]: primitive.char.html + /// + /// Equivalent to [`split()`], except that the trailing substring is /// skipped if empty. /// + /// [`split()`]: #method.split + /// /// This method can be used for string data that is _terminated_, /// rather than _separated_ by a pattern. /// @@ -1457,7 +1467,7 @@ impl str { /// # Iterator behavior /// /// The returned iterator requires that the pattern supports a reverse - /// search, and it will be a `[DoubleEndedIterator]` if a forward/reverse + /// search, and it will be a [`DoubleEndedIterator`] if a forward/reverse /// search yields the same elements. /// /// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html @@ -1694,9 +1704,11 @@ impl str { /// /// # Errors /// - /// Will return `Err` if it's not possible to parse this string slice into + /// Will return [`Err`] if it's not possible to parse this string slice into /// the desired type. /// + /// [`Err`]: str/trait.FromStr.html#associatedtype.Err + /// /// # Example /// /// Basic usage @@ -1707,7 +1719,7 @@ impl str { /// assert_eq!(4, four); /// ``` /// - /// Using the 'turbofish' instead of annotationg `four`: + /// Using the 'turbofish' instead of annotating `four`: /// /// ``` /// let four = "4".parse::(); @@ -1765,11 +1777,13 @@ impl str { result } - /// Returns the lowercase equivalent of this string slice, as a new `String`. + /// Returns the lowercase equivalent of this string slice, as a new [`String`]. /// /// 'Lowercase' is defined according to the terms of the Unicode Derived Core Property /// `Lowercase`. /// + /// [`String`]: string/struct.String.html + /// /// # Examples /// /// Basic usage: @@ -1839,11 +1853,13 @@ impl str { } } - /// Returns the uppercase equivalent of this string slice, as a new `String`. + /// Returns the uppercase equivalent of this string slice, as a new [`String`]. /// /// 'Uppercase' is defined according to the terms of the Unicode Derived Core Property /// `Uppercase`. /// + /// [`String`]: string/struct.String.html + /// /// # Examples /// /// Basic usage: @@ -1884,7 +1900,9 @@ impl str { self.chars().flat_map(|c| c.escape_unicode()).collect() } - /// Converts a `Box` into a `String` without copying or allocating. + /// Converts a `Box` into a [`String`] without copying or allocating. + /// + /// [`String`]: string/struct.String.html /// /// # Examples ///