From 46c23e8f0316e9dae0f3596ff252a0b69d345369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Lode?= Date: Sun, 17 Jan 2016 04:36:03 +0100 Subject: [PATCH 1/7] Fix typo in std::fmt docs --- src/libcollections/fmt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 1450b8efb0f..31f750b0d36 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -348,8 +348,8 @@ //! The fill character is provided normally in conjunction with the `width` //! parameter. This indicates that if the value being formatted is smaller than //! `width` some extra characters will be printed around it. The extra -//! characters are specified by `fill`, and the alignment can be one of two -//! options: +//! characters are specified by `fill`, and the alignment can be one of the +//! following options: //! //! * `<` - the argument is left-aligned in `width` columns //! * `^` - the argument is center-aligned in `width` columns From 8a829704cb28544dd13c3de831cf822da17e5bf0 Mon Sep 17 00:00:00 2001 From: "Stephen (Ziyun) Li" Date: Sun, 17 Jan 2016 14:56:23 -0500 Subject: [PATCH 2/7] Fix C macro example --- src/doc/book/macros.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc/book/macros.md b/src/doc/book/macros.md index 7c8b74bd649..f5a0cd5e2c6 100644 --- a/src/doc/book/macros.md +++ b/src/doc/book/macros.md @@ -285,9 +285,11 @@ This expands to ```text const char *state = "reticulating splines"; -int state = get_log_state(); -if (state > 0) { - printf("log(%d): %s\n", state, state); +{ + int state = get_log_state(); + if (state > 0) { + printf("log(%d): %s\n", state, state); + } } ``` From f4fac9b0fa55d253b438eccdf1794baace6c9efe Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sun, 17 Jan 2016 23:36:38 +0100 Subject: [PATCH 3/7] Fix spacing style of `T: Bound` in docs The space between `T` and `Bound` is the typical style used in code and produced by rustdoc's rendering. Fixed first in Reflect's docs and then I fixed all occurrences in docs I could find. --- src/doc/book/lifetimes.md | 4 ++-- src/doc/nomicon/lifetime-elision.md | 4 ++-- src/libcore/marker.rs | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md index 8bf90b4ea4d..4193c93c894 100644 --- a/src/doc/book/lifetimes.md +++ b/src/doc/book/lifetimes.md @@ -353,8 +353,8 @@ fn frob<'a, 'b>(s: &'a str, t: &'b str) -> &str; // Expanded: Output lifetime is fn get_mut(&mut self) -> &mut T; // elided fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded -fn args(&mut self, args: &[T]) -> &mut Command; // elided -fn args<'a, 'b, T:ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command; // expanded +fn args(&mut self, args: &[T]) -> &mut Command; // elided +fn args<'a, 'b, T: ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command; // expanded fn new(buf: &mut [u8]) -> BufWriter; // elided fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a>; // expanded diff --git a/src/doc/nomicon/lifetime-elision.md b/src/doc/nomicon/lifetime-elision.md index 41014f46dd9..bcd93a58d85 100644 --- a/src/doc/nomicon/lifetime-elision.md +++ b/src/doc/nomicon/lifetime-elision.md @@ -55,8 +55,8 @@ fn frob(s: &str, t: &str) -> &str; // ILLEGAL fn get_mut(&mut self) -> &mut T; // elided fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded -fn args(&mut self, args: &[T]) -> &mut Command // elided -fn args<'a, 'b, T:ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded +fn args(&mut self, args: &[T]) -> &mut Command // elided +fn args<'a, 'b, T: ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded fn new(buf: &mut [u8]) -> BufWriter; // elided fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 621dce3efc8..1ed2a219fac 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -333,7 +333,7 @@ macro_rules! impls{ /// use std::marker::PhantomData; /// /// # #[allow(dead_code)] -/// struct Slice<'a, T:'a> { +/// struct Slice<'a, T: 'a> { /// start: *const T, /// end: *const T, /// phantom: PhantomData<&'a T> @@ -428,18 +428,18 @@ mod impls { /// use std::any::Any; /// /// # #[allow(dead_code)] -/// fn foo(x: &T) { +/// fn foo(x: &T) { /// let any: &Any = x; /// if any.is::() { println!("u32"); } /// } /// ``` /// -/// Without the declaration `T:Reflect`, `foo` would not type check +/// Without the declaration `T: Reflect`, `foo` would not type check /// (note: as a matter of style, it would be preferable to write -/// `T:Any`, because `T:Any` implies `T:Reflect` and `T:'static`, but +/// `T: Any`, because `T: Any` implies `T: Reflect` and `T: 'static`, but /// we use `Reflect` here to show how it works). The `Reflect` bound /// thus serves to alert `foo`'s caller to the fact that `foo` may -/// behave differently depending on whether `T=u32` or not. In +/// behave differently depending on whether `T = u32` or not. In /// particular, thanks to the `Reflect` bound, callers know that a /// function declared like `fn bar(...)` will always act in /// precisely the same way no matter what type `T` is supplied, From 2f1703d161acd1608780f0e699f29340b90382d0 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 18 Jan 2016 04:44:35 +0100 Subject: [PATCH 4/7] Allow clang 7.x in configuration I'm using clang 7.2 which works just fine to compile Rust with, but was disallowed. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0255b04caa3..07c9551951e 100755 --- a/configure +++ b/configure @@ -1035,7 +1035,7 @@ then if [ -n "$CFG_OSX_CLANG_VERSION" ] then case $CFG_OSX_CLANG_VERSION in - (7.0*) + (7.*) step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION" ;; (*) From 686be822efd61ec1dc7668bfc18f53dd7b02519c Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Mon, 18 Jan 2016 07:36:39 -0500 Subject: [PATCH 5/7] Make `btree_set::{IntoIter, Iter, Range}` covariant CC #30642 --- src/libcollections/btree/set.rs | 28 +++++++++------------------- src/libcollectionstest/btree/set.rs | 10 ++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index c1381dde762..91fc8d8217f 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -14,7 +14,7 @@ use core::cmp::Ordering::{self, Less, Greater, Equal}; use core::fmt::Debug; use core::fmt; -use core::iter::{Peekable, Map, FromIterator}; +use core::iter::{Peekable, FromIterator}; use core::ops::{BitOr, BitAnd, BitXor, Sub}; use borrow::Borrow; @@ -52,12 +52,12 @@ pub struct Iter<'a, T: 'a> { /// An owning iterator over a BTreeSet's items. #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter { - iter: Map<::btree_map::IntoIter, fn((T, ())) -> T>, + iter: ::btree_map::IntoIter, } /// An iterator over a sub-range of BTreeSet's items. pub struct Range<'a, T: 'a> { - iter: Map<::btree_map::Range<'a, T, ()>, fn((&'a T, &'a ())) -> &'a T>, + iter: ::btree_map::Range<'a, T, ()>, } /// A lazy iterator producing elements in the set difference (in-order). @@ -160,12 +160,7 @@ impl BTreeSet { -> Range<'a, T> where T: Borrow + Borrow { - fn first((a, _): (A, B)) -> A { - a - } - let first: fn((&'a T, &'a ())) -> &'a T = first; // coerce to fn pointer - - Range { iter: self.map.range(min, max).map(first) } + Range { iter: self.map.range(min, max) } } } @@ -548,12 +543,7 @@ impl IntoIterator for BTreeSet { /// assert_eq!(v, [1, 2, 3, 4]); /// ``` fn into_iter(self) -> IntoIter { - fn first((a, _): (A, B)) -> A { - a - } - let first: fn((T, ())) -> T = first; // coerce to fn pointer - - IntoIter { iter: self.map.into_iter().map(first) } + IntoIter { iter: self.map.into_iter() } } } @@ -721,7 +711,7 @@ impl Iterator for IntoIter { type Item = T; fn next(&mut self) -> Option { - self.iter.next() + self.iter.next().map(|(k, _)| k) } fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() @@ -730,7 +720,7 @@ impl Iterator for IntoIter { #[stable(feature = "rust1", since = "1.0.0")] impl DoubleEndedIterator for IntoIter { fn next_back(&mut self) -> Option { - self.iter.next_back() + self.iter.next_back().map(|(k, _)| k) } } #[stable(feature = "rust1", since = "1.0.0")] @@ -746,12 +736,12 @@ impl<'a, T> Iterator for Range<'a, T> { type Item = &'a T; fn next(&mut self) -> Option<&'a T> { - self.iter.next() + self.iter.next().map(|(k, _)| k) } } impl<'a, T> DoubleEndedIterator for Range<'a, T> { fn next_back(&mut self) -> Option<&'a T> { - self.iter.next_back() + self.iter.next_back().map(|(k, _)| k) } } diff --git a/src/libcollectionstest/btree/set.rs b/src/libcollectionstest/btree/set.rs index 8fcfe97f42a..fee18343328 100644 --- a/src/libcollectionstest/btree/set.rs +++ b/src/libcollectionstest/btree/set.rs @@ -254,3 +254,13 @@ fn test_recovery() { assert_eq!(s.iter().next(), None); } + +#[test] +fn test_variance() { + use std::collections::btree_set::{IntoIter, Iter, Range}; + + fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> { v } + fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { v } + fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> { v } + fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> { v } +} From da56967a3eaac0a556e818745dfc5a64d7dcf26a Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 18 Jan 2016 15:57:57 +0100 Subject: [PATCH 6/7] Enumerate acceptable clang versions --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 07c9551951e..287b7b35219 100755 --- a/configure +++ b/configure @@ -1035,7 +1035,7 @@ then if [ -n "$CFG_OSX_CLANG_VERSION" ] then case $CFG_OSX_CLANG_VERSION in - (7.*) + (7.0* | 7.1* | 7.2*) step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION" ;; (*) From d449ec01956d74a3dfecf4cffe34440d7c050480 Mon Sep 17 00:00:00 2001 From: Barosl Lee Date: Tue, 19 Jan 2016 03:07:27 +0900 Subject: [PATCH 7/7] Fix typo --- src/libcollections/str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 766867f284e..9ce1a111cf8 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -302,7 +302,7 @@ impl str { /// # Safety /// /// Callers of this function are responsible that three preconditions are - /// satisifed: + /// satisfied: /// /// * `begin` must come before `end`. /// * `begin` and `end` must be byte positions within the string slice. @@ -345,7 +345,7 @@ impl str { /// # Safety /// /// Callers of this function are responsible that three preconditions are - /// satisifed: + /// satisfied: /// /// * `begin` must come before `end`. /// * `begin` and `end` must be byte positions within the string slice.