Skip to content

Commit 0834bd1

Browse files
committed
Auto merge of #23548 - Manishearth:rollup, r=Manishearth
2 parents fda8673 + 6107e4c commit 0834bd1

File tree

20 files changed

+89
-70
lines changed

20 files changed

+89
-70
lines changed

Makefile.in

+1-6
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@
9797
# make check-stage1-rpass TESTNAME=my-shiny-new-test
9898
#
9999
# // Having trouble figuring out which test is failing? Turn off parallel tests
100-
# make check-stage1-std RUST_TEST_TASKS=1
101-
#
102-
# This is hardly all there is to know of The Rust Build System's
103-
# mysteries. The tale continues on the wiki[1].
104-
#
105-
# [1]: https://github.com/rust-lang/rust/wiki/Note-testsuite
100+
# make check-stage1-std RUST_TEST_THREADS=1
106101
#
107102
# If you really feel like getting your hands dirty, then:
108103
#

man/rustc.1

+22
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,28 @@ full debug info with variable and type information.
242242
\fBopt\-level\fR=\fIVAL\fR
243243
Optimize with possible levels 0\[en]3
244244

245+
.SH ENVIRONMENT VARIABLES
246+
247+
Some of these affect the output of the compiler, while others affect programs
248+
which link to the standard library.
249+
250+
.TP
251+
\fBRUST_TEST_THREADS\fR
252+
The test framework Rust provides executes tests in parallel. This variable sets
253+
the maximum number of threads used for this purpose.
254+
255+
.TP
256+
\fBRUST_TEST_NOCAPTURE\fR
257+
A synonym for the --nocapture flag.
258+
259+
.TP
260+
\fBRUST_MIN_STACK\fR
261+
Sets the minimum stack size for new threads.
262+
263+
.TP
264+
\fBRUST_BACKTRACE\fR
265+
If set, produces a backtrace in the output of a program which panics.
266+
245267
.SH "EXAMPLES"
246268
To build an executable from a source file with a main function:
247269
$ rustc \-o hello hello.rs

src/compiletest/compiletest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ pub fn run_tests(config: &Config) {
224224
// android debug-info test uses remote debugger
225225
// so, we test 1 task at once.
226226
// also trying to isolate problems with adb_run_wrapper.sh ilooping
227-
env::set_var("RUST_TEST_TASKS","1");
227+
env::set_var("RUST_TEST_THREADS","1");
228228
}
229229

230230
match config.mode {
231231
DebugInfoLldb => {
232232
// Some older versions of LLDB seem to have problems with multiple
233233
// instances running in parallel, so only run one test task at a
234234
// time.
235-
env::set_var("RUST_TEST_TASKS", "1");
235+
env::set_var("RUST_TEST_THREADS", "1");
236236
}
237237
_ => { /* proceed */ }
238238
}

src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
131131
true
132132
});
133133

134-
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
134+
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
135135
match env::var(key) {
136136
Ok(val) =>
137137
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {

src/doc/trpl/ffi.md

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Foreign libraries often hand off ownership of resources to the calling code.
170170
When this occurs, we must use Rust's destructors to provide safety and guarantee
171171
the release of these resources (especially in the case of panic).
172172

173+
For more about destructors, see the [Drop trait](../std/ops/trait.Drop.html).
174+
173175
# Callbacks from C code to Rust functions
174176

175177
Some external libraries require the usage of callbacks to report back their

src/doc/trpl/pointers.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -561,38 +561,40 @@ fn main() {
561561
In this case, Rust knows that `x` is being *borrowed* by the `add_one()`
562562
function, and since it's only reading the value, allows it.
563563

564-
We can borrow `x` multiple times, as long as it's not simultaneous:
564+
We can borrow `x` as read-only multiple times, even simultaneously:
565565

566566
```{rust}
567-
fn add_one(x: &i32) -> i32 {
568-
*x + 1
567+
fn add(x: &i32, y: &i32) -> i32 {
568+
*x + *y
569569
}
570570
571571
fn main() {
572572
let x = Box::new(5);
573573
574-
println!("{}", add_one(&*x));
575-
println!("{}", add_one(&*x));
576-
println!("{}", add_one(&*x));
574+
println!("{}", add(&x, &x));
575+
println!("{}", add(&x, &x));
577576
}
578577
```
579578

580-
Or as long as it's not a mutable borrow. This will error:
579+
We can mutably borrow `x` multiple times, but only if x itself is mutable, and
580+
it may not be *simultaneously* borrowed:
581581

582582
```{rust,ignore}
583-
fn add_one(x: &mut i32) -> i32 {
584-
*x + 1
583+
fn increment(x: &mut i32) {
584+
*x += 1;
585585
}
586586
587587
fn main() {
588-
let x = Box::new(5);
588+
// If variable x is not "mut", this will not compile
589+
let mut x = Box::new(5);
589590
590-
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
591-
// of `&`-pointer as mutable
591+
increment(&mut x);
592+
increment(&mut x);
593+
println!("{}", x);
592594
}
593595
```
594596

595-
Notice we changed the signature of `add_one()` to request a mutable reference.
597+
Notice the signature of `increment()` requests a mutable reference.
596598

597599
## Best practices
598600

src/doc/trpl/unsafe.md

-4
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ offered by the Rust language and libraries. For example, they
9393
- are plain-old-data, that is, they don't move ownership, again unlike
9494
`Box`, hence the Rust compiler cannot protect against bugs like
9595
use-after-free;
96-
- are considered sendable (if their contents is considered sendable),
97-
so the compiler offers no assistance with ensuring their use is
98-
thread-safe; for example, one can concurrently access a `*mut i32`
99-
from two threads without synchronization.
10096
- lack any form of lifetimes, unlike `&`, and so the compiler cannot
10197
reason about dangling pointers; and
10298
- have no guarantees about aliasing or mutability other than mutation

src/libstd/fs/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ pub struct Metadata(fs_imp::FileAttr);
7373
/// will yield instances of `io::Result<DirEntry>`. Through a `DirEntry`
7474
/// information like the entry's path and possibly other metadata can be
7575
/// learned.
76+
///
77+
/// # Failure
78+
///
79+
/// This `io::Result` will be an `Err` if there's some sort of intermittent
80+
/// IO error during iteration.
7681
#[stable(feature = "rust1", since = "1.0.0")]
7782
pub struct ReadDir(fs_imp::ReadDir);
7883

src/libstd/io/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,8 @@ pub trait BufRead: Read {
584584
read_until(self, byte, buf)
585585
}
586586

587-
/// Read all bytes until a newline byte (the 0xA byte) is reached.
587+
/// Read all bytes until a newline byte (the 0xA byte) is reached, and
588+
/// append them to the provided buffer.
588589
///
589590
/// This function will continue to read (and buffer) bytes from the
590591
/// underlying stream until the newline delimiter (the 0xA byte) or EOF is

src/libstd/num/f32.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ impl Float for f32 {
191191
/// Constructs a floating point number by multiplying `x` by 2 raised to the
192192
/// power of `exp`
193193
#[inline]
194-
fn ldexp(x: f32, exp: int) -> f32 {
195-
unsafe { cmath::ldexpf(x, exp as c_int) }
194+
fn ldexp(self, exp: isize) -> f32 {
195+
unsafe { cmath::ldexpf(self, exp as c_int) }
196196
}
197197

198198
/// Breaks the number into a normalized fraction and a base-2 exponent,
@@ -2207,8 +2207,8 @@ mod tests {
22072207
let f1: f32 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
22082208
let f2: f32 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
22092209
let f3: f32 = FromStrRadix::from_str_radix("1.Cp-12", 16).unwrap();
2210-
assert_eq!(Float::ldexp(1f32, -123), f1);
2211-
assert_eq!(Float::ldexp(1f32, -111), f2);
2210+
assert_eq!(1f32.ldexp(-123), f1);
2211+
assert_eq!(1f32.ldexp(-111), f2);
22122212
assert_eq!(Float::ldexp(1.75f32, -12), f3);
22132213

22142214
assert_eq!(Float::ldexp(0f32, -123), 0f32);

src/libstd/num/f64.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ impl Float for f64 {
200200
fn to_radians(self) -> f64 { num::Float::to_radians(self) }
201201

202202
#[inline]
203-
fn ldexp(x: f64, exp: int) -> f64 {
204-
unsafe { cmath::ldexp(x, exp as c_int) }
203+
fn ldexp(self, exp: isize) -> f64 {
204+
unsafe { cmath::ldexp(self, exp as c_int) }
205205
}
206206

207207
/// Breaks the number into a normalized fraction and a base-2 exponent,
@@ -2214,8 +2214,8 @@ mod tests {
22142214
let f1: f64 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
22152215
let f2: f64 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
22162216
let f3: f64 = FromStrRadix::from_str_radix("1.Cp-12", 16).unwrap();
2217-
assert_eq!(Float::ldexp(1f64, -123), f1);
2218-
assert_eq!(Float::ldexp(1f64, -111), f2);
2217+
assert_eq!(1f64.ldexp(-123), f1);
2218+
assert_eq!(1f64.ldexp(-111), f2);
22192219
assert_eq!(Float::ldexp(1.75f64, -12), f3);
22202220

22212221
assert_eq!(Float::ldexp(0f64, -123), 0f64);

src/libstd/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ pub trait Float
699699
/// ```
700700
#[unstable(feature = "std_misc",
701701
reason = "pending integer conventions")]
702-
fn ldexp(x: Self, exp: isize) -> Self;
702+
fn ldexp(self, exp: isize) -> Self;
703703
/// Breaks the number into a normalized fraction and a base-2 exponent,
704704
/// satisfying:
705705
///

src/libstd/rt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use thunk::Thunk;
3030
use usize;
3131

3232
// Reexport some of our utilities which are expected by other crates.
33-
pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
33+
pub use self::util::{min_stack, running_on_valgrind};
3434
pub use self::unwind::{begin_unwind, begin_unwind_fmt};
3535

3636
// Reexport some functionality from liballoc.

src/libstd/rt/util.rs

-23
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,6 @@ pub fn min_stack() -> uint {
5858
return amt;
5959
}
6060

61-
/// Get's the number of scheduler threads requested by the environment
62-
/// either `RUST_THREADS` or `num_cpus`.
63-
#[allow(deprecated)]
64-
pub fn default_sched_threads() -> uint {
65-
use os;
66-
match env::var("RUST_THREADS") {
67-
Ok(nstr) => {
68-
let opt_n: Option<uint> = nstr.parse().ok();
69-
match opt_n {
70-
Some(n) if n > 0 => n,
71-
_ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr)
72-
}
73-
}
74-
Err(..) => {
75-
if limit_thread_creation_due_to_osx_and_valgrind() {
76-
1
77-
} else {
78-
os::num_cpus()
79-
}
80-
}
81-
}
82-
}
83-
8461
// Indicates whether we should perform expensive sanity checks, including rtassert!
8562
//
8663
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert,

src/libsyntax/ext/quote.rs

+4
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ pub mod rt {
176176
impl_to_source! { ast::Arg, arg_to_string }
177177
impl_to_source! { Generics, generics_to_string }
178178
impl_to_source! { P<ast::Item>, item_to_string }
179+
impl_to_source! { P<ast::ImplItem>, impl_item_to_string }
180+
impl_to_source! { P<ast::TraitItem>, trait_item_to_string }
179181
impl_to_source! { P<ast::Stmt>, stmt_to_string }
180182
impl_to_source! { P<ast::Expr>, expr_to_string }
181183
impl_to_source! { P<ast::Pat>, pat_to_string }
@@ -308,6 +310,8 @@ pub mod rt {
308310

309311
impl_to_tokens! { ast::Ident }
310312
impl_to_tokens! { P<ast::Item> }
313+
impl_to_tokens! { P<ast::ImplItem> }
314+
impl_to_tokens! { P<ast::TraitItem> }
311315
impl_to_tokens! { P<ast::Pat> }
312316
impl_to_tokens! { ast::Arm }
313317
impl_to_tokens_lifetime! { &'a [P<ast::Item>] }

src/libsyntax/print/pprust.rs

+8
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ pub fn item_to_string(i: &ast::Item) -> String {
355355
$to_string(|s| s.print_item(i))
356356
}
357357

358+
pub fn impl_item_to_string(i: &ast::ImplItem) -> String {
359+
$to_string(|s| s.print_impl_item(i))
360+
}
361+
362+
pub fn trait_item_to_string(i: &ast::TraitItem) -> String {
363+
$to_string(|s| s.print_trait_item(i))
364+
}
365+
358366
pub fn generics_to_string(generics: &ast::Generics) -> String {
359367
$to_string(|s| s.print_generics(generics))
360368
}

src/libtest/lib.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#![feature(std_misc)]
4545
#![feature(libc)]
4646
#![feature(set_stdio)]
47+
#![feature(os)]
4748

4849
extern crate getopts;
4950
extern crate serialize;
@@ -338,7 +339,7 @@ The FILTER regex is tested against the name of all tests to run, and
338339
only those tests that match are run.
339340
340341
By default, all tests are run in parallel. This can be altered with the
341-
RUST_TEST_TASKS environment variable when running tests (set it to 1).
342+
RUST_TEST_THRADS environment variable when running tests (set it to 1).
342343
343344
All tests have their standard output and standard error captured by default.
344345
This can be overridden with the --nocapture flag or the RUST_TEST_NOCAPTURE=1
@@ -841,18 +842,22 @@ fn run_tests<F>(opts: &TestOpts,
841842
Ok(())
842843
}
843844

845+
#[allow(deprecated)]
844846
fn get_concurrency() -> uint {
845-
use std::rt;
846-
match env::var("RUST_TEST_TASKS") {
847+
match env::var("RUST_TEST_THREADS") {
847848
Ok(s) => {
848849
let opt_n: Option<uint> = s.parse().ok();
849850
match opt_n {
850851
Some(n) if n > 0 => n,
851-
_ => panic!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s)
852+
_ => panic!("RUST_TEST_THREADS is `{}`, should be a positive integer.", s)
852853
}
853854
}
854855
Err(..) => {
855-
rt::default_sched_threads()
856+
if std::rt::util::limit_thread_creation_due_to_osx_and_valgrind() {
857+
1
858+
} else {
859+
std::os::num_cpus()
860+
}
856861
}
857862
}
858863
}

src/libunicode/char.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ impl CharExt for char {
462462
}
463463

464464
/// An iterator over the lowercase mapping of a given character, returned from
465-
/// the `lowercase` method on characters.
465+
/// the [`to_lowercase` method](../primitive.char.html#method.to_lowercase) on
466+
/// characters.
466467
#[stable(feature = "rust1", since = "1.0.0")]
467468
pub struct ToLowercase(Option<char>);
468469

@@ -473,7 +474,8 @@ impl Iterator for ToLowercase {
473474
}
474475

475476
/// An iterator over the uppercase mapping of a given character, returned from
476-
/// the `uppercase` method on characters.
477+
/// the [`to_uppercase` method](../primitive.char.html#method.to_uppercase) on
478+
/// characters.
477479
#[stable(feature = "rust1", since = "1.0.0")]
478480
pub struct ToUppercase(Option<char>);
479481

src/test/run-fail/test-tasks-invalid-value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// This checks that RUST_TEST_TASKS not being 1, 2, ... is detected
11+
// This checks that RUST_TEST_THREADS not being 1, 2, ... is detected
1212
// properly.
1313

1414
// error-pattern:should be a positive integer
1515
// compile-flags: --test
16-
// exec-env:RUST_TEST_TASKS=foo
16+
// exec-env:RUST_TEST_THREADS=foo
1717
// ignore-pretty: does not work well with `--test`
1818

1919
#[test]

src/test/run-pass/tcp-connect-timeouts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-pretty
1212
// compile-flags:--test
13-
// exec-env:RUST_TEST_TASKS=1
13+
// exec-env:RUST_TEST_THREADS=1
1414

1515
// Tests for the connect_timeout() function on a TcpStream. This runs with only
1616
// one test task to ensure that errors are timeouts, not file descriptor

0 commit comments

Comments
 (0)