Skip to content

Commit bc8484a

Browse files
committed
---
yaml --- r: 177918 b: refs/heads/snap-stage3 c: 19a1f7e h: refs/heads/master v: v3
1 parent 9102f50 commit bc8484a

File tree

184 files changed

+4798
-2296
lines changed

Some content is hidden

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

184 files changed

+4798
-2296
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 474b324eda10440d6568ef872a7307d38e7de95b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6ea5fb8a6d3131931dd70d45dc4d4f0b1e26cd01
4+
refs/heads/snap-stage3: 19a1f7ed06d3f4f3b64cb4417f7159cd59f38ae7
55
refs/heads/try: fde4472848b662a4d1236388c4cf15e2450237e6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/README.md

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

111111
The Rust community congregates in a few places:
112112

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

118117
[StackOverflow]: http://stackoverflow.com/questions/tagged/rust
119118
[/r/rust]: http://reddit.com/r/rust
120-
[users.rust-lang.org]: http://users.rust-lang.org/
121119
[internals.rust-lang.org]: http://internals.rust-lang.org/
122120

123121
## License

branches/snap-stage3/src/compiletest/common.rs

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

2727
impl FromStr for Mode {
28-
type Err = ();
29-
fn from_str(s: &str) -> Result<Mode, ()> {
28+
fn from_str(s: &str) -> Option<Mode> {
3029
match s {
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(()),
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,
4039
}
4140
}
4241
}

branches/snap-stage3/src/compiletest/compiletest.rs

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

branches/snap-stage3/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().ok().expect(error_string);
356-
let minor: int = components[1].parse().ok().expect(error_string);
355+
let major: int = components[0].parse().expect(error_string);
356+
let minor: int = components[1].parse().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().ok().expect(error_string);
366+
let major: int = version_string.parse().expect(error_string);
367367
return major;
368368
}

branches/snap-stage3/src/doc/index.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ 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 and news about Rust.
42+
discussion about Rust.
4343

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.
44+
There is also a [developer forum](http://internals.rust-lang.org/), where the
45+
development of Rust itself is discussed.
4846

4947
# Specification
5048

branches/snap-stage3/src/doc/reference.md

Lines changed: 2 additions & 2 deletions
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().ok();
2997+
let pi: Option<f32> = "3.14".parse();
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

branches/snap-stage3/src/doc/trpl/guessing-game.md

Lines changed: 11 additions & 13 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().ok();
403+
let input_num: Option<u32> = input.parse();
404404
```
405405
406406
The `parse` function takes in a `&str` value and converts it into something.
@@ -422,13 +422,11 @@ 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>().ok(); // input_num: Option<u32>
426-
let input_num: Option<u32> = "5".parse().ok(); // input_num: Option<u32>
425+
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426+
let input_num: Option<u32> = "5".parse(); // input_num: Option<u32>
427427
```
428428
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:
429+
Anyway, with us now converting our input to a number, our code looks like this:
432430
433431
```{rust,ignore}
434432
use std::old_io;
@@ -447,7 +445,7 @@ fn main() {
447445
let input = old_io::stdin().read_line()
448446
.ok()
449447
.expect("Failed to read line");
450-
let input_num: Option<u32> = input.parse().ok();
448+
let input_num: Option<u32> = input.parse();
451449

452450
println!("You guessed: {}", input_num);
453451

@@ -497,7 +495,7 @@ fn main() {
497495
let input = old_io::stdin().read_line()
498496
.ok()
499497
.expect("Failed to read line");
500-
let input_num: Option<u32> = input.parse().ok();
498+
let input_num: Option<u32> = input.parse();
501499
502500
let num = match input_num {
503501
Some(num) => num,
@@ -564,7 +562,7 @@ fn main() {
564562
let input = old_io::stdin().read_line()
565563
.ok()
566564
.expect("Failed to read line");
567-
let input_num: Option<u32> = input.trim().parse().ok();
565+
let input_num: Option<u32> = input.trim().parse();
568566
569567
let num = match input_num {
570568
Some(num) => num,
@@ -640,7 +638,7 @@ fn main() {
640638
let input = old_io::stdin().read_line()
641639
.ok()
642640
.expect("Failed to read line");
643-
let input_num: Option<u32> = input.trim().parse().ok();
641+
let input_num: Option<u32> = input.trim().parse();
644642

645643
let num = match input_num {
646644
Some(num) => num,
@@ -716,7 +714,7 @@ fn main() {
716714
let input = old_io::stdin().read_line()
717715
.ok()
718716
.expect("Failed to read line");
719-
let input_num: Option<u32> = input.trim().parse().ok();
717+
let input_num: Option<u32> = input.trim().parse();
720718
721719
let num = match input_num {
722720
Some(num) => num,
@@ -772,7 +770,7 @@ fn main() {
772770
let input = old_io::stdin().read_line()
773771
.ok()
774772
.expect("Failed to read line");
775-
let input_num: Option<u32> = input.trim().parse().ok();
773+
let input_num: Option<u32> = input.trim().parse();
776774
777775
let num = match input_num {
778776
Some(num) => num,
@@ -849,7 +847,7 @@ fn main() {
849847
let input = old_io::stdin().read_line()
850848
.ok()
851849
.expect("Failed to read line");
852-
let input_num: Option<u32> = input.trim().parse().ok();
850+
let input_num: Option<u32> = input.trim().parse();
853851
854852
let num = match input_num {
855853
Some(num) => num,

branches/snap-stage3/src/doc/trpl/more-strings.md

Lines changed: 2 additions & 2 deletions
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

branches/snap-stage3/src/doc/trpl/patterns.md

Lines changed: 2 additions & 2 deletions
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
}

branches/snap-stage3/src/doc/trpl/plugins.md

Lines changed: 1 addition & 1 deletion
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)) {

branches/snap-stage3/src/doc/trpl/strings.md

Lines changed: 3 additions & 23 deletions
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

branches/snap-stage3/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
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
`rust-mode`: A major Emacs mode for editing Rust source code
2+
============================================================
3+
4+
`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs
5+
enjoyable.
6+
7+
8+
### Manual Installation
9+
10+
To install manually, check out this repository and add this to your
11+
`.emacs` file:
12+
13+
```lisp
14+
(add-to-list 'load-path "/path/to/rust-mode/")
15+
(autoload 'rust-mode "rust-mode" nil t)
16+
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
17+
```
18+
19+
This associates `rust-mode` with `.rs` files. To enable it explicitly, do
20+
<kbd>M-x rust-mode</kbd>.
21+
22+
### `package.el` installation via Marmalade or MELPA
23+
24+
It can be more convenient to use Emacs's package manager to handle
25+
installation for you if you use many elisp libraries. If you have
26+
`package.el` but haven't added Marmalade or MELPA, the community
27+
package source, yet, add this to `~/.emacs.d/init.el`:
28+
29+
Using Marmalade:
30+
31+
```lisp
32+
(require 'package)
33+
(add-to-list 'package-archives
34+
'("marmalade" . "http://marmalade-repo.org/packages/"))
35+
(package-initialize)
36+
```
37+
38+
Using MELPA:
39+
40+
```lisp
41+
(require 'package)
42+
(add-to-list 'package-archives
43+
'("melpa" . "http://melpa.milkbox.net/packages/") t)
44+
(package-initialize)
45+
```
46+
47+
Then do this to load the package listing:
48+
49+
* <kbd>M-x eval-buffer</kbd>
50+
* <kbd>M-x package-refresh-contents</kbd>
51+
52+
If you use a version of Emacs prior to 24 that doesn't include
53+
`package.el`, you can get it from [here](http://bit.ly/pkg-el23).
54+
55+
If you have an older ELPA `package.el` installed from tromey.com, you
56+
should upgrade in order to support installation from multiple sources.
57+
The ELPA archive is deprecated and no longer accepting new packages,
58+
so the version there (1.7.1) is very outdated.
59+
60+
#### Install `rust-mode`
61+
62+
One you have `package.el`, you can install `rust-mode` or any other
63+
modes by choosing them from a list:
64+
65+
* <kbd>M-x package-list-packages</kbd>
66+
67+
Now, to install packages, move your cursor to them and press
68+
<kbd>i</kbd>. This will mark the packages for installation. When
69+
you're done with marking, press <kbd>x</kbd>, and ELPA will install
70+
the packages for you (under `~/.emacs.d/elpa/`).
71+
72+
* or using <kbd>M-x package-install rust-mode</kbd>
73+
74+
### Tests via ERT
75+
76+
The file `rust-mode-tests.el` contains tests that can be run via
77+
[ERT](http://www.gnu.org/software/emacs/manual/html_node/ert/index.html).
78+
You can use `run_rust_emacs_tests.sh` to run them in batch mode, if
79+
Emacs is somewhere in your `$PATH`.

0 commit comments

Comments
 (0)