Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #31006

Merged
merged 12 commits into from
Jan 19, 2016
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ then
if [ -n "$CFG_OSX_CLANG_VERSION" ]
then
case $CFG_OSX_CLANG_VERSION in
(7.0*)
(7.0* | 7.1* | 7.2*)
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
;;
(*)
Expand Down
4 changes: 2 additions & 2 deletions src/doc/book/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T:ToCStr>(&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<T: ToCStr>(&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
Expand Down
8 changes: 5 additions & 3 deletions src/doc/book/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions src/doc/nomicon/lifetime-elision.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T:ToCStr>(&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<T: ToCStr>(&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
Expand Down
28 changes: 9 additions & 19 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<T> {
iter: Map<::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>,
iter: ::btree_map::IntoIter<T, ()>,
}

/// 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).
Expand Down Expand Up @@ -160,12 +160,7 @@ impl<T: Ord> BTreeSet<T> {
-> Range<'a, T>
where T: Borrow<Min> + Borrow<Max>
{
fn first<A, B>((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) }
}
}

Expand Down Expand Up @@ -548,12 +543,7 @@ impl<T> IntoIterator for BTreeSet<T> {
/// assert_eq!(v, [1, 2, 3, 4]);
/// ```
fn into_iter(self) -> IntoIter<T> {
fn first<A, B>((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() }
}
}

Expand Down Expand Up @@ -721,7 +711,7 @@ impl<T> Iterator for IntoIter<T> {
type Item = T;

fn next(&mut self) -> Option<T> {
self.iter.next()
self.iter.next().map(|(k, _)| k)
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
Expand All @@ -730,7 +720,7 @@ impl<T> Iterator for IntoIter<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> DoubleEndedIterator for IntoIter<T> {
fn next_back(&mut self) -> Option<T> {
self.iter.next_back()
self.iter.next_back().map(|(k, _)| k)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/libcollectionstest/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
10 changes: 5 additions & 5 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -428,18 +428,18 @@ mod impls {
/// use std::any::Any;
///
/// # #[allow(dead_code)]
/// fn foo<T:Reflect+'static>(x: &T) {
/// fn foo<T: Reflect + 'static>(x: &T) {
/// let any: &Any = x;
/// if any.is::<u32>() { 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<T>(...)` will always act in
/// precisely the same way no matter what type `T` is supplied,
Expand Down