Skip to content

Rolling up PRs in the queue #24433

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 68 commits into from
Apr 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1a28237
Alter libcore::result example to utilize closure param
frewsxcv Apr 6, 2015
734bdc6
copyedits: functions
steveklabnik Apr 10, 2015
2b38819
copyedits: documentation
steveklabnik Apr 10, 2015
f1515fa
Add Default trait for AtomicBool, AtomicIsize and AtomicUsize
GuillaumeGomez Apr 10, 2015
f329030
std: Stabilize the Utf8Error type
alexcrichton Apr 10, 2015
912a872
Fixed with_extension documentation bug
tbelaire Apr 12, 2015
12d21bf
References to `CString::from_vec` changed to `new`
tbelaire Apr 12, 2015
219f61b
Make Debug include the - in -0.0
Apr 12, 2015
cef96b9
rustdoc: Prevent '/' from showing the help dialog
barosl Apr 11, 2015
c3c83bf
Arity link has moved to primitive-types.md.
Apr 13, 2015
e891f29
Fix ICE when returning a variable whose declaration is unreachable
dotdash Apr 13, 2015
6f54ce9
added _SC_NPROCESSORS_ONLN constants for linux and macos for fix #24374
oh-its-jimjam Apr 13, 2015
883bb65
remove duplicated linux sysconf mod
oh-its-jimjam Apr 13, 2015
39543e9
Don't try to suggest fields of an enum
arielb1 Apr 13, 2015
951db77
syntax: Publically expose printing where clauses, and add attr_to_string
erickt Apr 13, 2015
6fa16d6
pluralize doc comment verbs and add missing periods
apasel422 Apr 13, 2015
6399bb4
De-stabilize `thread::scoped` and friends
aturon Apr 13, 2015
f60f4b7
Fix check for globally routable IPv4 address
Apr 12, 2015
32f7e67
Refine read_to_end documentation
nagisa Apr 13, 2015
6e0fb70
Generalize `spawn` beyond unit closures
aturon Apr 13, 2015
01678ac
Expose visibility for fns in syntax::visit
nrc Apr 13, 2015
57e3475
Update vectors.md
Apr 13, 2015
8a65029
Link RBE more prominently
steveklabnik Apr 13, 2015
00867b3
Fix up nightly installation instructions.
steveklabnik Apr 14, 2015
942c97b
Make use of the stability attributes issue a deprecation warning. #22830
brson Apr 14, 2015
ab93a51
Point to From trait in error handling guide
fenduru Apr 14, 2015
a9fd41e
Fallout: move from scoped to spawn
aturon Apr 13, 2015
8b6987a
copyediting: structs
steveklabnik Apr 10, 2015
bf4e77d
std: Remove old_io/old_path/rand modules
alexcrichton Apr 10, 2015
359ab0b
rustc_back: Rewrite realpath to not use old_io
alexcrichton Apr 10, 2015
0516c40
std: Reexport some unstable rand functionality for now
alexcrichton Apr 10, 2015
84a89ed
compiletest: Re-add raise_fd_limit
alexcrichton Apr 10, 2015
adcd672
test: Fix fallout in run-pass tests
alexcrichton Apr 10, 2015
dddfbe0
syntax: Remove derive(Rand)
alexcrichton Apr 10, 2015
700e627
test: Fixup many library unit tests
alexcrichton Apr 10, 2015
b53319a
rand: Delete all doc tests
alexcrichton Apr 10, 2015
8f7eb3b
core: Update all Result docs
alexcrichton Apr 10, 2015
33fb5bb
bench: Fix fallout in benchmarks
alexcrichton Apr 10, 2015
9cd8a5a
std: Remove AsSlice/Str from the prelude
alexcrichton Apr 10, 2015
b8760af
More test fixes
alexcrichton Apr 10, 2015
6476a1e
mutability fixes
steveklabnik Apr 14, 2015
fb956dc
rollup merge of #24048: frewsxcv/patch-11
alexcrichton Apr 14, 2015
330466e
rollup merge of #24273: steveklabnik/even_moar_editing
alexcrichton Apr 14, 2015
88a145e
rollup merge of #24303: alexcrichton/remove-deprecated
alexcrichton Apr 14, 2015
34603b0
rollup merge of #24310: alexcrichton/stabilize-utf8-error
alexcrichton Apr 14, 2015
1c7ade9
rollup merge of #24329: GuillaumeGomez/atomicbool
alexcrichton Apr 14, 2015
5780fc1
rollup merge of #24337: barosl/rustdoc-help-key
alexcrichton Apr 14, 2015
e8ca9a6
rollup merge of #24342: tbelaire/patch-1
alexcrichton Apr 14, 2015
9f7b6cb
rollup merge of #24343: achanda/global_ip
alexcrichton Apr 14, 2015
83d79c6
rollup merge of #24350: tbelaire/cstring-doc-from-vec
alexcrichton Apr 14, 2015
db79ce0
rollup merge of #24368: kgv/fix
alexcrichton Apr 14, 2015
c24e55b
rollup merge of #24371: dotdash/24353
alexcrichton Apr 14, 2015
263314e
rollup merge of #24376: lambdaburrito/master
alexcrichton Apr 14, 2015
2795811
rollup merge of #24379: rkruppe/fmt-negative-zero
alexcrichton Apr 14, 2015
38c9e0f
rollup merge of #24380: arielb1/no-enum-suggest
alexcrichton Apr 14, 2015
52067fd
rollup merge of #24381: erickt/cleanup
alexcrichton Apr 14, 2015
d10be64
rollup merge of #24386: nagisa/rte-fix
alexcrichton Apr 14, 2015
d7ff4f5
rollup merge of #24391: nrc/visit-vis
alexcrichton Apr 14, 2015
ecbbbfa
rollup merge of #24393: steveklabnik/rbe
alexcrichton Apr 14, 2015
cf53ae0
rollup merge of #24394: rundrop1/patch-1
alexcrichton Apr 14, 2015
84e4a72
rollup merge of #24398: steveklabnik/thanks_mdinger
alexcrichton Apr 14, 2015
33733b7
rollup merge of #24399: brson/stab
alexcrichton Apr 14, 2015
7913f56
rollup merge of #24401: fenduru/patch-2
alexcrichton Apr 14, 2015
ae7959d
rollup merge of #24377: apasel422/docs
alexcrichton Apr 14, 2015
b9d9a37
rollup merge of #24385: aturon/unstable-scoped
alexcrichton Apr 14, 2015
30425bf
Test fixes and rebase conflicts
alexcrichton Apr 14, 2015
d3da5a7
Merge remote-tracking branch 'origin/master' into rollup
alexcrichton Apr 14, 2015
e053571
Test fixes and rebase conflicts, round 2
alexcrichton Apr 14, 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
11 changes: 4 additions & 7 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

#![feature(box_syntax)]
#![feature(collections)]
#![feature(old_io)]
#![feature(rustc_private)]
#![feature(unboxed_closures)]
#![feature(std_misc)]
#![feature(test)]
#![feature(path_ext)]
#![feature(str_char)]
#![feature(libc)]

#![deny(warnings)]

extern crate libc;
extern crate test;
extern crate getopts;

Expand All @@ -42,6 +42,7 @@ pub mod header;
pub mod runtest;
pub mod common;
pub mod errors;
mod raise_fd_limit;

pub fn main() {
let config = parse_config(env::args().collect());
Expand Down Expand Up @@ -245,11 +246,7 @@ pub fn run_tests(config: &Config) {
// sadly osx needs some file descriptor limits raised for running tests in
// parallel (especially when we have lots and lots of child processes).
// For context, see #8904
#[allow(deprecated)]
fn raise_fd_limit() {
std::old_io::test::raise_fd_limit();
}
raise_fd_limit();
unsafe { raise_fd_limit::raise_fd_limit(); }
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
Expand Down
79 changes: 79 additions & 0 deletions src/compiletest/raise_fd_limit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X
/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256
/// ends up being far too low for our multithreaded scheduler testing, depending
/// on the number of cores available.
///
/// This fixes issue #7772.
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[allow(non_camel_case_types)]
pub unsafe fn raise_fd_limit() {
use libc;
use std::cmp;
use std::io;
use std::mem::size_of_val;
use std::ptr::null_mut;

type rlim_t = libc::uint64_t;

#[repr(C)]
struct rlimit {
rlim_cur: rlim_t,
rlim_max: rlim_t
}
extern {
// name probably doesn't need to be mut, but the C function doesn't
// specify const
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
oldp: *mut libc::c_void, oldlenp: *mut libc::size_t,
newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int;
fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int;
fn setrlimit(resource: libc::c_int, rlp: *const rlimit) -> libc::c_int;
}
static CTL_KERN: libc::c_int = 1;
static KERN_MAXFILESPERPROC: libc::c_int = 29;
static RLIMIT_NOFILE: libc::c_int = 8;

// The strategy here is to fetch the current resource limits, read the
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
// maxfiles up to the sysctl value.

// Fetch the kern.maxfilesperproc value
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
let mut maxfiles: libc::c_int = 0;
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
null_mut(), 0) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling sysctl: {}", err);
}

// Fetch the current resource limits
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling getrlimit: {}", err);
}

// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
// limit
rlim.rlim_cur = cmp::min(maxfiles as rlim_t, rlim.rlim_max);

// Set our newly-increased resource limit
if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {
let err = io::Error::last_os_error();
panic!("raise_fd_limit: error calling setrlimit: {}", err);
}
}

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
pub unsafe fn raise_fd_limit() {}
7 changes: 1 addition & 6 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use std::net::TcpStream;
use std::path::{Path, PathBuf};
use std::process::{Command, Output, ExitStatus};
use std::str;
use std::time::Duration;
use test::MetricMap;

pub fn run(config: Config, testfile: &Path) {
Expand Down Expand Up @@ -452,11 +451,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
.expect(&format!("failed to exec `{:?}`", config.adb_path));
loop {
//waiting 1 second for gdbserver start
#[allow(deprecated)]
fn sleep() {
::std::old_io::timer::sleep(Duration::milliseconds(1000));
}
sleep();
::std::thread::sleep_ms(1000);
if TcpStream::connect("127.0.0.1:5039").is_ok() {
break
}
Expand Down
20 changes: 6 additions & 14 deletions src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Rust, its syntax, and its concepts. Upon completing the book, you'll be an
intermediate Rust developer, and will have a good grasp of the fundamental
ideas behind Rust.

[Rust By Example][rbe] was originally a community resource, but was then
donated to the Rust project. As the name implies, it teaches you Rust through a
series of small examples.

[rbe]: rustbyexample.com

# Community & Getting Help

If you need help with something, or just want to talk about Rust with others,
Expand Down Expand Up @@ -76,17 +82,3 @@ We have [API documentation for the entire standard
library](std/index.html). There's a list of crates on the left with more
specific sections, or you can use the search bar at the top to search for
something if you know its name.

# External documentation

*Note: While these are great resources for learning Rust, they may track a
particular version of Rust that is likely not exactly the same as that for
which this documentation was generated.*

* [Rust by Example] - Short examples of common tasks in Rust (tracks the master
branch).
* [Rust for Rubyists] - The first community tutorial for Rust. Tracks the last
stable release. Not just for Ruby programmers.

[Rust by Example]: http://rustbyexample.com/
[Rust for Rubyists]: http://www.rustforrubyists.com/
4 changes: 4 additions & 0 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ safe concurrent programs.
Here's an example of a concurrent Rust program:

```{rust}
# #![feature(scoped)]
use std::thread;

fn main() {
Expand Down Expand Up @@ -421,6 +422,7 @@ problem.
Let's see an example. This Rust code will not compile:

```{rust,ignore}
# #![feature(scoped)]
use std::thread;

fn main() {
Expand Down Expand Up @@ -467,6 +469,7 @@ that our mutation doesn't cause a data race.
Here's what using a Mutex looks like:

```{rust}
# #![feature(scoped)]
use std::thread;
use std::sync::Mutex;

Expand Down Expand Up @@ -527,6 +530,7 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
safety check that makes this an error about moved values:

```{rust,ignore}
# #![feature(scoped)]
use std::thread;

fn main() {
Expand Down
38 changes: 18 additions & 20 deletions src/doc/trpl/comments.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
% Comments

Now that we have some functions, it's a good idea to learn about comments.
Now that we have some functions, its a good idea to learn about comments.
Comments are notes that you leave to other programmers to help explain things
about your code. The compiler mostly ignores them.

Rust has two kinds of comments that you should care about: *line comments*
and *doc comments*.

```{rust}
// Line comments are anything after '//' and extend to the end of the line.
```rust
// Line comments are anything after ‘//’ and extend to the end of the line.

let x = 5; // this is also a line comment.

// If you have a long explanation for something, you can put line comments next
// to each other. Put a space between the // and your comment so that it's
// to each other. Put a space between the // and your comment so that its
// more readable.
```

The other kind of comment is a doc comment. Doc comments use `///` instead of
`//`, and support Markdown notation inside:

```{rust}
/// `hello` is a function that prints a greeting that is personalized based on
/// the name given.
///
/// # Arguments
///
/// * `name` - The name of the person you'd like to greet.
```rust
/// Adds one to the number given.
///
/// # Examples
///
/// ```rust
/// let name = "Steve";
/// hello(name); // prints "Hello, Steve!"
/// ```
fn hello(name: &str) {
println!("Hello, {}!", name);
/// let five = 5;
///
/// assert_eq!(6, add_one(5));
/// ```
fn add_one(x: i32) -> i32 {
x + 1
}
```

When writing doc comments, adding sections for any arguments, return values,
and providing some examples of usage is very, very helpful. Don't worry about
the `&str`, we'll get to it soon.
When writing doc comments, providing some examples of usage is very, very
helpful. You’ll notice we’ve used a new macro here: `assert_eq!`. This compares
two values, and `panic!`s if they’re not equal to each other. It’s very helpful
in documentation. There’s another macro, `assert!`, which `panic!`s if the
value passed to it is `false`.

You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation
from these doc comments.
from these doc comments, and also to run the code examples as tests!
49 changes: 8 additions & 41 deletions src/doc/trpl/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,68 +56,35 @@ place!

## Threads

Rust's standard library provides a library for 'threads', which allow you to
Rust's standard library provides a library for threads, which allow you to
run Rust code in parallel. Here's a basic example of using `std::thread`:

```
use std::thread;

fn main() {
thread::scoped(|| {
thread::spawn(|| {
println!("Hello from a thread!");
});
}
```

The `thread::scoped()` method accepts a closure, which is executed in a new
thread. It's called `scoped` because this thread returns a join guard:
The `thread::spawn()` method accepts a closure, which is executed in a
new thread. It returns a handle to the thread, that can be used to
wait for the child thread to finish and extract its result:

```
use std::thread;

fn main() {
let guard = thread::scoped(|| {
println!("Hello from a thread!");
let handle = thread::spawn(|| {
"Hello from a thread!"
});

// guard goes out of scope here
println!("{}", handle.join().unwrap());
}
```

When `guard` goes out of scope, it will block execution until the thread is
finished. If we didn't want this behaviour, we could use `thread::spawn()`:

```
use std::thread;

fn main() {
thread::spawn(|| {
println!("Hello from a thread!");
});

thread::sleep_ms(50);
}
```

We need to `sleep` here because when `main()` ends, it kills all of the
running threads.

[`scoped`](std/thread/struct.Builder.html#method.scoped) has an interesting
type signature:

```text
fn scoped<'a, T, F>(self, f: F) -> JoinGuard<'a, T>
where T: Send + 'a,
F: FnOnce() -> T,
F: Send + 'a
```

Specifically, `F`, the closure that we pass to execute in the new thread. It
has two restrictions: It must be a `FnOnce` from `()` to `T`. Using `FnOnce`
allows the closure to take ownership of any data it mentions from the parent
thread. The other restriction is that `F` must be `Send`. We aren't allowed to
transfer this ownership unless the type thinks that's okay.

Many languages have the ability to execute threads, but it's wildly unsafe.
There are entire books about how to prevent errors that occur from shared
mutable state. Rust helps out with its type system here as well, by preventing
Expand Down
2 changes: 0 additions & 2 deletions src/doc/trpl/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,5 @@ matching, a tool that will let us deconstruct sum types (the type theory term
for enums) like `Ordering` in a very elegant way that avoids all these messy
and brittle `if`/`else`s.


[arity]: ./glossary.html#arity
[match]: ./match.html
[generics]: ./generics.html
2 changes: 1 addition & 1 deletion src/doc/trpl/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,5 @@ It's worth noting that you can only use `try!` from a function that returns a
`Result`, which means that you cannot use `try!` inside of `main()`, because
`main()` doesn't return anything.

`try!` makes use of [`FromError`](../std/error/#the-fromerror-trait) to determine
`try!` makes use of [`From<Error>`](../std/convert/trait.From.hml) to determine
what to return in the error case.
Loading