Skip to content

Commit 4e1e5e4

Browse files
committed
---
yaml --- r: 233717 b: refs/heads/beta c: 35eb3e8 h: refs/heads/master i: 233715: f6b1a4b v: v3
1 parent 8f9565d commit 4e1e5e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+881
-1033
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 14b7591ee578042da43f6a9968034f4998cf291c
26+
refs/heads/beta: 35eb3e8b79c60ec18e724c7a68625d7cdf9300c0
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/configure

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ valopt python "" "set path to python"
602602
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
603603
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
604604
valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path (deprecated)"
605-
valopt i686-linux-android-ndk "" "i686-linux-android NDK standalone path"
606605
valopt arm-linux-androideabi-ndk "" "arm-linux-androideabi NDK standalone path"
607606
valopt aarch64-linux-android-ndk "" "aarch64-linux-android NDK standalone path"
608607
valopt release-channel "dev" "the name of the release channel to build"
@@ -1694,7 +1693,6 @@ putvar CFG_LIBDIR_RELATIVE
16941693
putvar CFG_DISABLE_MANAGE_SUBMODULES
16951694
putvar CFG_AARCH64_LINUX_ANDROID_NDK
16961695
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
1697-
putvar CFG_I686_LINUX_ANDROID_NDK
16981696
putvar CFG_MANDIR
16991697

17001698
# Avoid spurious warnings from clang by feeding it original source on

branches/beta/mk/cfg/i686-linux-android.mk

Lines changed: 0 additions & 25 deletions
This file was deleted.

branches/beta/src/compiletest/compiletest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(str_char)]
2020
#![feature(test)]
2121
#![feature(vec_push_all)]
22-
#![feature(path_components_peek)]
2322

2423
#![deny(warnings)]
2524

branches/beta/src/compiletest/runtest.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::fs::{self, File};
2525
use std::io::BufReader;
2626
use std::io::prelude::*;
2727
use std::net::TcpStream;
28-
use std::path::{Path, PathBuf, Component};
28+
use std::path::{Path, PathBuf};
2929
use std::process::{Command, Output, ExitStatus};
3030

3131
pub fn run(config: Config, testfile: &Path) {
@@ -952,9 +952,6 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
952952
// filename:line1:col1: line2:col2: *warning:* msg
953953
// where line1:col1: is the starting point, line2:col2:
954954
// is the ending point, and * represents ANSI color codes.
955-
//
956-
// This pattern is ambiguous on windows, because filename may contain
957-
// a colon, so any path prefix must be detected and removed first.
958955
for line in proc_res.stderr.lines() {
959956
let mut was_expected = false;
960957
let mut prev = 0;
@@ -1009,16 +1006,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
10091006
}
10101007
}
10111008

1012-
fn is_compiler_error_or_warning(mut line: &str) -> bool {
1013-
// Remove initial prefix which may contain a colon
1014-
let mut components = Path::new(line).components();
1015-
if let Some(Component::Prefix(_)) = components.peek() {
1016-
components.next();
1017-
}
1018-
1019-
// Safe as path was originally constructed from a &str ^
1020-
line = components.as_path().to_str().unwrap();
1021-
1009+
fn is_compiler_error_or_warning(line: &str) -> bool {
10221010
let mut i = 0;
10231011
return
10241012
scan_until_char(line, ':', &mut i) &&

branches/beta/src/doc/reference.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ fn draw_twice<T: Shape>(surface: Surface, sh: T) {
14521452
}
14531453
```
14541454

1455-
Traits also define a [trait object](#trait-objects) with the same
1455+
Traits also define an [trait object](#trait-objects) with the same
14561456
name as the trait. Values of this type are created by coercing from a
14571457
pointer of some specific type to a pointer of trait type. For example,
14581458
`&T` could be coerced to `&Shape` if `T: Shape` holds (and similarly
@@ -1881,15 +1881,11 @@ type int8_t = i8;
18811881
- `no_start` - disable linking to the `native` crate, which specifies the
18821882
"start" language item.
18831883
- `no_std` - disable linking to the `std` crate.
1884-
- `plugin` - load a list of named crates as compiler plugins, e.g.
1884+
- `plugin` load a list of named crates as compiler plugins, e.g.
18851885
`#![plugin(foo, bar)]`. Optional arguments for each plugin,
18861886
i.e. `#![plugin(foo(... args ...))]`, are provided to the plugin's
18871887
registrar function. The `plugin` feature gate is required to use
18881888
this attribute.
1889-
- `recursion_limit` - Sets the maximum depth for potentially
1890-
infinitely-recursive compile-time operations like
1891-
auto-dereference or macro expansion. The default is
1892-
`#![recursion_limit="64"]`.
18931889

18941890
### Module-only attributes
18951891

branches/beta/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ Because these kinds of situations are relatively rare, use panics sparingly.
208208

209209
In certain circumstances, even though a function may fail, we may want to treat
210210
it as a panic instead. For example, `io::stdin().read_line(&mut buffer)` returns
211-
a `Result<usize>`, which can indicate an error if one occurs when reading the line.
212-
This allows us to handle and possibly recover from errors.
211+
a `Result<usize>`, when there is an error reading the line. This allows us to
212+
handle and possibly recover from error.
213213

214214
If we don't want to handle this error, and would rather just abort the program,
215215
we can use the `unwrap()` method:

branches/beta/src/doc/trpl/testing.md

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -219,66 +219,6 @@ fn it_works() {
219219
This is a very common use of `assert_eq!`: call some function with
220220
some known arguments and compare it to the expected output.
221221

222-
# The `ignore` attribute
223-
224-
Sometimes a few specific tests can be very time-consuming to execute. These
225-
can be disabled by default by using the `ignore` attribute:
226-
227-
```rust
228-
#[test]
229-
fn it_works() {
230-
assert_eq!(4, add_two(2));
231-
}
232-
233-
#[test]
234-
#[ignore]
235-
fn expensive_test() {
236-
// code that takes an hour to run
237-
}
238-
```
239-
240-
Now we run our tests and see that `it_works` is run, but `expensive_test` is
241-
not:
242-
243-
```bash
244-
$ cargo test
245-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
246-
Running target/adder-91b3e234d4ed382a
247-
248-
running 2 tests
249-
test expensive_test ... ignored
250-
test it_works ... ok
251-
252-
test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured
253-
254-
Doc-tests adder
255-
256-
running 0 tests
257-
258-
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
259-
```
260-
261-
The expensive tests can be run explicitly using `cargo test -- --ignored`:
262-
263-
```bash
264-
$ cargo test -- --ignored
265-
Running target/adder-91b3e234d4ed382a
266-
267-
running 1 test
268-
test expensive_test ... ok
269-
270-
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
271-
272-
Doc-tests adder
273-
274-
running 0 tests
275-
276-
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
277-
```
278-
279-
The `--ignored` argument is an argument to the test binary, and not to cargo,
280-
which is why the command is `cargo test -- --ignored`.
281-
282222
# The `tests` module
283223

284224
There is one way in which our existing example is not idiomatic: it's

branches/beta/src/libcollections/string.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,11 @@ impl<'a> Extend<&'a char> for String {
813813
#[stable(feature = "rust1", since = "1.0.0")]
814814
impl<'a> Extend<&'a str> for String {
815815
fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) {
816-
for s in iterable {
816+
let iterator = iterable.into_iter();
817+
// A guess that at least one byte per iterator element will be needed.
818+
let (lower_bound, _) = iterator.size_hint();
819+
self.reserve(lower_bound);
820+
for s in iterator {
817821
self.push_str(s)
818822
}
819823
}

branches/beta/src/libcore/iter.rs

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub trait Iterator {
184184
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> where
185185
Self: Sized, U: IntoIterator<Item=Self::Item>,
186186
{
187-
Chain{a: self, b: other.into_iter(), flag: false}
187+
Chain{a: self, b: other.into_iter(), state: ChainState::Both}
188188
}
189189

190190
/// Creates an iterator that iterates over both this and the specified
@@ -1277,7 +1277,30 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator {
12771277
pub struct Chain<A, B> {
12781278
a: A,
12791279
b: B,
1280-
flag: bool,
1280+
state: ChainState,
1281+
}
1282+
1283+
// The iterator protocol specifies that iteration ends with the return value
1284+
// `None` from `.next()` (or `.next_back()`) and it is unspecified what
1285+
// further calls return. The chain adaptor must account for this since it uses
1286+
// two subiterators.
1287+
//
1288+
// It uses three states:
1289+
//
1290+
// - Both: `a` and `b` are remaining
1291+
// - Front: `a` remaining
1292+
// - Back: `b` remaining
1293+
//
1294+
// The fourth state (neither iterator is remaining) only occurs after Chain has
1295+
// returned None once, so we don't need to store this state.
1296+
#[derive(Clone)]
1297+
enum ChainState {
1298+
// both front and back iterator are remaining
1299+
Both,
1300+
// only front is remaining
1301+
Front,
1302+
// only back is remaining
1303+
Back,
12811304
}
12821305

12831306
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1289,42 +1312,58 @@ impl<A, B> Iterator for Chain<A, B> where
12891312

12901313
#[inline]
12911314
fn next(&mut self) -> Option<A::Item> {
1292-
if self.flag {
1293-
self.b.next()
1294-
} else {
1295-
match self.a.next() {
1296-
Some(x) => return Some(x),
1297-
_ => ()
1298-
}
1299-
self.flag = true;
1300-
self.b.next()
1315+
match self.state {
1316+
ChainState::Both => match self.a.next() {
1317+
elt @ Some(..) => return elt,
1318+
None => {
1319+
self.state = ChainState::Back;
1320+
self.b.next()
1321+
}
1322+
},
1323+
ChainState::Front => self.a.next(),
1324+
ChainState::Back => self.b.next(),
13011325
}
13021326
}
13031327

13041328
#[inline]
13051329
fn count(self) -> usize {
1306-
(if !self.flag { self.a.count() } else { 0 }) + self.b.count()
1330+
match self.state {
1331+
ChainState::Both => self.a.count() + self.b.count(),
1332+
ChainState::Front => self.a.count(),
1333+
ChainState::Back => self.b.count(),
1334+
}
13071335
}
13081336

13091337
#[inline]
13101338
fn nth(&mut self, mut n: usize) -> Option<A::Item> {
1311-
if !self.flag {
1312-
for x in self.a.by_ref() {
1313-
if n == 0 {
1314-
return Some(x)
1339+
match self.state {
1340+
ChainState::Both | ChainState::Front => {
1341+
for x in self.a.by_ref() {
1342+
if n == 0 {
1343+
return Some(x)
1344+
}
1345+
n -= 1;
1346+
}
1347+
if let ChainState::Both = self.state {
1348+
self.state = ChainState::Back;
13151349
}
1316-
n -= 1;
13171350
}
1318-
self.flag = true;
1351+
ChainState::Back => {}
1352+
}
1353+
if let ChainState::Back = self.state {
1354+
self.b.nth(n)
1355+
} else {
1356+
None
13191357
}
1320-
self.b.nth(n)
13211358
}
13221359

13231360
#[inline]
13241361
fn last(self) -> Option<A::Item> {
1325-
let a_last = if self.flag { None } else { self.a.last() };
1326-
let b_last = self.b.last();
1327-
b_last.or(a_last)
1362+
match self.state {
1363+
ChainState::Both => self.b.last().or(self.a.last()),
1364+
ChainState::Front => self.a.last(),
1365+
ChainState::Back => self.b.last()
1366+
}
13281367
}
13291368

13301369
#[inline]
@@ -1350,9 +1389,16 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
13501389
{
13511390
#[inline]
13521391
fn next_back(&mut self) -> Option<A::Item> {
1353-
match self.b.next_back() {
1354-
Some(x) => Some(x),
1355-
None => self.a.next_back()
1392+
match self.state {
1393+
ChainState::Both => match self.b.next_back() {
1394+
elt @ Some(..) => return elt,
1395+
None => {
1396+
self.state = ChainState::Front;
1397+
self.a.next_back()
1398+
}
1399+
},
1400+
ChainState::Front => self.a.next_back(),
1401+
ChainState::Back => self.b.next_back(),
13561402
}
13571403
}
13581404
}

branches/beta/src/libcoretest/iter.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,26 @@ fn test_double_ended_chain() {
729729
assert_eq!(it.next_back().unwrap(), &5);
730730
assert_eq!(it.next_back().unwrap(), &7);
731731
assert_eq!(it.next_back(), None);
732+
733+
734+
// test that .chain() is well behaved with an unfused iterator
735+
struct CrazyIterator(bool);
736+
impl CrazyIterator { fn new() -> CrazyIterator { CrazyIterator(false) } }
737+
impl Iterator for CrazyIterator {
738+
type Item = i32;
739+
fn next(&mut self) -> Option<i32> {
740+
if self.0 { Some(99) } else { self.0 = true; None }
741+
}
742+
}
743+
744+
impl DoubleEndedIterator for CrazyIterator {
745+
fn next_back(&mut self) -> Option<i32> {
746+
self.next()
747+
}
748+
}
749+
750+
assert_eq!(CrazyIterator::new().chain(0..10).rev().last(), Some(0));
751+
assert!((0..10).chain(CrazyIterator::new()).rev().any(|i| i == 0));
732752
}
733753

734754
#[test]

0 commit comments

Comments
 (0)