Skip to content

Rollup of PRs in the queue #22724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 81 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
ef1308c
Handle RUST_TEST_NOCAPTURE in compiletest and set add if to run env
fhahn Feb 15, 2015
55f625a
os.getcwd renamed to env::current_dir
tshepang Feb 18, 2015
2f735f5
unused imports
tshepang Feb 18, 2015
ac3a390
rustbook: no-longer-used feature gate
tshepang Feb 18, 2015
bb22c10
borrowck/README.md: Remove most references to &const
kmcallister Feb 19, 2015
0c1fc1c
borrowck/README.md: Clarify MUTABILITY and ALIASABLE
kmcallister Feb 19, 2015
160cf96
borrowck/README.md: Remove SCOPE (mostly unused)
kmcallister Feb 19, 2015
ac6cab0
borrowck/README.md: Fix display of code on GitHub
kmcallister Feb 19, 2015
f051e13
Fix references to doc.rs throughout the code
kmcallister Feb 19, 2015
1597f91
borrowck/README.md: Normalize types in examples
kmcallister Feb 19, 2015
61ea8b3
Fix issue #22426 #22447
bombless Feb 19, 2015
0643494
Fix tests
bombless Feb 19, 2015
b13e072
Remove questionable pattern
bombless Feb 19, 2015
96be553
book: Minor clarifications about strings
brson Feb 20, 2015
5e616db
Tweaks to equality comparisons for slices/arrays/vectors
petrochenkov Feb 20, 2015
fcc21b3
docs: Explain static dispatch advantage more clearly
brson Feb 20, 2015
eceab29
Fix typo
bombless Feb 20, 2015
244c65d
Un-ignore lang-item-public test.
vadimcn Feb 21, 2015
03753ba
Fix io::Take behavior with limit 0
sfackler Feb 21, 2015
b4dc9fd
Remove last traces of BitV and BitVSet from documentation
fhartwig Feb 21, 2015
b46e3ee
Implement BufRead for Take
sfackler Feb 21, 2015
aa6604a
Fix small typo in reference to code of conduct
tigarmo Feb 22, 2015
c2a2b10
shift int/uint tests around to avoid code repetition
glacjay Feb 22, 2015
928341e
Include tuple indexing in the Reference.
achernya Feb 22, 2015
a7594f2
Disallow crate names with leading hyphens
lambda-fairy Feb 22, 2015
24fa6be
Miscellaneous README changes
iKevinY Feb 21, 2015
c9d0967
Validate inline attribute arguments
nagisa Feb 18, 2015
b593c60
Add missing cast for retslots in case of "subtyping" due to trait bounds
dotdash Feb 22, 2015
25d3e01
Implement append and split_off for VecMap (RFC 509)
msiemens Feb 18, 2015
c5a3cbb
Fix typos in CStr docs
shepmaster Feb 22, 2015
0c25e6f
Convert some panics to bug diagnostics in trans
nagisa Feb 19, 2015
9be8ec8
Properly translate methods with foreign CC
nagisa Feb 19, 2015
a499148
Fix another occurrence of #22243
untitaker Feb 22, 2015
d7c02c3
Link from literals to their representation
steveklabnik Feb 13, 2015
27f3571
Improve documentation for libcollections/str
steveklabnik Feb 18, 2015
6f9b91d
save-analysis: handle type defs in struct patterns
nrc Feb 19, 2015
6154c88
Update intro.md to fix thread spawning example Closes #22419
diamondman Feb 13, 2015
23fe16e
rustbook: update slicing syntax where [] --> [..]
tshepang Feb 22, 2015
04b0a3a
save-analysis: fix impls on primitive types
nrc Feb 22, 2015
852eadc
boxed: fix typo in doc
stepancheg Feb 22, 2015
6ea97c4
runtest: update slicing syntax where [] becomes [..]
tshepang Feb 22, 2015
554022e
boxed: mark from_raw and into_raw functions inline
stepancheg Feb 22, 2015
26d9f0a
Use boxed functions instead of transmute
stepancheg Feb 22, 2015
72eaf2c
Switch to &vector notation in the iterators chapter.
jxcl Feb 21, 2015
9f2b067
Fixed erroneous statements in iterators.md.
jxcl Feb 23, 2015
46a5451
Rollup merge of #22270 - steveklabnik:gh22152, r=huonw
Manishearth Feb 23, 2015
1acd7c9
Rollup merge of #22371 - fhahn:issue-17829-compiletest-nocapture, r=M…
Manishearth Feb 23, 2015
a0375e1
Rollup merge of #22505 - tshepang:current_dir, r=steveklabnik
Manishearth Feb 23, 2015
1517313
Rollup merge of #22513 - steveklabnik:doc_str, r=brson
Manishearth Feb 23, 2015
5972695
Rollup merge of #22514 - diamondman:intro_doc_threading, r=steveklabnik
Manishearth Feb 23, 2015
0fab2b9
Rollup merge of #22556 - brson:str, r=steveklabnik
Manishearth Feb 23, 2015
af81ec2
Rollup merge of #22559 - kmcallister:borrowck-readme, r=nikomatsakis
Manishearth Feb 23, 2015
eb06c0e
Rollup merge of #22593 - brson:spatch, r=steveklabnik
Manishearth Feb 23, 2015
26180e9
Rollup merge of #22601 - bombless:patch-1, r=Manishearth
Manishearth Feb 23, 2015
f73457a
Rollup merge of #22612 - jxcl:iter-replace, r=steveklabnik
Manishearth Feb 23, 2015
90d4aaa
Rollup merge of #22613 - nick29581:fix-save-alias, r=huonw
Manishearth Feb 23, 2015
c9c5dd4
Rollup merge of #22643 - fhartwig:bitvec-doc-fix, r=alexcrichton
Manishearth Feb 23, 2015
7d46e04
Rollup merge of #22652 - tigarmo:patch-1, r=Manishearth
Manishearth Feb 23, 2015
f008506
Rollup merge of #22658 - glacjay:issue-22535, r=Gankro
Manishearth Feb 23, 2015
4e73d49
Rollup merge of #22660 - achernya:tuple-reference, r=alexcrichton
Manishearth Feb 23, 2015
2af91c4
Rollup merge of #22662 - iKevinY:readme-changes, r=steveklabnik
Manishearth Feb 23, 2015
8c1606b
Rollup merge of #22670 - shepmaster:c_str_typos, r=Manishearth
Manishearth Feb 23, 2015
07b6b74
Rollup merge of #22674 - untitaker:issue22243, r=alexcrichton
Manishearth Feb 23, 2015
5aee931
Rollup merge of #22691 - nick29581:fix-save-impl, r=huonw
Manishearth Feb 23, 2015
0750cf7
Rollup merge of #22688 - tshepang:use-new-slicing-syntax, r=alexcrichton
Manishearth Feb 23, 2015
b2302a5
Rollup merge of #22693 - tshepang:use-new-slicing-syntax-runtest, r=a…
Manishearth Feb 23, 2015
db04229
Rollup merge of #22696 - stepancheg:use-box, r=alexcrichton
Manishearth Feb 23, 2015
65b1a98
Rollup merge of #22640 - sfackler:fix-take, r=alexcrichton
Manishearth Feb 23, 2015
5a41536
Rollup merge of #22664 - lfairy:just-say-no, r=alexcrichton
Manishearth Feb 23, 2015
8f92150
Rollup merge of #22667 - dotdash:retslot_cast.rs, r=huonw
Manishearth Feb 23, 2015
bff94bd
Rollup merge of #22624 - vadimcn:iss-13361, r=alexcrichton
Manishearth Feb 23, 2015
f1a6d67
Rollup merge of #22544 - bombless:fix-pattern, r=pnkfelix
Manishearth Feb 23, 2015
bf7cde4
Rollup merge of #22538 - nagisa:properise-trans-asserts, r=nikomatsakis
Manishearth Feb 23, 2015
3b4b901
Rollup merge of #22494 - msiemens:vec_map-append-split_off, r=Gankro
Manishearth Feb 23, 2015
3b69d1b
Rollup merge of #22490 - nagisa:inline-args, r=alexcrichton
Manishearth Feb 23, 2015
8487498
Rollup merge of #22320 - petrochenkov:eq, r=alexcrichton
Manishearth Feb 23, 2015
f17a522
Add marker trait to test (fixup #22538)
Manishearth Feb 23, 2015
8eb655b
import boxed for alloc/rc.rs (fixup #22696)
Manishearth Feb 23, 2015
d6d3377
Rollup merge of #22723 - alexcrichton:less-flaky-windows-test, r=alex…
Manishearth Feb 23, 2015
1beaebb
Fix windows failure (fixup #22538)
Manishearth Feb 23, 2015
ee6f2a1
Test fixes and rebase conflicts
alexcrichton Feb 23, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 42 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,34 @@ Read ["Installing Rust"] from [The Book].
## Building from Source

1. Make sure you have installed the dependencies:
* `g++` 4.7 or `clang++` 3.x
* `python` 2.6 or later (but not 3.x)
* GNU `make` 3.81 or later
* `curl`
* `git`

* `g++` 4.7 or `clang++` 3.x
* `python` 2.6 or later (but not 3.x)
* GNU `make` 3.81 or later
* `curl`
* `git`

2. Clone the [source] with `git`:

$ git clone https://github.com/rust-lang/rust.git
$ cd rust
```sh
$ git clone https://github.com/rust-lang/rust.git
$ cd rust
```

[source]: https://github.com/rust-lang/rust

3. Build and install:

$ ./configure
$ make && make install
```sh
$ ./configure
$ make && make install
```

> ***Note:*** You may need to use `sudo make install` if you do not normally have
> permission to modify the destination directory. The install locations can
> be adjusted by passing a `--prefix` argument to `configure`. Various other
> options are also supported, pass `--help` for more information on them.
> ***Note:*** You may need to use `sudo make install` if you do not
> normally have permission to modify the destination directory. The
> install locations can be adjusted by passing a `--prefix` argument
> to `configure`. Various other options are also supported – pass
> `--help` for more information on them.

When complete, `make install` will place several programs into
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
Expand All @@ -47,27 +53,30 @@ Read ["Installing Rust"] from [The Book].

### Building on Windows

To easily build on windows we can use [MSYS2](http://msys2.github.io/):
[MSYS2](http://msys2.github.io/) can be used to easily build Rust on Windows:

1. Grab the latest MSYS2 installer and go through the installer.
2. Now from the MSYS2 terminal we want to install the mingw64 toolchain and the other
tools we need.

```bash
# choose one based on platform
$ pacman -S mingw-w64-i686-toolchain
$ pacman -S mingw-w64-x86_64-toolchain
2. From the MSYS2 terminal, install the `mingw64` toolchain and other required
tools.

```sh
# Choose one based on platform:
$ pacman -S mingw-w64-i686-toolchain
$ pacman -S mingw-w64-x86_64-toolchain

$ pacman -S base-devel
```

$ pacman -S base-devel
```
3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
MYSY2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.

3. With that now start `mingw32_shell.bat` or `mingw64_shell.bat`
from where you installed MSYS2 (i.e. `C:\msys`). Which one you
choose depends on if you want 32 or 64 bit Rust.
4. From there just navigate to where you have Rust's source code, configure and build it:
4. Navigate to Rust's source code, configure and build it:

$ ./configure
$ make && make install
```sh
$ ./configure
$ make && make install
```

## Notes

Expand All @@ -92,15 +101,15 @@ There is more advice about hacking on Rust in [CONTRIBUTING.md].

[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md

## Getting help
## Getting Help

The Rust community congregates in a few places:

* [StackOverflow] - Direct questions about using the language here.
* [users.rust-lang.org] - General discussion, broader questions.
* [Stack Overflow] - Direct questions about using the language.
* [users.rust-lang.org] - General discussion and broader questions.
* [/r/rust] - News and general discussion.

[StackOverflow]: http://stackoverflow.com/questions/tagged/rust
[Stack Overflow]: http://stackoverflow.com/questions/tagged/rust
[/r/rust]: http://reddit.com/r/rust
[users.rust-lang.org]: http://users.rust-lang.org/

Expand All @@ -111,7 +120,7 @@ To contribute to Rust, please see [CONTRIBUTING.md](CONTRIBUTING.md).
Rust has an [IRC] culture and most real-time collaboration happens in a
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
most popular channel is [#rust], a venue for general discussion about
Rust, and a good place to ask for help,
Rust, and a good place to ask for help.

[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
[#rust]: irc://irc.mozilla.org/rust
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
logfile: config.logfile.clone(),
run_tests: true,
run_benchmarks: true,
nocapture: false,
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
color: test::AutoColor,
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::env;

use common::Config;
use common;
use util;
Expand Down Expand Up @@ -125,6 +127,16 @@ pub fn load_props(testfile: &Path) -> TestProps {
true
});

for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
match env::var(key) {
Ok(val) =>
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
exec_env.push((key.to_string(), val))
},
Err(..) => {}
}
}

TestProps {
error_patterns: error_patterns,
compile_flags: compile_flags,
Expand Down
12 changes: 6 additions & 6 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
let proc_res = compile_test(config, props, testfile);

if proc_res.status.success() {
fatal_proc_rec(&format!("{} test compiled successfully!", config.mode)[],
fatal_proc_rec(&format!("{} test compiled successfully!", config.mode)[..],
&proc_res);
}

Expand Down Expand Up @@ -398,7 +398,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
for line in breakpoint_lines.iter() {
script_str.push_str(&format!("break {:?}:{}\n",
testfile.filename_display(),
*line)[]);
*line)[..]);
}
script_str.push_str(&cmds);
script_str.push_str("quit\n");
Expand Down Expand Up @@ -553,17 +553,17 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
script_str.push_str("set print pretty off\n");

// Add the pretty printer directory to GDB's source-file search path
script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)[]);
script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)[..]);

// Load the target executable
script_str.push_str(&format!("file {}\n",
exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
exe_file.as_str().unwrap().replace("\\", "\\\\"))[..]);

// Add line breakpoints
for line in &breakpoint_lines {
script_str.push_str(&format!("break '{}':{}\n",
testfile.filename_display(),
*line)[]);
*line)[..]);
}

script_str.push_str(&cmds);
Expand Down Expand Up @@ -689,7 +689,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
.unwrap()
.to_string();

script_str.push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[..])[]);
script_str.push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[..])[..]);
script_str.push_str("type summary add --no-value ");
script_str.push_str("--python-function lldb_rust_formatters.print_val ");
script_str.push_str("-x \".*\" --category Rust\n");
Expand Down
64 changes: 30 additions & 34 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,39 +426,33 @@ use std::thread::Thread;
fn main() {
let mut numbers = vec![1, 2, 3];

for i in 0..3 {
Thread::spawn(move || {
let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || {
for j in 0..3 { numbers[j] += 1 }
});
}
}).collect();
}
```

It gives us this error:

```text
6:71 error: capture of moved value: `numbers`
for j in 0..3 { numbers[j] += 1 }
^~~~~~~
7:50 note: `numbers` moved into closure environment here
spawn(move || {
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 0..3 { numbers[j] += 1 }
^~~~~~~~~~~~~~~
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || {
8 for j in 0..3 { numbers[j] += 1 }
9 });
```

It mentions that "numbers moved into closure environment". Because we
declared the closure as a moving closure, and it referred to
`numbers`, the closure will try to take ownership of the vector. But
the closure itself is created in a loop, and hence we will actually
create three closures, one for every iteration of the loop. This means
that all three of those closures would try to own `numbers`, which is
impossible -- `numbers` must have just one owner. Rust detects this
and gives us the error: we claim that `numbers` has ownership, but our
code tries to make three owners. This may cause a safety problem, so
Rust disallows it.
It mentions that "captured outer variable in an `FnMut` closure".
Because we declared the closure as a moving closure, and it referred
to `numbers`, the closure will try to take ownership of the
vector. But the closure itself is created in a loop, and hence we will
actually create three closures, one for every iteration of the
loop. This means that all three of those closures would try to own
`numbers`, which is impossible -- `numbers` must have just one
owner. Rust detects this and gives us the error: we claim that
`numbers` has ownership, but our code tries to make three owners. This
may cause a safety problem, so Rust disallows it.

What to do here? Rust has two types that helps us: `Arc<T>` and `Mutex<T>`.
*Arc* stands for "atomically reference counted". In other words, an Arc will
Expand All @@ -480,14 +474,14 @@ use std::sync::{Arc,Mutex};
fn main() {
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));

for i in 0..3 {
let guards: Vec<_> = (0..3).map(|i| {
let number = numbers.clone();
Thread::spawn(move || {
Thread::scoped(move || {
let mut array = number.lock().unwrap();
array[i] += 1;
println!("numbers[{}] is {}", i, array[i]);
});
}
}).collect();
}
```

Expand Down Expand Up @@ -516,8 +510,10 @@ numbers[1] is 3
numbers[0] is 2
```

Each time, we get a slightly different output, because each thread works in a
different order. You may not get the same output as this sample, even.
Each time, we can get a slithtly different output because the threads
are not quaranteed to run in any set order. If you get the same order
every time it is because each of these threads are very small and
complete too fast for their indeterminate behavior to surface.

The important part here is that the Rust compiler was able to use ownership to
give us assurance _at compile time_ that we weren't doing something incorrect
Expand All @@ -539,13 +535,13 @@ safety check that makes this an error about moved values:
use std::thread::Thread;

fn main() {
let vec = vec![1, 2, 3];

for i in 0..3 {
Thread::spawn(move || {
println!("{}", vec[i]);
let numbers = vec![1, 2, 3];
let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || {
println!("{}", numbers[i]);
});
}
}).collect();
}
```

Expand Down
7 changes: 6 additions & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ This last example is different because it is not possible to use the suffix
syntax with a floating point literal ending in a period. `2.f64` would attempt
to call a method named `f64` on `2`.

The representation semantics of floating-point numbers are described in
["Machine Types"](#machine-types).

#### Boolean literals

The two values of the boolean type are written `true` and `false`.
Expand Down Expand Up @@ -3554,7 +3557,8 @@ Tuple types and values are denoted by listing the types or values of their
elements, respectively, in a parenthesized, comma-separated list.

Because tuple elements don't have a name, they can only be accessed by
pattern-matching.
pattern-matching or by using `N` directly as a field to access the
`N`th element.

An example of a tuple type and its use:

Expand All @@ -3563,6 +3567,7 @@ type Pair<'a> = (i32, &'a str);
let p: Pair<'static> = (10, "hello");
let (a, b) = p;
assert!(b != "world");
assert!(p.0 == 10);
```

### Array, and Slice types
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/crates-and-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Rust has two distinct terms that relate to the module system: *crate* and
*module*. A crate is synonymous with a *library* or *package* in other
languages. Hence "Cargo" as the name of Rust's package management tool: you
ship your crates to others with Cargo. Crates can produce an executable or a
shared library, depending on the project.
library, depending on the project.

Each crate has an implicit *root module* that contains the code for that crate.
You can then define a tree of sub-modules under that root module. Modules allow
Expand Down
Loading