Skip to content

Commit 6636af3

Browse files
committed
---
yaml --- r: 209490 b: refs/heads/try c: a52182f h: refs/heads/master v: v3
1 parent 884f285 commit 6636af3

File tree

429 files changed

+4140
-28621
lines changed

Some content is hidden

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

429 files changed

+4140
-28621
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 4f678509649a59daa17dc968b2aeb1023fb23c0f
5+
refs/heads/try: a52182ffdedaabb3b72a11e8a67a411124ecb9ac
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/compiletest/compiletest.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
#![feature(box_syntax)]
1414
#![feature(collections)]
15-
#![feature(old_io)]
1615
#![feature(rustc_private)]
17-
#![feature(unboxed_closures)]
1816
#![feature(std_misc)]
1917
#![feature(test)]
2018
#![feature(path_ext)]
2119
#![feature(str_char)]
20+
#![feature(libc)]
2221

2322
#![deny(warnings)]
2423

24+
extern crate libc;
2525
extern crate test;
2626
extern crate getopts;
2727

@@ -42,6 +42,7 @@ pub mod header;
4242
pub mod runtest;
4343
pub mod common;
4444
pub mod errors;
45+
mod raise_fd_limit;
4546

4647
pub fn main() {
4748
let config = parse_config(env::args().collect());
@@ -245,11 +246,7 @@ pub fn run_tests(config: &Config) {
245246
// sadly osx needs some file descriptor limits raised for running tests in
246247
// parallel (especially when we have lots and lots of child processes).
247248
// For context, see #8904
248-
#[allow(deprecated)]
249-
fn raise_fd_limit() {
250-
std::old_io::test::raise_fd_limit();
251-
}
252-
raise_fd_limit();
249+
unsafe { raise_fd_limit::raise_fd_limit(); }
253250
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
254251
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
255252
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
@@ -371,7 +368,7 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
371368
fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
372369
match full_version_line {
373370
Some(ref full_version_line)
374-
if full_version_line.trim().len() > 0 => {
371+
if !full_version_line.trim().is_empty() => {
375372
let full_version_line = full_version_line.trim();
376373

377374
// used to be a regex "(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)"
@@ -411,7 +408,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
411408

412409
match full_version_line {
413410
Some(ref full_version_line)
414-
if full_version_line.trim().len() > 0 => {
411+
if !full_version_line.trim().is_empty() => {
415412
let full_version_line = full_version_line.trim();
416413

417414
for (pos, l) in full_version_line.char_indices() {
@@ -429,7 +426,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
429426
let vers = full_version_line[pos + 5..].chars().take_while(|c| {
430427
c.is_digit(10)
431428
}).collect::<String>();
432-
if vers.len() > 0 { return Some(vers) }
429+
if !vers.is_empty() { return Some(vers) }
433430
}
434431
println!("Could not extract LLDB version from line '{}'",
435432
full_version_line);
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X
12+
/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256
13+
/// ends up being far too low for our multithreaded scheduler testing, depending
14+
/// on the number of cores available.
15+
///
16+
/// This fixes issue #7772.
17+
#[cfg(any(target_os = "macos", target_os = "ios"))]
18+
#[allow(non_camel_case_types)]
19+
pub unsafe fn raise_fd_limit() {
20+
use libc;
21+
use std::cmp;
22+
use std::io;
23+
use std::mem::size_of_val;
24+
use std::ptr::null_mut;
25+
26+
type rlim_t = libc::uint64_t;
27+
28+
#[repr(C)]
29+
struct rlimit {
30+
rlim_cur: rlim_t,
31+
rlim_max: rlim_t
32+
}
33+
extern {
34+
// name probably doesn't need to be mut, but the C function doesn't
35+
// specify const
36+
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
37+
oldp: *mut libc::c_void, oldlenp: *mut libc::size_t,
38+
newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int;
39+
fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int;
40+
fn setrlimit(resource: libc::c_int, rlp: *const rlimit) -> libc::c_int;
41+
}
42+
static CTL_KERN: libc::c_int = 1;
43+
static KERN_MAXFILESPERPROC: libc::c_int = 29;
44+
static RLIMIT_NOFILE: libc::c_int = 8;
45+
46+
// The strategy here is to fetch the current resource limits, read the
47+
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
48+
// maxfiles up to the sysctl value.
49+
50+
// Fetch the kern.maxfilesperproc value
51+
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
52+
let mut maxfiles: libc::c_int = 0;
53+
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
54+
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
55+
null_mut(), 0) != 0 {
56+
let err = io::Error::last_os_error();
57+
panic!("raise_fd_limit: error calling sysctl: {}", err);
58+
}
59+
60+
// Fetch the current resource limits
61+
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
62+
if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 {
63+
let err = io::Error::last_os_error();
64+
panic!("raise_fd_limit: error calling getrlimit: {}", err);
65+
}
66+
67+
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
68+
// limit
69+
rlim.rlim_cur = cmp::min(maxfiles as rlim_t, rlim.rlim_max);
70+
71+
// Set our newly-increased resource limit
72+
if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {
73+
let err = io::Error::last_os_error();
74+
panic!("raise_fd_limit: error calling setrlimit: {}", err);
75+
}
76+
}
77+
78+
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
79+
pub unsafe fn raise_fd_limit() {}

branches/try/src/compiletest/runtest.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::net::TcpStream;
2929
use std::path::{Path, PathBuf};
3030
use std::process::{Command, Output, ExitStatus};
3131
use std::str;
32-
use std::time::Duration;
3332
use test::MetricMap;
3433

3534
pub fn run(config: Config, testfile: &Path) {
@@ -452,11 +451,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
452451
.expect(&format!("failed to exec `{:?}`", config.adb_path));
453452
loop {
454453
//waiting 1 second for gdbserver start
455-
#[allow(deprecated)]
456-
fn sleep() {
457-
::std::old_io::timer::sleep(Duration::milliseconds(1000));
458-
}
459-
sleep();
454+
::std::thread::sleep_ms(1000);
460455
if TcpStream::connect("127.0.0.1:5039").is_ok() {
461456
break
462457
}
@@ -869,7 +864,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
869864
}
870865
first = false;
871866
}
872-
if !failed && rest.len() == 0 {
867+
if !failed && rest.is_empty() {
873868
i += 1;
874869
}
875870
if i == num_check_lines {
@@ -1667,7 +1662,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
16671662
// codegen tests (vs. clang)
16681663

16691664
fn append_suffix_to_stem(p: &Path, suffix: &str) -> PathBuf {
1670-
if suffix.len() == 0 {
1665+
if suffix.is_empty() {
16711666
p.to_path_buf()
16721667
} else {
16731668
let mut stem = p.file_stem().unwrap().to_os_string();

branches/try/src/doc/index.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Rust, its syntax, and its concepts. Upon completing the book, you'll be an
1515
intermediate Rust developer, and will have a good grasp of the fundamental
1616
ideas behind Rust.
1717

18+
[Rust By Example][rbe] was originally a community resource, but was then
19+
donated to the Rust project. As the name implies, it teaches you Rust through a
20+
series of small examples.
21+
22+
[rbe]: http://rustbyexample.com/
23+
1824
# Community & Getting Help
1925

2026
If you need help with something, or just want to talk about Rust with others,
@@ -76,17 +82,3 @@ We have [API documentation for the entire standard
7682
library](std/index.html). There's a list of crates on the left with more
7783
specific sections, or you can use the search bar at the top to search for
7884
something if you know its name.
79-
80-
# External documentation
81-
82-
*Note: While these are great resources for learning Rust, they may track a
83-
particular version of Rust that is likely not exactly the same as that for
84-
which this documentation was generated.*
85-
86-
* [Rust by Example] - Short examples of common tasks in Rust (tracks the master
87-
branch).
88-
* [Rust for Rubyists] - The first community tutorial for Rust. Tracks the last
89-
stable release. Not just for Ruby programmers.
90-
91-
[Rust by Example]: http://rustbyexample.com/
92-
[Rust for Rubyists]: http://www.rustforrubyists.com/

branches/try/src/doc/intro.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ safe concurrent programs.
389389
Here's an example of a concurrent Rust program:
390390
391391
```{rust}
392+
# #![feature(scoped)]
392393
use std::thread;
393394
394395
fn main() {
@@ -421,6 +422,7 @@ problem.
421422
Let's see an example. This Rust code will not compile:
422423
423424
```{rust,ignore}
425+
# #![feature(scoped)]
424426
use std::thread;
425427
426428
fn main() {
@@ -467,6 +469,7 @@ that our mutation doesn't cause a data race.
467469
Here's what using a Mutex looks like:
468470
469471
```{rust}
472+
# #![feature(scoped)]
470473
use std::thread;
471474
use std::sync::Mutex;
472475
@@ -527,6 +530,7 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
527530
safety check that makes this an error about moved values:
528531
529532
```{rust,ignore}
533+
# #![feature(scoped)]
530534
use std::thread;
531535
532536
fn main() {

branches/try/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3788,7 +3788,7 @@ its type parameters are types:
37883788

37893789
```ignore
37903790
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
3791-
if xs.len() == 0 {
3791+
if xs.is_empty() {
37923792
return vec![];
37933793
}
37943794
let first: B = f(xs[0].clone());

branches/try/src/doc/trpl/comments.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
11
% Comments
22

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

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

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

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

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

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

23-
```{rust}
24-
/// `hello` is a function that prints a greeting that is personalized based on
25-
/// the name given.
26-
///
27-
/// # Arguments
28-
///
29-
/// * `name` - The name of the person you'd like to greet.
23+
```rust
24+
/// Adds one to the number given.
3025
///
3126
/// # Examples
3227
///
33-
/// ```rust
34-
/// let name = "Steve";
35-
/// hello(name); // prints "Hello, Steve!"
3628
/// ```
37-
fn hello(name: &str) {
38-
println!("Hello, {}!", name);
29+
/// let five = 5;
30+
///
31+
/// assert_eq!(6, add_one(5));
32+
/// ```
33+
fn add_one(x: i32) -> i32 {
34+
x + 1
3935
}
4036
```
4137

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

4644
You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation
47-
from these doc comments.
45+
from these doc comments, and also to run the code examples as tests!

0 commit comments

Comments
 (0)