Skip to content

Commit 95da4d4

Browse files
committed
---
yaml --- r: 177512 b: refs/heads/master c: 0cdde6e h: refs/heads/master v: v3
1 parent b2603ed commit 95da4d4

File tree

132 files changed

+1118
-1640
lines changed

Some content is hidden

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

132 files changed

+1118
-1640
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0ba812fbf00e3026b29282e1a72d58ea7959833e
2+
refs/heads/master: 0cdde6e5e015ee6f6d9381ab624a312af7c9b069
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a45e117733b866302fa99390553d1c548508dcca
55
refs/heads/try: fde4472848b662a4d1236388c4cf15e2450237e6

trunk/src/compiletest/common.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ pub enum Mode {
2525
}
2626

2727
impl FromStr for Mode {
28-
fn from_str(s: &str) -> Option<Mode> {
28+
type Err = ();
29+
fn from_str(s: &str) -> Result<Mode, ()> {
2930
match s {
30-
"compile-fail" => Some(CompileFail),
31-
"run-fail" => Some(RunFail),
32-
"run-pass" => Some(RunPass),
33-
"run-pass-valgrind" => Some(RunPassValgrind),
34-
"pretty" => Some(Pretty),
35-
"debuginfo-lldb" => Some(DebugInfoLldb),
36-
"debuginfo-gdb" => Some(DebugInfoGdb),
37-
"codegen" => Some(Codegen),
38-
_ => None,
31+
"compile-fail" => Ok(CompileFail),
32+
"run-fail" => Ok(RunFail),
33+
"run-pass" => Ok(RunPass),
34+
"run-pass-valgrind" => Ok(RunPassValgrind),
35+
"pretty" => Ok(Pretty),
36+
"debuginfo-lldb" => Ok(DebugInfoLldb),
37+
"debuginfo-gdb" => Ok(DebugInfoGdb),
38+
"codegen" => Ok(Codegen),
39+
_ => Err(()),
3940
}
4041
}
4142
}

trunk/src/compiletest/compiletest.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ extern crate log;
3535
use std::os;
3636
use std::old_io;
3737
use std::old_io::fs;
38-
use std::str::FromStr;
3938
use std::thunk::Thunk;
4039
use getopts::{optopt, optflag, reqopt};
4140
use common::Config;
@@ -140,9 +139,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
140139
build_base: opt_path(matches, "build-base"),
141140
aux_base: opt_path(matches, "aux-base"),
142141
stage_id: matches.opt_str("stage-id").unwrap(),
143-
mode: FromStr::from_str(matches.opt_str("mode")
144-
.unwrap()
145-
.as_slice()).expect("invalid mode"),
142+
mode: matches.opt_str("mode").unwrap().parse().ok().expect("invalid mode"),
146143
run_ignored: matches.opt_present("ignored"),
147144
filter: filter,
148145
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),

trunk/src/compiletest/header.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
352352
panic!("{}", error_string);
353353
}
354354

355-
let major: int = components[0].parse().expect(error_string);
356-
let minor: int = components[1].parse().expect(error_string);
355+
let major: int = components[0].parse().ok().expect(error_string);
356+
let minor: int = components[1].parse().ok().expect(error_string);
357357

358358
return major * 1000 + minor;
359359
}
@@ -363,6 +363,6 @@ pub fn lldb_version_to_int(version_string: &str) -> int {
363363
"Encountered LLDB version string with unexpected format: {}",
364364
version_string);
365365
let error_string = error_string.as_slice();
366-
let major: int = version_string.parse().expect(error_string);
366+
let major: int = version_string.parse().ok().expect(error_string);
367367
return major;
368368
}

trunk/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ Some examples of call expressions:
29942994
# fn add(x: i32, y: i32) -> i32 { 0 }
29952995
29962996
let x: i32 = add(1i32, 2i32);
2997-
let pi: Option<f32> = "3.14".parse();
2997+
let pi: Option<f32> = "3.14".parse().ok();
29982998
```
29992999

30003000
### Lambda expressions

trunk/src/doc/trpl/guessing-game.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ a function for that:
400400
let input = old_io::stdin().read_line()
401401
.ok()
402402
.expect("Failed to read line");
403-
let input_num: Option<u32> = input.parse();
403+
let input_num: Option<u32> = input.parse().ok();
404404
```
405405
406406
The `parse` function takes in a `&str` value and converts it into something.
@@ -422,11 +422,13 @@ In this case, we say `x` is a `u32` explicitly, so Rust is able to properly
422422
tell `random()` what to generate. In a similar fashion, both of these work:
423423
424424
```{rust,ignore}
425-
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426-
let input_num: Option<u32> = "5".parse(); // input_num: Option<u32>
425+
let input_num = "5".parse::<u32>().ok(); // input_num: Option<u32>
426+
let input_num: Option<u32> = "5".parse().ok(); // input_num: Option<u32>
427427
```
428428
429-
Anyway, with us now converting our input to a number, our code looks like this:
429+
Here we're converting the `Result` returned by `parse` to an `Option` by using
430+
the `ok` method as well. Anyway, with us now converting our input to a number,
431+
our code looks like this:
430432
431433
```{rust,ignore}
432434
use std::old_io;
@@ -445,7 +447,7 @@ fn main() {
445447
let input = old_io::stdin().read_line()
446448
.ok()
447449
.expect("Failed to read line");
448-
let input_num: Option<u32> = input.parse();
450+
let input_num: Option<u32> = input.parse().ok();
449451
450452
println!("You guessed: {}", input_num);
451453
@@ -495,7 +497,7 @@ fn main() {
495497
let input = old_io::stdin().read_line()
496498
.ok()
497499
.expect("Failed to read line");
498-
let input_num: Option<u32> = input.parse();
500+
let input_num: Option<u32> = input.parse().ok();
499501

500502
let num = match input_num {
501503
Some(num) => num,
@@ -562,7 +564,7 @@ fn main() {
562564
let input = old_io::stdin().read_line()
563565
.ok()
564566
.expect("Failed to read line");
565-
let input_num: Option<u32> = input.trim().parse();
567+
let input_num: Option<u32> = input.trim().parse().ok();
566568

567569
let num = match input_num {
568570
Some(num) => num,
@@ -638,7 +640,7 @@ fn main() {
638640
let input = old_io::stdin().read_line()
639641
.ok()
640642
.expect("Failed to read line");
641-
let input_num: Option<u32> = input.trim().parse();
643+
let input_num: Option<u32> = input.trim().parse().ok();
642644
643645
let num = match input_num {
644646
Some(num) => num,
@@ -714,7 +716,7 @@ fn main() {
714716
let input = old_io::stdin().read_line()
715717
.ok()
716718
.expect("Failed to read line");
717-
let input_num: Option<u32> = input.trim().parse();
719+
let input_num: Option<u32> = input.trim().parse().ok();
718720

719721
let num = match input_num {
720722
Some(num) => num,
@@ -770,7 +772,7 @@ fn main() {
770772
let input = old_io::stdin().read_line()
771773
.ok()
772774
.expect("Failed to read line");
773-
let input_num: Option<u32> = input.trim().parse();
775+
let input_num: Option<u32> = input.trim().parse().ok();
774776

775777
let num = match input_num {
776778
Some(num) => num,
@@ -847,7 +849,7 @@ fn main() {
847849
let input = old_io::stdin().read_line()
848850
.ok()
849851
.expect("Failed to read line");
850-
let input_num: Option<u32> = input.trim().parse();
852+
let input_num: Option<u32> = input.trim().parse().ok();
851853

852854
let num = match input_num {
853855
Some(num) => num,

trunk/src/doc/trpl/unsafe.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,6 @@ extern fn panic_fmt(args: &core::fmt::Arguments,
576576
#[lang = "eh_personality"] extern fn eh_personality() {}
577577
# #[start] fn start(argc: isize, argv: *const *const u8) -> isize { 0 }
578578
# fn main() {}
579-
# mod std { // for-loops
580-
# pub use core::iter;
581-
# pub use core::option;
582-
# }
583579
```
584580

585581
Note that there is one extra lang item here which differs from the examples

trunk/src/libcollections/binary_heap.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
use core::prelude::*;
154154

155155
use core::default::Default;
156-
use core::iter::{FromIterator, IntoIterator};
156+
use core::iter::FromIterator;
157157
use core::mem::{zeroed, replace, swap};
158158
use core::ptr;
159159

@@ -655,22 +655,6 @@ impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
655655
}
656656
}
657657

658-
impl<T: Ord> IntoIterator for BinaryHeap<T> {
659-
type Iter = IntoIter<T>;
660-
661-
fn into_iter(self) -> IntoIter<T> {
662-
self.into_iter()
663-
}
664-
}
665-
666-
impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
667-
type Iter = Iter<'a, T>;
668-
669-
fn into_iter(self) -> Iter<'a, T> {
670-
self.iter()
671-
}
672-
}
673-
674658
#[stable(feature = "rust1", since = "1.0.0")]
675659
impl<T: Ord> Extend<T> for BinaryHeap<T> {
676660
fn extend<Iter: Iterator<Item=T>>(&mut self, mut iter: Iter) {

trunk/src/libcollections/bit.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ use core::fmt;
8989
use core::hash;
9090
use core::iter::RandomAccessIterator;
9191
use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned};
92-
use core::iter::{self, FromIterator, IntoIterator};
92+
use core::iter::{self, FromIterator};
9393
use core::num::Int;
9494
use core::ops::Index;
9595
use core::slice;
@@ -1070,14 +1070,6 @@ impl<'a> RandomAccessIterator for Iter<'a> {
10701070
}
10711071
}
10721072

1073-
impl<'a> IntoIterator for &'a Bitv {
1074-
type Iter = Iter<'a>;
1075-
1076-
fn into_iter(self) -> Iter<'a> {
1077-
self.iter()
1078-
}
1079-
}
1080-
10811073
/// An implementation of a set using a bit vector as an underlying
10821074
/// representation for holding unsigned numerical elements.
10831075
///
@@ -1881,13 +1873,6 @@ impl<'a> Iterator for SymmetricDifference<'a> {
18811873
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.0.size_hint() }
18821874
}
18831875

1884-
impl<'a> IntoIterator for &'a BitvSet {
1885-
type Iter = SetIter<'a>;
1886-
1887-
fn into_iter(self) -> SetIter<'a> {
1888-
self.iter()
1889-
}
1890-
}
18911876

18921877
#[cfg(test)]
18931878
mod tests {

trunk/src/libcollections/btree/map.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::cmp::Ordering;
2424
use core::default::Default;
2525
use core::fmt::Debug;
2626
use core::hash::{Hash, Hasher};
27-
use core::iter::{Map, FromIterator, IntoIterator};
27+
use core::iter::{Map, FromIterator};
2828
use core::ops::{Index, IndexMut};
2929
use core::{iter, fmt, mem};
3030
use Bound::{self, Included, Excluded, Unbounded};
@@ -478,30 +478,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
478478
}
479479
}
480480

481-
impl<K, V> IntoIterator for BTreeMap<K, V> {
482-
type Iter = IntoIter<K, V>;
483-
484-
fn into_iter(self) -> IntoIter<K, V> {
485-
self.into_iter()
486-
}
487-
}
488-
489-
impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
490-
type Iter = Iter<'a, K, V>;
491-
492-
fn into_iter(self) -> Iter<'a, K, V> {
493-
self.iter()
494-
}
495-
}
496-
497-
impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
498-
type Iter = IterMut<'a, K, V>;
499-
500-
fn into_iter(mut self) -> IterMut<'a, K, V> {
501-
self.iter_mut()
502-
}
503-
}
504-
505481
/// A helper enum useful for deciding whether to continue a loop since we can't
506482
/// return from a closure
507483
enum Continuation<A, B> {

trunk/src/libcollections/btree/node.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<T> DoubleEndedIterator for RawItems<T> {
271271
#[unsafe_destructor]
272272
impl<T> Drop for RawItems<T> {
273273
fn drop(&mut self) {
274-
for _ in self.by_ref() {}
274+
for _ in *self {}
275275
}
276276
}
277277

@@ -1374,9 +1374,9 @@ impl<K, V> Drop for MoveTraversalImpl<K, V> {
13741374
fn drop(&mut self) {
13751375
// We need to cleanup the stored values manually, as the RawItems destructor would run
13761376
// after our deallocation.
1377-
for _ in self.keys.by_ref() {}
1378-
for _ in self.vals.by_ref() {}
1379-
for _ in self.edges.by_ref() {}
1377+
for _ in self.keys {}
1378+
for _ in self.vals {}
1379+
for _ in self.edges {}
13801380

13811381
let (alignment, size) =
13821382
calculate_allocation_generic::<K, V>(self.capacity, self.is_leaf);

trunk/src/libcollections/btree/set.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core::cmp::Ordering::{self, Less, Greater, Equal};
1818
use core::default::Default;
1919
use core::fmt::Debug;
2020
use core::fmt;
21-
use core::iter::{Peekable, Map, FromIterator, IntoIterator};
21+
use core::iter::{Peekable, Map, FromIterator};
2222
use core::ops::{BitOr, BitAnd, BitXor, Sub};
2323

2424
use btree_map::{BTreeMap, Keys};
@@ -480,22 +480,6 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {
480480
}
481481
}
482482

483-
impl<T> IntoIterator for BTreeSet<T> {
484-
type Iter = IntoIter<T>;
485-
486-
fn into_iter(self) -> IntoIter<T> {
487-
self.into_iter()
488-
}
489-
}
490-
491-
impl<'a, T> IntoIterator for &'a BTreeSet<T> {
492-
type Iter = Iter<'a, T>;
493-
494-
fn into_iter(self) -> Iter<'a, T> {
495-
self.iter()
496-
}
497-
}
498-
499483
#[stable(feature = "rust1", since = "1.0.0")]
500484
impl<T: Ord> Extend<T> for BTreeSet<T> {
501485
#[inline]

trunk/src/libcollections/dlist.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use core::cmp::Ordering;
2828
use core::default::Default;
2929
use core::fmt;
3030
use core::hash::{Writer, Hasher, Hash};
31-
use core::iter::{self, FromIterator, IntoIterator};
31+
use core::iter::{self, FromIterator};
3232
use core::mem;
3333
use core::ptr;
3434

@@ -830,30 +830,6 @@ impl<A> FromIterator<A> for DList<A> {
830830
}
831831
}
832832

833-
impl<T> IntoIterator for DList<T> {
834-
type Iter = IntoIter<T>;
835-
836-
fn into_iter(self) -> IntoIter<T> {
837-
self.into_iter()
838-
}
839-
}
840-
841-
impl<'a, T> IntoIterator for &'a DList<T> {
842-
type Iter = Iter<'a, T>;
843-
844-
fn into_iter(self) -> Iter<'a, T> {
845-
self.iter()
846-
}
847-
}
848-
849-
impl<'a, T> IntoIterator for &'a mut DList<T> {
850-
type Iter = IterMut<'a, T>;
851-
852-
fn into_iter(mut self) -> IterMut<'a, T> {
853-
self.iter_mut()
854-
}
855-
}
856-
857833
#[stable(feature = "rust1", since = "1.0.0")]
858834
impl<A> Extend<A> for DList<A> {
859835
fn extend<T: Iterator<Item=A>>(&mut self, mut iterator: T) {

0 commit comments

Comments
 (0)