Skip to content

Commit

Permalink
auto merge of #21300 : steveklabnik/rust/rollup, r=steveklabnik
Browse files Browse the repository at this point in the history
manual rollup to fix some conflicts and diagnose why the test is failing...
  • Loading branch information
bors committed Jan 17, 2015
2 parents 89c4e37 + 6553c0f commit f4f10db
Show file tree
Hide file tree
Showing 50 changed files with 604 additions and 457 deletions.
2 changes: 1 addition & 1 deletion LICENSE-MIT
@@ -1,4 +1,4 @@
Copyright (c) 2014 The Rust Project Developers
Copyright (c) 2015 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
7 changes: 5 additions & 2 deletions mk/crates.mk
Expand Up @@ -52,7 +52,7 @@
TARGET_CRATES := libc std flate arena term \
serialize getopts collections test rand \
log regex graphviz core rbml alloc \
unicode
unicode rustc_bitflags
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
rustc_trans rustc_back rustc_llvm rustc_privacy
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
Expand All @@ -64,7 +64,8 @@ DEPS_libc := core
DEPS_unicode := core
DEPS_alloc := core libc native:jemalloc
DEPS_std := core libc rand alloc collections unicode \
native:rust_builtin native:backtrace native:rustrt_native
native:rust_builtin native:backtrace native:rustrt_native \
rustc_bitflags
DEPS_graphviz := std
DEPS_syntax := std term serialize log fmt_macros arena libc
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
Expand All @@ -83,6 +84,7 @@ DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
test
DEPS_rustc_bitflags := core
DEPS_flate := std native:miniz
DEPS_arena := std
DEPS_graphviz := std
Expand Down Expand Up @@ -114,6 +116,7 @@ ONLY_RLIB_alloc := 1
ONLY_RLIB_rand := 1
ONLY_RLIB_collections := 1
ONLY_RLIB_unicode := 1
ONLY_RLIB_rustc_bitflags := 1

################################################################################
# You should not need to edit below this line
Expand Down
32 changes: 16 additions & 16 deletions src/doc/intro.md
Expand Up @@ -424,11 +424,11 @@ Let's see an example. This Rust code will not compile:
use std::thread::Thread;
fn main() {
let mut numbers = vec![1i, 2i, 3i];
let mut numbers = vec![1is, 2, 3];
for i in range(0u, 3u) {
for i in 0..3 {
Thread::spawn(move || {
for j in range(0, 3) { numbers[j] += 1 }
for j in 0..3 { numbers[j] += 1 }
});
}
}
Expand All @@ -438,15 +438,15 @@ It gives us this error:
```text
6:71 error: capture of moved value: `numbers`
for j in range(0, 3) { numbers[j] += 1 }
^~~~~~~
for j in 0..3 { numbers[j] += 1 }
^~~~~~~
7:50 note: `numbers` moved into closure environment here
spawn(move || {
for j in range(0, 3) { numbers[j] += 1 }
for j in 0..3 { numbers[j] += 1 }
});
6:79 error: cannot assign to immutable dereference (dereference is implicit, due to indexing)
for j in range(0, 3) { numbers[j] += 1 }
^~~~~~~~~~~~~~~
for j in 0..3 { numbers[j] += 1 }
^~~~~~~~~~~~~~~
```
It mentions that "numbers moved into closure environment". Because we
Expand Down Expand Up @@ -478,9 +478,9 @@ use std::thread::Thread;
use std::sync::{Arc,Mutex};
fn main() {
let numbers = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
let numbers = Arc::new(Mutex::new(vec![1is, 2, 3]));
for i in range(0u, 3u) {
for i in 0..3 {
let number = numbers.clone();
Thread::spawn(move || {
let mut array = number.lock().unwrap();
Expand Down Expand Up @@ -541,12 +541,12 @@ safety check that makes this an error about moved values:
use std::thread::Thread;
fn main() {
let vec = vec![1i, 2, 3];
let vec = vec![1is, 2, 3];
for i in range(0u, 3) {
for i in 0us..3 {
Thread::spawn(move || {
println!("{}", vec[i]);
}).detach();
});
}
}
```
Expand All @@ -557,9 +557,9 @@ you can remove it. As an example, this is a poor way to iterate through
a vector:
```{rust}
let vec = vec![1i, 2, 3];
let vec = vec![1, 2, 3];
for i in range(0u, vec.len()) {
for i in 0..vec.len() {
println!("{}", vec[i]);
}
```
Expand All @@ -569,7 +569,7 @@ that we don't try to access an invalid index. However, we can remove this
while retaining safety. The answer is iterators:
```{rust}
let vec = vec![1i, 2, 3];
let vec = vec![1, 2, 3];
for x in vec.iter() {
println!("{}", x);
Expand Down
21 changes: 21 additions & 0 deletions src/doc/reference.md
Expand Up @@ -1413,6 +1413,27 @@ a = Animal::Cat { name: "Spotty".to_string(), weight: 2.7 };
In this example, `Cat` is a _struct-like enum variant_,
whereas `Dog` is simply called an enum variant.

Enums have a discriminant. You can assign them explicitly:

```
enum Foo {
Bar = 123,
}
```

If a discriminant isn't assigned, they start at zero, and add one for each
variant, in order.

You can cast an enum to get this value:

```
# enum Foo { Bar = 123 }
let x = Foo::Bar as u32; // x is now 123u32
```

This only works as long as none of the variants have data attached. If
it were `Bar(i32)`, this is disallowed.

### Constant items

```{.ebnf .gram}
Expand Down
8 changes: 4 additions & 4 deletions src/doc/trpl/arrays-vectors-and-slices.md
Expand Up @@ -5,7 +5,7 @@ things. The most basic is the *array*, a fixed-size list of elements of the
same type. By default, arrays are immutable.

```{rust}
let a = [1, 2, 3]; // a: [i32; 3]
let a = [1, 2, 3]; // a: [i32; 3]
let mut m = [1, 2, 3]; // mut m: [i32; 3]
```

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

Vectors have many more useful methods.
Expand All @@ -82,10 +82,10 @@ arrays:

```{rust}
let a = [0, 1, 2, 3, 4];
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
let middle = &a[1..4]; // A slice of a: just the elements 1, 2, and 3
for e in middle.iter() {
println!("{}", e); // Prints 1, 2, 3
println!("{}", e); // Prints 1, 2, 3
}
```

Expand Down
6 changes: 3 additions & 3 deletions src/doc/trpl/compound-data-types.md
Expand Up @@ -51,7 +51,7 @@ arity and contained types.

```rust
let mut x = (1, 2); // x: (i32, i32)
let y = (2, 3); // y: (i32, i32)
let y = (2, 3); // y: (i32, i32)

x = y;
```
Expand Down Expand Up @@ -156,7 +156,7 @@ These two will not be equal, even if they have the same values:
```{rust}
# struct Color(i32, i32, i32);
# struct Point(i32, i32, i32);
let black = Color(0, 0, 0);
let black = Color(0, 0, 0);
let origin = Point(0, 0, 0);
```

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

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/crates-and-modules.md
@@ -1,4 +1,4 @@
% The Rust Crates and Modules Guide
% Crates and Modules

When a project starts getting large, it's considered a good software
engineering practice to split it up into a bunch of smaller pieces, and then
Expand Down
14 changes: 7 additions & 7 deletions src/doc/trpl/error-handling.md
@@ -1,4 +1,4 @@
% Error Handling in Rust
% Error Handling

> The best-laid plans of mice and men
> Often go awry
Expand Down Expand Up @@ -60,12 +60,12 @@ fn probability(_: &Event) -> f64 {
fn descriptive_probability(event: Event) -> &'static str {
match probability(&event) {
1.00 => "certain",
0.00 => "impossible",
1.00 => "certain",
0.00 => "impossible",
0.00 ... 0.25 => "very unlikely",
0.25 ... 0.50 => "unlikely",
0.50 ... 0.75 => "likely",
0.75 ... 1.00 => "very likely",
0.75 ... 1.00 => "very likely",
}
}
Expand Down Expand Up @@ -97,12 +97,12 @@ fn probability(_: &Event) -> f64 {

fn descriptive_probability(event: Event) -> &'static str {
match probability(&event) {
1.00 => "certain",
0.00 => "impossible",
1.00 => "certain",
0.00 => "impossible",
0.00 ... 0.25 => "very unlikely",
0.25 ... 0.50 => "unlikely",
0.50 ... 0.75 => "likely",
0.75 ... 1.00 => "very likely",
0.75 ... 1.00 => "very likely",
_ => unreachable!()
}
}
Expand Down

0 comments on commit f4f10db

Please sign in to comment.