Skip to content

Commit 3053288

Browse files
committed
Test fixes and rebase conflicts, round 2
1 parent 554946c commit 3053288

File tree

15 files changed

+80
-91
lines changed

15 files changed

+80
-91
lines changed

src/libcollections/borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
213213
///
214214
/// let hello = cow.to_mut();
215215
///
216-
/// assert_eq!(&[1, 2, 3], hello);
216+
/// assert_eq!(hello, &[1, 2, 3]);
217217
/// ```
218218
#[stable(feature = "rust1", since = "1.0.0")]
219219
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {

src/libcore/convert.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ impl<'a, T: ?Sized, U: ?Sized> AsMut<U> for &'a mut T where T: AsMut<U> {
9595
// }
9696
// }
9797

98-
// From itself is always itself
99-
impl<T> From<T> for T {
100-
fn from(t: T) -> T {
101-
t
102-
}
103-
}
104-
10598
// From implies Into
10699
#[stable(feature = "rust1", since = "1.0.0")]
107100
impl<T, U> Into<U> for T where U: From<T> {

src/libcore/iter.rs

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@
1212
//!
1313
//! # The `Iterator` trait
1414
//!
15-
//! This module defines Rust's core iteration trait. The `Iterator` trait has one
16-
//! unimplemented method, `next`. All other methods are derived through default
17-
//! methods to perform operations such as `zip`, `chain`, `enumerate`, and `fold`.
15+
//! This module defines Rust's core iteration trait. The `Iterator` trait has
16+
//! one unimplemented method, `next`. All other methods are derived through
17+
//! default methods to perform operations such as `zip`, `chain`, `enumerate`,
18+
//! and `fold`.
1819
//!
1920
//! The goal of this module is to unify iteration across all containers in Rust.
20-
//! An iterator can be considered as a state machine which is used to track which
21-
//! element will be yielded next.
21+
//! An iterator can be considered as a state machine which is used to track
22+
//! which element will be yielded next.
2223
//!
23-
//! There are various extensions also defined in this module to assist with various
24-
//! types of iteration, such as the `DoubleEndedIterator` for iterating in reverse,
25-
//! the `FromIterator` trait for creating a container from an iterator, and much
26-
//! more.
24+
//! There are various extensions also defined in this module to assist with
25+
//! various types of iteration, such as the `DoubleEndedIterator` for iterating
26+
//! in reverse, the `FromIterator` trait for creating a container from an
27+
//! iterator, and much more.
2728
//!
2829
//! ## Rust's `for` loop
2930
//!
3031
//! The special syntax used by rust's `for` loop is based around the `Iterator`
31-
//! trait defined in this module. For loops can be viewed as a syntactical expansion
32-
//! into a `loop`, for example, the `for` loop in this example is essentially
33-
//! translated to the `loop` below.
32+
//! trait defined in this module. For loops can be viewed as a syntactical
33+
//! expansion into a `loop`, for example, the `for` loop in this example is
34+
//! essentially translated to the `loop` below.
3435
//!
3536
//! ```
3637
//! let values = vec![1, 2, 3];
@@ -64,8 +65,8 @@ use cmp::Ord;
6465
use default::Default;
6566
use marker;
6667
use mem;
67-
use num::{Int, Zero, One, ToPrimitive};
68-
use ops::{Add, Sub, FnMut, RangeFrom};
68+
use num::{Int, Zero, One};
69+
use ops::{self, Add, Sub, FnMut, RangeFrom};
6970
use option::Option::{self, Some, None};
7071
use marker::Sized;
7172
use usize;
@@ -84,21 +85,22 @@ fn _assert_is_object_safe(_: &Iterator) {}
8485
/// else.
8586
#[lang="iterator"]
8687
#[stable(feature = "rust1", since = "1.0.0")]
87-
#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling `.iter()` or a similar \
88-
method"]
88+
#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \
89+
`.iter()` or a similar method"]
8990
pub trait Iterator {
9091
/// The type of the elements being iterated
9192
#[stable(feature = "rust1", since = "1.0.0")]
9293
type Item;
9394

94-
/// Advance the iterator and return the next value. Return `None` when the end is reached.
95+
/// Advance the iterator and return the next value. Return `None` when the
96+
/// end is reached.
9597
#[stable(feature = "rust1", since = "1.0.0")]
9698
fn next(&mut self) -> Option<Self::Item>;
9799

98100
/// Returns a lower and upper bound on the remaining length of the iterator.
99101
///
100-
/// An upper bound of `None` means either there is no known upper bound, or the upper bound
101-
/// does not fit within a `usize`.
102+
/// An upper bound of `None` means either there is no known upper bound, or
103+
/// the upper bound does not fit within a `usize`.
102104
#[inline]
103105
#[stable(feature = "rust1", since = "1.0.0")]
104106
fn size_hint(&self) -> (usize, Option<usize>) { (0, None) }
@@ -274,7 +276,8 @@ pub trait Iterator {
274276
/// iterator plus the current index of iteration.
275277
///
276278
/// `enumerate` keeps its count as a `usize`. If you want to count by a
277-
/// different sized integer, the `zip` function provides similar functionality.
279+
/// different sized integer, the `zip` function provides similar
280+
/// functionality.
278281
///
279282
/// # Examples
280283
///
@@ -612,7 +615,8 @@ pub trait Iterator {
612615
true
613616
}
614617

615-
/// Tests whether any element of an iterator satisfies the specified predicate.
618+
/// Tests whether any element of an iterator satisfies the specified
619+
/// predicate.
616620
///
617621
/// Does not consume the iterator past the first found element.
618622
///
@@ -776,7 +780,8 @@ pub trait Iterator {
776780
/// element in the iterator and all elements are equal.
777781
///
778782
/// On an iterator of length `n`, `min_max` does `1.5 * n` comparisons,
779-
/// and so is faster than calling `min` and `max` separately which does `2 * n` comparisons.
783+
/// and so is faster than calling `min` and `max` separately which does `2 *
784+
/// n` comparisons.
780785
///
781786
/// # Examples
782787
///
@@ -810,10 +815,11 @@ pub trait Iterator {
810815
};
811816

812817
loop {
813-
// `first` and `second` are the two next elements we want to look at.
814-
// We first compare `first` and `second` (#1). The smaller one is then compared to
815-
// current minimum (#2). The larger one is compared to current maximum (#3). This
816-
// way we do 3 comparisons for 2 elements.
818+
// `first` and `second` are the two next elements we want to look
819+
// at. We first compare `first` and `second` (#1). The smaller one
820+
// is then compared to current minimum (#2). The larger one is
821+
// compared to current maximum (#3). This way we do 3 comparisons
822+
// for 2 elements.
817823
let first = match self.next() {
818824
None => break,
819825
Some(x) => x
@@ -1038,7 +1044,8 @@ pub trait FromIterator<A> {
10381044
/// assert_eq!(colors_set.len(), 3);
10391045
/// ```
10401046
///
1041-
/// `FromIterator` is more commonly used implicitly via the `Iterator::collect` method:
1047+
/// `FromIterator` is more commonly used implicitly via the
1048+
/// `Iterator::collect` method:
10421049
///
10431050
/// ```
10441051
/// use std::collections::HashSet;
@@ -1105,12 +1112,13 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I {
11051112

11061113
/// An object implementing random access indexing by `usize`
11071114
///
1108-
/// A `RandomAccessIterator` should be either infinite or a `DoubleEndedIterator`.
1109-
/// Calling `next()` or `next_back()` on a `RandomAccessIterator`
1110-
/// reduces the indexable range accordingly. That is, `it.idx(1)` will become `it.idx(0)`
1111-
/// after `it.next()` is called.
1115+
/// A `RandomAccessIterator` should be either infinite or a
1116+
/// `DoubleEndedIterator`. Calling `next()` or `next_back()` on a
1117+
/// `RandomAccessIterator` reduces the indexable range accordingly. That is,
1118+
/// `it.idx(1)` will become `it.idx(0)` after `it.next()` is called.
11121119
#[unstable(feature = "core",
1113-
reason = "not widely used, may be better decomposed into Index and ExactSizeIterator")]
1120+
reason = "not widely used, may be better decomposed into Index \
1121+
and ExactSizeIterator")]
11141122
pub trait RandomAccessIterator: Iterator {
11151123
/// Return the number of indexable elements. At most `std::usize::MAX`
11161124
/// elements are indexable, even if the iterator represents a longer range.
@@ -1155,13 +1163,15 @@ impl<I: ExactSizeIterator, F> ExactSizeIterator for Inspect<I, F> where
11551163
F: FnMut(&I::Item),
11561164
{}
11571165
#[stable(feature = "rust1", since = "1.0.0")]
1158-
impl<I> ExactSizeIterator for Rev<I> where I: ExactSizeIterator + DoubleEndedIterator {}
1166+
impl<I> ExactSizeIterator for Rev<I>
1167+
where I: ExactSizeIterator + DoubleEndedIterator {}
11591168
#[stable(feature = "rust1", since = "1.0.0")]
11601169
impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F> where
11611170
F: FnMut(I::Item) -> B,
11621171
{}
11631172
#[stable(feature = "rust1", since = "1.0.0")]
1164-
impl<A, B> ExactSizeIterator for Zip<A, B> where A: ExactSizeIterator, B: ExactSizeIterator {}
1173+
impl<A, B> ExactSizeIterator for Zip<A, B>
1174+
where A: ExactSizeIterator, B: ExactSizeIterator {}
11651175

11661176
/// An double-ended iterator with the direction inverted
11671177
#[derive(Clone)]
@@ -1188,7 +1198,9 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator {
11881198
}
11891199

11901200
#[unstable(feature = "core", reason = "trait is experimental")]
1191-
impl<I> RandomAccessIterator for Rev<I> where I: DoubleEndedIterator + RandomAccessIterator {
1201+
impl<I> RandomAccessIterator for Rev<I>
1202+
where I: DoubleEndedIterator + RandomAccessIterator
1203+
{
11921204
#[inline]
11931205
fn indexable(&self) -> usize { self.iter.indexable() }
11941206
#[inline]
@@ -1291,7 +1303,8 @@ impl_multiplicative! { usize, 1 }
12911303
impl_multiplicative! { f32, 1.0 }
12921304
impl_multiplicative! { f64, 1.0 }
12931305

1294-
/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for more detail.
1306+
/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for
1307+
/// more detail.
12951308
#[derive(Clone, PartialEq, Debug)]
12961309
#[unstable(feature = "core",
12971310
reason = "unclear whether such a fine-grained result is widely useful")]
@@ -1302,15 +1315,17 @@ pub enum MinMaxResult<T> {
13021315
/// Iterator with one element, so the minimum and maximum are the same
13031316
OneElement(T),
13041317

1305-
/// More than one element in the iterator, the first element is not larger than the second
1318+
/// More than one element in the iterator, the first element is not larger
1319+
/// than the second
13061320
MinMax(T, T)
13071321
}
13081322

13091323
impl<T: Clone> MinMaxResult<T> {
1310-
/// `into_option` creates an `Option` of type `(T,T)`. The returned `Option` has variant
1311-
/// `None` if and only if the `MinMaxResult` has variant `NoElements`. Otherwise variant
1312-
/// `Some(x,y)` is returned where `x <= y`. If `MinMaxResult` has variant `OneElement(x)`,
1313-
/// performing this operation will make one clone of `x`.
1324+
/// `into_option` creates an `Option` of type `(T,T)`. The returned `Option`
1325+
/// has variant `None` if and only if the `MinMaxResult` has variant
1326+
/// `NoElements`. Otherwise variant `Some(x,y)` is returned where `x <= y`.
1327+
/// If `MinMaxResult` has variant `OneElement(x)`, performing this operation
1328+
/// will make one clone of `x`.
13141329
///
13151330
/// # Examples
13161331
///
@@ -2522,7 +2537,7 @@ impl<A: Step> RangeFrom<A> {
25222537
}
25232538

25242539
#[allow(deprecated)]
2525-
impl<A: Step> ::ops::Range<A> {
2540+
impl<A: Step> ops::Range<A> {
25262541
/// Creates an iterator with the same range, but stepping by the
25272542
/// given amount at each iteration.
25282543
///
@@ -2588,7 +2603,9 @@ pub struct RangeInclusive<A> {
25882603
#[inline]
25892604
#[unstable(feature = "core",
25902605
reason = "likely to be replaced by range notation and adapters")]
2591-
pub fn range_inclusive<A: Int>(start: A, stop: A) -> RangeInclusive<A> {
2606+
pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A>
2607+
where A: Step + One + Clone
2608+
{
25922609
RangeInclusive {
25932610
range: start..stop,
25942611
done: false,
@@ -2597,7 +2614,7 @@ pub fn range_inclusive<A: Int>(start: A, stop: A) -> RangeInclusive<A> {
25972614

25982615
#[unstable(feature = "core",
25992616
reason = "likely to be replaced by range notation and adapters")]
2600-
impl<A: Int + ToPrimitive> Iterator for RangeInclusive<A> {
2617+
impl<A: Step + One + Clone> Iterator for RangeInclusive<A> {
26012618
type Item = A;
26022619

26032620
#[inline]
@@ -2633,12 +2650,15 @@ impl<A: Int + ToPrimitive> Iterator for RangeInclusive<A> {
26332650

26342651
#[unstable(feature = "core",
26352652
reason = "likely to be replaced by range notation and adapters")]
2636-
impl<A: Int + ToPrimitive> DoubleEndedIterator for RangeInclusive<A> {
2653+
impl<A> DoubleEndedIterator for RangeInclusive<A>
2654+
where A: Step + One + Clone,
2655+
for<'a> &'a A: Sub<Output=A>
2656+
{
26372657
#[inline]
26382658
fn next_back(&mut self) -> Option<A> {
26392659
if self.range.end > self.range.start {
26402660
let result = self.range.end.clone();
2641-
self.range.end = self.range.end - A::one();
2661+
self.range.end = &self.range.end - &A::one();
26422662
Some(result)
26432663
} else if !self.done && self.range.start == self.range.end {
26442664
self.done = true;
@@ -2651,7 +2671,7 @@ impl<A: Int + ToPrimitive> DoubleEndedIterator for RangeInclusive<A> {
26512671

26522672
#[stable(feature = "rust1", since = "1.0.0")]
26532673
#[allow(deprecated)]
2654-
impl<A: Step + Zero + Clone> Iterator for StepBy<A, ::ops::Range<A>> {
2674+
impl<A: Step + Zero + Clone> Iterator for StepBy<A, ops::Range<A>> {
26552675
type Item = A;
26562676

26572677
#[inline]
@@ -2754,13 +2774,13 @@ impl<A: Int> Iterator for RangeStepInclusive<A> {
27542774
macro_rules! range_exact_iter_impl {
27552775
($($t:ty)*) => ($(
27562776
#[stable(feature = "rust1", since = "1.0.0")]
2757-
impl ExactSizeIterator for ::ops::Range<$t> { }
2777+
impl ExactSizeIterator for ops::Range<$t> { }
27582778
)*)
27592779
}
27602780

27612781
#[stable(feature = "rust1", since = "1.0.0")]
27622782
#[allow(deprecated)]
2763-
impl<A: Step + One + Clone> Iterator for ::ops::Range<A> {
2783+
impl<A: Step + One + Clone> Iterator for ops::Range<A> {
27642784
type Item = A;
27652785

27662786
#[inline]
@@ -2799,7 +2819,7 @@ range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
27992819

28002820
#[stable(feature = "rust1", since = "1.0.0")]
28012821
#[allow(deprecated)]
2802-
impl<A: Step + One + Clone> DoubleEndedIterator for ::ops::Range<A> where
2822+
impl<A: Step + One + Clone> DoubleEndedIterator for ops::Range<A> where
28032823
for<'a> &'a A: Sub<&'a A, Output = A>
28042824
{
28052825
#[inline]
@@ -2815,7 +2835,7 @@ impl<A: Step + One + Clone> DoubleEndedIterator for ::ops::Range<A> where
28152835

28162836
#[stable(feature = "rust1", since = "1.0.0")]
28172837
#[allow(deprecated)]
2818-
impl<A: Step + One> Iterator for ::ops::RangeFrom<A> {
2838+
impl<A: Step + One> Iterator for ops::RangeFrom<A> {
28192839
type Item = A;
28202840

28212841
#[inline]

src/libcore/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use str::{FromStr, StrExt};
4646
/// intended to have wrapping semantics.
4747
#[stable(feature = "rust1", since = "1.0.0")]
4848
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)]
49-
pub struct Wrapping<T>(pub T);
49+
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
5050

5151
#[unstable(feature = "core", reason = "may be removed or relocated")]
5252
pub mod wrapping;

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#![feature(unsafe_destructor)]
3838
#![feature(staged_api)]
3939
#![feature(std_misc)]
40-
#![feature(io)]
4140
#![feature(path_ext)]
4241
#![feature(str_words)]
4342
#![feature(str_char)]

src/librustc_driver/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#![feature(box_syntax)]
2929
#![feature(collections)]
30-
#![feature(core)]
3130
#![feature(libc)]
3231
#![feature(quote)]
3332
#![feature(rustc_diagnostic_macros)]

src/librustc_llvm/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#![feature(libc)]
3131
#![feature(link_args)]
3232
#![feature(staged_api)]
33-
#![cfg_attr(unix, feature(convert))]
3433

3534
extern crate libc;
3635
#[macro_use] #[no_link] extern crate rustc_bitflags;

src/librustdoc/flock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ mod imp {
195195

196196
impl Lock {
197197
pub fn new(p: &Path) -> Lock {
198-
let p: &OsStr = p.as_ref();
199-
let mut p_16: Vec<_> = p.encode_wide().collect();
198+
let os: &OsStr = p.as_ref();
199+
let mut p_16: Vec<_> = os.encode_wide().collect();
200200
p_16.push(0);
201201
let handle = unsafe {
202202
libc::CreateFileW(p_16.as_ptr(),

src/librustdoc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![feature(box_patterns)]
2424
#![feature(box_syntax)]
2525
#![feature(collections)]
26-
#![feature(core)]
2726
#![feature(exit_status)]
2827
#![feature(set_stdio)]
2928
#![feature(libc)]

src/libstd/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![unstable(feature = "std_misc")]
1212

13-
use convert::Into;
13+
use convert::{Into, From};
1414
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
1515
use error::Error;
1616
use fmt;

0 commit comments

Comments
 (0)