Skip to content

Commit 474b324

Browse files
committed
Auto merge of #21791 - alexcrichton:rollup, r=alexcrichton
2 parents 1d00c54 + e8fd9d3 commit 474b324

File tree

661 files changed

+4539
-7316
lines changed

Some content is hidden

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

661 files changed

+4539
-7316
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ There is a lot more documentation in the [wiki].
110110

111111
The Rust community congregates in a few places:
112112

113-
* [StackOverflow] - Get help here.
114-
* [/r/rust] - General discussion.
113+
* [StackOverflow] - Direct questions about using the language here.
114+
* [users.rust-lang.org] - General discussion, broader questions.
115115
* [internals.rust-lang.org] - For development of the Rust language itself.
116+
* [/r/rust] - News and general discussion.
116117

117118
[StackOverflow]: http://stackoverflow.com/questions/tagged/rust
118119
[/r/rust]: http://reddit.com/r/rust
120+
[users.rust-lang.org]: http://users.rust-lang.org/
119121
[internals.rust-lang.org]: http://internals.rust-lang.org/
120122

121123
## License

src/compiletest/common.rs

+11-10
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
}

src/compiletest/compiletest.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@
99
// except according to those terms.
1010

1111
#![crate_type = "bin"]
12-
#![allow(unknown_features)]
13-
#![feature(slicing_syntax, unboxed_closures)]
12+
1413
#![feature(box_syntax)]
14+
#![feature(collections)]
15+
#![feature(core)]
1516
#![feature(int_uint)]
16-
#![feature(test)]
17-
#![feature(rustc_private)]
18-
#![feature(std_misc)]
19-
#![feature(path)]
2017
#![feature(io)]
21-
#![feature(core)]
22-
#![feature(collections)]
2318
#![feature(os)]
19+
#![feature(path)]
20+
#![feature(rustc_private)]
21+
#![feature(slicing_syntax, unboxed_closures)]
22+
#![feature(std_misc)]
23+
#![feature(test)]
2424
#![feature(unicode)]
2525

26-
#![allow(unstable)]
2726
#![deny(warnings)]
2827

2928
extern crate test;
@@ -35,7 +34,6 @@ extern crate log;
3534
use std::os;
3635
use std::old_io;
3736
use std::old_io::fs;
38-
use std::str::FromStr;
3937
use std::thunk::Thunk;
4038
use getopts::{optopt, optflag, reqopt};
4139
use common::Config;
@@ -140,9 +138,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
140138
build_base: opt_path(matches, "build-base"),
141139
aux_base: opt_path(matches, "aux-base"),
142140
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"),
141+
mode: matches.opt_str("mode").unwrap().parse().ok().expect("invalid mode"),
146142
run_ignored: matches.opt_present("ignored"),
147143
filter: filter,
148144
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),

src/compiletest/header.rs

+3-3
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
}

src/doc/index.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ Overflow](http://stackoverflow.com/questions/tagged/rust). Searching for your
3939
problem might reveal someone who has asked it before!
4040

4141
There is an active [subreddit](http://reddit.com/r/rust) with lots of
42-
discussion about Rust.
42+
discussion and news about Rust.
4343

44-
There is also a [developer forum](http://internals.rust-lang.org/), where the
45-
development of Rust itself is discussed.
44+
There is also a [user forum](http://users.rust-lang.org), for all
45+
user-oriented discussion, and a [developer
46+
forum](http://internals.rust-lang.org/), where the development of Rust
47+
itself is discussed.
4648

4749
# Specification
4850

src/doc/reference.md

+2-2
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
@@ -3518,7 +3518,7 @@ An example of each kind:
35183518
```{rust}
35193519
let vec: Vec<i32> = vec![1, 2, 3];
35203520
let arr: [i32; 3] = [1, 2, 3];
3521-
let s: &[i32] = vec.as_slice();
3521+
let s: &[i32] = &vec;
35223522
```
35233523

35243524
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The

src/doc/trpl/guessing-game.md

+13-11
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,

src/doc/trpl/more-strings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ To write a function that's generic over types of strings, use `&str`.
100100

101101
```
102102
fn some_string_length(x: &str) -> uint {
103-
x.len()
103+
x.len()
104104
}
105105
106106
fn main() {
@@ -110,7 +110,7 @@ fn main() {
110110
111111
let s = "Hello, world".to_string();
112112
113-
println!("{}", some_string_length(s.as_slice()));
113+
println!("{}", some_string_length(&s));
114114
}
115115
```
116116

src/doc/trpl/patterns.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ match origin {
174174
}
175175
```
176176

177-
If you want to match against a slice or array, you can use `[]`:
177+
If you want to match against a slice or array, you can use `&`:
178178

179179
```{rust}
180180
fn main() {
181181
let v = vec!["match_this", "1"];
182182
183-
match v.as_slice() {
183+
match &v[] {
184184
["match_this", second] => println!("The second element is {}", second),
185185
_ => {},
186186
}

src/doc/trpl/plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
8282
}
8383
};
8484
85-
let mut text = text.as_slice();
85+
let mut text = &text;
8686
let mut total = 0;
8787
while !text.is_empty() {
8888
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {

src/doc/trpl/standard-input.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Let's go over these chunks, one by one:
2020
std::old_io::stdin();
2121
```
2222

23-
This calls a function, `stdin()`, that lives inside the `std::io` module. As
23+
This calls a function, `stdin()`, that lives inside the `std::old_io` module. As
2424
you can imagine, everything in `std` is provided by Rust, the 'standard
2525
library.' We'll talk more about the module system later.
2626

src/doc/trpl/strings.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,16 @@ s.push_str(", world.");
3636
println!("{}", s);
3737
```
3838

39-
You can get a `&str` view into a `String` with the `as_slice()` method:
39+
`String`s will coerece into `&str` with an `&`:
4040

41-
```{rust}
41+
```
4242
fn takes_slice(slice: &str) {
4343
println!("Got: {}", slice);
4444
}
4545
4646
fn main() {
4747
let s = "Hello".to_string();
48-
takes_slice(s.as_slice());
49-
}
50-
```
51-
52-
To compare a String to a constant string, prefer `as_slice()`...
53-
54-
```{rust}
55-
fn compare(string: String) {
56-
if string.as_slice() == "Hello" {
57-
println!("yes");
58-
}
59-
}
60-
```
61-
62-
... over `to_string()`:
63-
64-
```{rust}
65-
fn compare(string: String) {
66-
if string == "Hello".to_string() {
67-
println!("yes");
68-
}
48+
takes_slice(&s);
6949
}
7050
```
7151

src/doc/trpl/unsafe.md

+4
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,10 @@ 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+
# }
579583
```
580584

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

src/driver/driver.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(unknown_features)]
1211
#![cfg_attr(rustc, feature(rustc_private))]
1312
#![cfg_attr(rustdoc, feature(rustdoc))]
1413

0 commit comments

Comments
 (0)