Skip to content

Commit f4f10db

Browse files
committed
auto merge of #21300 : steveklabnik/rust/rollup, r=steveklabnik
manual rollup to fix some conflicts and diagnose why the test is failing...
2 parents 89c4e37 + 6553c0f commit f4f10db

Some content is hidden

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

50 files changed

+604
-457
lines changed

LICENSE-MIT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 The Rust Project Developers
1+
Copyright (c) 2015 The Rust Project Developers
22

33
Permission is hereby granted, free of charge, to any
44
person obtaining a copy of this software and associated

mk/crates.mk

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
TARGET_CRATES := libc std flate arena term \
5353
serialize getopts collections test rand \
5454
log regex graphviz core rbml alloc \
55-
unicode
55+
unicode rustc_bitflags
5656
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
5757
rustc_trans rustc_back rustc_llvm rustc_privacy
5858
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
@@ -64,7 +64,8 @@ DEPS_libc := core
6464
DEPS_unicode := core
6565
DEPS_alloc := core libc native:jemalloc
6666
DEPS_std := core libc rand alloc collections unicode \
67-
native:rust_builtin native:backtrace native:rustrt_native
67+
native:rust_builtin native:backtrace native:rustrt_native \
68+
rustc_bitflags
6869
DEPS_graphviz := std
6970
DEPS_syntax := std term serialize log fmt_macros arena libc
7071
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
@@ -83,6 +84,7 @@ DEPS_rustc_llvm := native:rustllvm libc std
8384
DEPS_rustc_back := std syntax rustc_llvm flate log libc
8485
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
8586
test
87+
DEPS_rustc_bitflags := core
8688
DEPS_flate := std native:miniz
8789
DEPS_arena := std
8890
DEPS_graphviz := std
@@ -114,6 +116,7 @@ ONLY_RLIB_alloc := 1
114116
ONLY_RLIB_rand := 1
115117
ONLY_RLIB_collections := 1
116118
ONLY_RLIB_unicode := 1
119+
ONLY_RLIB_rustc_bitflags := 1
117120

118121
################################################################################
119122
# You should not need to edit below this line

src/doc/intro.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ Let's see an example. This Rust code will not compile:
424424
use std::thread::Thread;
425425
426426
fn main() {
427-
let mut numbers = vec![1i, 2i, 3i];
427+
let mut numbers = vec![1is, 2, 3];
428428
429-
for i in range(0u, 3u) {
429+
for i in 0..3 {
430430
Thread::spawn(move || {
431-
for j in range(0, 3) { numbers[j] += 1 }
431+
for j in 0..3 { numbers[j] += 1 }
432432
});
433433
}
434434
}
@@ -438,15 +438,15 @@ It gives us this error:
438438
439439
```text
440440
6:71 error: capture of moved value: `numbers`
441-
for j in range(0, 3) { numbers[j] += 1 }
442-
^~~~~~~
441+
for j in 0..3 { numbers[j] += 1 }
442+
^~~~~~~
443443
7:50 note: `numbers` moved into closure environment here
444444
spawn(move || {
445-
for j in range(0, 3) { numbers[j] += 1 }
445+
for j in 0..3 { numbers[j] += 1 }
446446
});
447447
6:79 error: cannot assign to immutable dereference (dereference is implicit, due to indexing)
448-
for j in range(0, 3) { numbers[j] += 1 }
449-
^~~~~~~~~~~~~~~
448+
for j in 0..3 { numbers[j] += 1 }
449+
^~~~~~~~~~~~~~~
450450
```
451451
452452
It mentions that "numbers moved into closure environment". Because we
@@ -478,9 +478,9 @@ use std::thread::Thread;
478478
use std::sync::{Arc,Mutex};
479479
480480
fn main() {
481-
let numbers = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
481+
let numbers = Arc::new(Mutex::new(vec![1is, 2, 3]));
482482
483-
for i in range(0u, 3u) {
483+
for i in 0..3 {
484484
let number = numbers.clone();
485485
Thread::spawn(move || {
486486
let mut array = number.lock().unwrap();
@@ -541,12 +541,12 @@ safety check that makes this an error about moved values:
541541
use std::thread::Thread;
542542
543543
fn main() {
544-
let vec = vec![1i, 2, 3];
544+
let vec = vec![1is, 2, 3];
545545
546-
for i in range(0u, 3) {
546+
for i in 0us..3 {
547547
Thread::spawn(move || {
548548
println!("{}", vec[i]);
549-
}).detach();
549+
});
550550
}
551551
}
552552
```
@@ -557,9 +557,9 @@ you can remove it. As an example, this is a poor way to iterate through
557557
a vector:
558558
559559
```{rust}
560-
let vec = vec![1i, 2, 3];
560+
let vec = vec![1, 2, 3];
561561
562-
for i in range(0u, vec.len()) {
562+
for i in 0..vec.len() {
563563
println!("{}", vec[i]);
564564
}
565565
```
@@ -569,7 +569,7 @@ that we don't try to access an invalid index. However, we can remove this
569569
while retaining safety. The answer is iterators:
570570
571571
```{rust}
572-
let vec = vec![1i, 2, 3];
572+
let vec = vec![1, 2, 3];
573573
574574
for x in vec.iter() {
575575
println!("{}", x);

src/doc/reference.md

+21
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,27 @@ a = Animal::Cat { name: "Spotty".to_string(), weight: 2.7 };
14131413
In this example, `Cat` is a _struct-like enum variant_,
14141414
whereas `Dog` is simply called an enum variant.
14151415

1416+
Enums have a discriminant. You can assign them explicitly:
1417+
1418+
```
1419+
enum Foo {
1420+
Bar = 123,
1421+
}
1422+
```
1423+
1424+
If a discriminant isn't assigned, they start at zero, and add one for each
1425+
variant, in order.
1426+
1427+
You can cast an enum to get this value:
1428+
1429+
```
1430+
# enum Foo { Bar = 123 }
1431+
let x = Foo::Bar as u32; // x is now 123u32
1432+
```
1433+
1434+
This only works as long as none of the variants have data attached. If
1435+
it were `Bar(i32)`, this is disallowed.
1436+
14161437
### Constant items
14171438

14181439
```{.ebnf .gram}

src/doc/trpl/arrays-vectors-and-slices.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ things. The most basic is the *array*, a fixed-size list of elements of the
55
same type. By default, arrays are immutable.
66

77
```{rust}
8-
let a = [1, 2, 3]; // a: [i32; 3]
8+
let a = [1, 2, 3]; // a: [i32; 3]
99
let mut m = [1, 2, 3]; // mut m: [i32; 3]
1010
```
1111

@@ -68,7 +68,7 @@ let mut nums = vec![1, 2, 3]; // mut nums: Vec<i32>
6868
6969
nums.push(4);
7070
71-
println!("The length of nums is now {}", nums.len()); // Prints 4
71+
println!("The length of nums is now {}", nums.len()); // Prints 4
7272
```
7373

7474
Vectors have many more useful methods.
@@ -82,10 +82,10 @@ arrays:
8282

8383
```{rust}
8484
let a = [0, 1, 2, 3, 4];
85-
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
85+
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
8686
8787
for e in middle.iter() {
88-
println!("{}", e); // Prints 1, 2, 3
88+
println!("{}", e); // Prints 1, 2, 3
8989
}
9090
```
9191

src/doc/trpl/compound-data-types.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ arity and contained types.
5151

5252
```rust
5353
let mut x = (1, 2); // x: (i32, i32)
54-
let y = (2, 3); // y: (i32, i32)
54+
let y = (2, 3); // y: (i32, i32)
5555

5656
x = y;
5757
```
@@ -156,7 +156,7 @@ These two will not be equal, even if they have the same values:
156156
```{rust}
157157
# struct Color(i32, i32, i32);
158158
# struct Point(i32, i32, i32);
159-
let black = Color(0, 0, 0);
159+
let black = Color(0, 0, 0);
160160
let origin = Point(0, 0, 0);
161161
```
162162

@@ -297,7 +297,7 @@ enum StringResult {
297297
}
298298
```
299299
Where a `StringResult` is either a `StringResult::StringOK`, with the result of
300-
a computation, or an `StringResult::ErrorReason` with a `String` explaining
300+
a computation, or a `StringResult::ErrorReason` with a `String` explaining
301301
what caused the computation to fail. These kinds of `enum`s are actually very
302302
useful and are even part of the standard library.
303303

src/doc/trpl/crates-and-modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% The Rust Crates and Modules Guide
1+
% Crates and Modules
22

33
When a project starts getting large, it's considered a good software
44
engineering practice to split it up into a bunch of smaller pieces, and then

src/doc/trpl/error-handling.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% Error Handling in Rust
1+
% Error Handling
22

33
> The best-laid plans of mice and men
44
> Often go awry
@@ -60,12 +60,12 @@ fn probability(_: &Event) -> f64 {
6060
6161
fn descriptive_probability(event: Event) -> &'static str {
6262
match probability(&event) {
63-
1.00 => "certain",
64-
0.00 => "impossible",
63+
1.00 => "certain",
64+
0.00 => "impossible",
6565
0.00 ... 0.25 => "very unlikely",
6666
0.25 ... 0.50 => "unlikely",
6767
0.50 ... 0.75 => "likely",
68-
0.75 ... 1.00 => "very likely",
68+
0.75 ... 1.00 => "very likely",
6969
}
7070
}
7171
@@ -97,12 +97,12 @@ fn probability(_: &Event) -> f64 {
9797

9898
fn descriptive_probability(event: Event) -> &'static str {
9999
match probability(&event) {
100-
1.00 => "certain",
101-
0.00 => "impossible",
100+
1.00 => "certain",
101+
0.00 => "impossible",
102102
0.00 ... 0.25 => "very unlikely",
103103
0.25 ... 0.50 => "unlikely",
104104
0.50 ... 0.75 => "likely",
105-
0.75 ... 1.00 => "very likely",
105+
0.75 ... 1.00 => "very likely",
106106
_ => unreachable!()
107107
}
108108
}

0 commit comments

Comments
 (0)