Skip to content

Commit 665ea96

Browse files
committed
Test fixes and rebase conflicts
1 parent ba8ce4c commit 665ea96

File tree

18 files changed

+65
-64
lines changed

18 files changed

+65
-64
lines changed

src/doc/trpl/traits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ trait ConvertTo<Output> {
343343
}
344344
345345
impl ConvertTo<i64> for i32 {
346-
fn convert(&self) -> i64 { *self as i32 }
346+
fn convert(&self) -> i64 { *self as i64 }
347347
}
348348
349349
// can be called with T == i32

src/libcollections/ring_buf.rs

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

11-
//! RingBuf is a double-ended queue, which is implemented with the help of a growing circular buffer.
11+
//! RingBuf is a double-ended queue, which is implemented with the help of a
12+
//! growing circular buffer.
1213
//!
13-
//! This queue has `O(1)` amortized inserts and removals from both ends of the container. It also
14-
//! has `O(1)` indexing like a vector. The contained elements are not required to be copyable, and
15-
//! the queue will be sendable if the contained type is sendable.
14+
//! This queue has `O(1)` amortized inserts and removals from both ends of the
15+
//! container. It also has `O(1)` indexing like a vector. The contained elements
16+
//! are not required to be copyable, and the queue will be sendable if the
17+
//! contained type is sendable.
1618
1719
#![stable(feature = "rust1", since = "1.0.0")]
1820

@@ -115,7 +117,8 @@ impl<T> RingBuf<T> {
115117
#[inline]
116118
fn is_full(&self) -> bool { self.cap - self.len() == 1 }
117119

118-
/// Returns the index in the underlying buffer for a given logical element index.
120+
/// Returns the index in the underlying buffer for a given logical element
121+
/// index.
119122
#[inline]
120123
fn wrap_index(&self, idx: usize) -> usize { wrap_index(idx, self.cap) }
121124

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) ->
764764
///
765765
/// The diagnostic emitter yielded to the procedure should be used for reporting
766766
/// errors of the compiler.
767-
pub fn monitor<F:FnOnce()+Send>(f: F) {
767+
pub fn monitor<F:FnOnce()+Send+'static>(f: F) {
768768
static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
769769

770770
let (tx, rx) = channel();

src/libstd/old_io/comm_adapters.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ mod test {
234234
writer.write_be_u32(42).unwrap();
235235

236236
let wanted = vec![0u8, 0u8, 0u8, 42u8];
237-
let got = match thread::spawn(move|| { rx.recv().unwrap() }).join() {
238-
Ok(got) => got,
239-
Err(_) => panic!(),
240-
};
237+
let got = thread::scoped(move|| { rx.recv().unwrap() }).join();
241238
assert_eq!(wanted, got);
242239

243240
match writer.write_u8(1) {

src/libstd/old_path/posix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ mod tests {
520520
fn test_null_byte() {
521521
use thread;
522522
let result = thread::spawn(move|| {
523-
Path::new(b"foo/bar\0")
523+
Path::new(b"foo/bar\0");
524524
}).join();
525525
assert!(result.is_err());
526526

src/libstd/old_path/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ mod tests {
13071307
fn test_null_byte() {
13081308
use thread;
13091309
let result = thread::spawn(move|| {
1310-
Path::new(b"foo/bar\0")
1310+
Path::new(b"foo/bar\0");
13111311
}).join();
13121312
assert!(result.is_err());
13131313

src/libstd/sync/rwlock.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ mod tests {
425425
#[test]
426426
fn frob() {
427427
static R: StaticRwLock = RW_LOCK_INIT;
428-
static N: uint = 10;
429-
static M: uint = 1000;
428+
static N: usize = 10;
429+
static M: usize = 1000;
430430

431431
let (tx, rx) = channel::<()>();
432432
for _ in 0..N {
@@ -452,7 +452,7 @@ mod tests {
452452
fn test_rw_arc_poison_wr() {
453453
let arc = Arc::new(RwLock::new(1));
454454
let arc2 = arc.clone();
455-
let _: Result<uint, _> = thread::spawn(move|| {
455+
let _: Result<(), _> = thread::spawn(move|| {
456456
let _lock = arc2.write().unwrap();
457457
panic!();
458458
}).join();
@@ -464,7 +464,7 @@ mod tests {
464464
let arc = Arc::new(RwLock::new(1));
465465
assert!(!arc.is_poisoned());
466466
let arc2 = arc.clone();
467-
let _: Result<uint, _> = thread::spawn(move|| {
467+
let _: Result<(), _> = thread::spawn(move|| {
468468
let _lock = arc2.write().unwrap();
469469
panic!();
470470
}).join();
@@ -476,7 +476,7 @@ mod tests {
476476
fn test_rw_arc_no_poison_rr() {
477477
let arc = Arc::new(RwLock::new(1));
478478
let arc2 = arc.clone();
479-
let _: Result<uint, _> = thread::spawn(move|| {
479+
let _: Result<(), _> = thread::spawn(move|| {
480480
let _lock = arc2.read().unwrap();
481481
panic!();
482482
}).join();
@@ -487,7 +487,7 @@ mod tests {
487487
fn test_rw_arc_no_poison_rw() {
488488
let arc = Arc::new(RwLock::new(1));
489489
let arc2 = arc.clone();
490-
let _: Result<uint, _> = thread::spawn(move|| {
490+
let _: Result<(), _> = thread::spawn(move|| {
491491
let _lock = arc2.read().unwrap();
492492
panic!()
493493
}).join();

src/libstd/thread.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl Builder {
260260
T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
261261
{
262262
self.spawn_inner(Thunk::new(f)).map(|inner| {
263-
JoinGuard { inner: inner, _marker: marker::PhantomData }
263+
JoinGuard { inner: inner, _marker: marker::CovariantType }
264264
})
265265
}
266266

@@ -642,7 +642,7 @@ impl Drop for JoinHandle {
642642
#[stable(feature = "rust1", since = "1.0.0")]
643643
pub struct JoinGuard<'a, T: 'a> {
644644
inner: JoinInner<T>,
645-
_marker: marker::PhantomData<&'a T>,
645+
_marker: marker::CovariantType<&'a T>,
646646
}
647647

648648
#[stable(feature = "rust1", since = "1.0.0")]
@@ -686,7 +686,9 @@ impl<T: Send> JoinGuard<'static, T> {
686686
impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
687687
fn drop(&mut self) {
688688
if !self.inner.joined {
689-
unsafe { imp::join(self.inner.native) };
689+
if self.inner.join().is_err() {
690+
panic!("child thread {:?} panicked", self.thread());
691+
}
690692
}
691693
}
692694
}
@@ -700,7 +702,8 @@ mod test {
700702
use boxed::BoxAny;
701703
use result;
702704
use std::old_io::{ChanReader, ChanWriter};
703-
use super::{self, Thread, Builder};
705+
use super::{Thread, Builder};
706+
use thread;
704707
use thunk::Thunk;
705708
use time::Duration;
706709

@@ -718,7 +721,7 @@ mod test {
718721
fn test_named_thread() {
719722
Builder::new().name("ada lovelace".to_string()).scoped(move|| {
720723
assert!(thread::current().name().unwrap() == "ada lovelace".to_string());
721-
}).join().ok().unwrap();
724+
}).unwrap().join();
722725
}
723726

724727
#[test]
@@ -732,12 +735,9 @@ mod test {
732735

733736
#[test]
734737
fn test_join_success() {
735-
match thread::spawn(move|| -> String {
738+
assert!(thread::scoped(move|| -> String {
736739
"Success!".to_string()
737-
}).join().as_ref().map(|s| &**s) {
738-
result::Result::Ok("Success!") => (),
739-
_ => panic!()
740-
}
740+
}).join() == "Success!");
741741
}
742742

743743
#[test]
@@ -928,10 +928,9 @@ mod test {
928928
let mut reader = ChanReader::new(rx);
929929
let stdout = ChanWriter::new(tx);
930930

931-
let r = Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
931+
Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
932932
print!("Hello, world!");
933-
}).join();
934-
assert!(r.is_ok());
933+
}).unwrap().join();
935934

936935
let output = reader.read_to_string().unwrap();
937936
assert_eq!(output, "Hello, world!".to_string());

src/libstd/thread_local/scoped.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ macro_rules! __scoped_thread_local_inner {
8484
target_os = "openbsd",
8585
target_arch = "aarch64")),
8686
thread_local)]
87-
static $name: ::std::thread_local::spawn::Key<$t> =
87+
static $name: ::std::thread_local::scoped::Key<$t> =
8888
__scoped_thread_local_inner!($t);
8989
);
9090
(pub static $name:ident: $t:ty) => (
@@ -94,19 +94,19 @@ macro_rules! __scoped_thread_local_inner {
9494
target_os = "openbsd",
9595
target_arch = "aarch64")),
9696
thread_local)]
97-
pub static $name: ::std::thread_local::spawn::Key<$t> =
97+
pub static $name: ::std::thread_local::scoped::Key<$t> =
9898
__scoped_thread_local_inner!($t);
9999
);
100100
($t:ty) => ({
101-
use std::thread_local::spawn::Key as __Key;
101+
use std::thread_local::scoped::Key as __Key;
102102

103103
#[cfg(not(any(windows,
104104
target_os = "android",
105105
target_os = "ios",
106106
target_os = "openbsd",
107107
target_arch = "aarch64")))]
108108
const _INIT: __Key<$t> = __Key {
109-
inner: ::std::thread_local::spawn::__impl::KeyInner {
109+
inner: ::std::thread_local::scoped::__impl::KeyInner {
110110
inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
111111
}
112112
};
@@ -117,8 +117,8 @@ macro_rules! __scoped_thread_local_inner {
117117
target_os = "openbsd",
118118
target_arch = "aarch64"))]
119119
const _INIT: __Key<$t> = __Key {
120-
inner: ::std::thread_local::spawn::__impl::KeyInner {
121-
inner: ::std::thread_local::spawn::__impl::OS_INIT,
120+
inner: ::std::thread_local::scoped::__impl::KeyInner {
121+
inner: ::std::thread_local::scoped::__impl::OS_INIT,
122122
marker: ::std::marker::InvariantType,
123123
}
124124
};

src/test/bench/shootout-binarytrees.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
extern crate arena;
4242

4343
use std::iter::range_step;
44-
use std::thread::{Thread, JoinGuard};
44+
use std::thread;
4545
use arena::TypedArena;
4646

4747
struct Tree<'a> {
@@ -110,11 +110,11 @@ fn main() {
110110
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
111111
use std::num::Int;
112112
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
113-
thread::spawn(move || inner(depth, iterations))
113+
thread::scoped(move || inner(depth, iterations))
114114
}).collect::<Vec<_>>();
115115

116116
for message in messages {
117-
println!("{}", message.join().ok().unwrap());
117+
println!("{}", message.join());
118118
}
119119

120120
println!("long lived tree of depth {}\t check: {}",

src/test/bench/shootout-fannkuch-redux.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ fn fannkuch(n: i32) -> (i32, i32) {
164164
for (_, j) in (0..N).zip(iter::count(0, k)) {
165165
let max = cmp::min(j+k, perm.max());
166166

167-
futures.push(thread::spawn(move|| {
167+
futures.push(thread::scoped(move|| {
168168
work(perm, j as uint, max as uint)
169169
}))
170170
}
171171

172172
let mut checksum = 0;
173173
let mut maxflips = 0;
174174
for fut in futures {
175-
let (cs, mf) = fut.join().ok().unwrap();
175+
let (cs, mf) = fut.join();
176176
checksum += cs;
177177
maxflips = cmp::max(maxflips, mf);
178178
}

src/test/bench/shootout-k-nucleotide.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,17 @@ fn main() {
303303

304304
let nb_freqs: Vec<_> = (1u..3).map(|i| {
305305
let input = input.clone();
306-
(i, thread::spawn(move|| generate_frequencies(&input, i)))
306+
(i, thread::scoped(move|| generate_frequencies(&input, i)))
307307
}).collect();
308308
let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
309309
let input = input.clone();
310-
thread::spawn(move|| generate_frequencies(&input, occ.len()))
310+
thread::scoped(move|| generate_frequencies(&input, occ.len()))
311311
}).collect();
312312

313313
for (i, freq) in nb_freqs {
314-
print_frequencies(&freq.join().ok().unwrap(), i);
314+
print_frequencies(&freq.join(), i);
315315
}
316316
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {
317-
print_occurrences(&mut freq.join().ok().unwrap(), occ);
317+
print_occurrences(&mut freq.join(), occ);
318318
}
319319
}

src/test/bench/shootout-mandelbrot.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
8181
let mut precalc_i = Vec::with_capacity(h);
8282

8383
let precalc_futures = (0..WORKERS).map(|i| {
84-
thread::spawn(move|| {
84+
thread::scoped(move|| {
8585
let mut rs = Vec::with_capacity(w / WORKERS);
8686
let mut is = Vec::with_capacity(w / WORKERS);
8787

@@ -107,7 +107,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
107107
}).collect::<Vec<_>>();
108108

109109
for res in precalc_futures {
110-
let (rs, is) = res.join().ok().unwrap();
110+
let (rs, is) = res.join();
111111
precalc_r.extend(rs.into_iter());
112112
precalc_i.extend(is.into_iter());
113113
}
@@ -122,7 +122,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
122122
let vec_init_r = arc_init_r.clone();
123123
let vec_init_i = arc_init_i.clone();
124124

125-
thread::spawn(move|| {
125+
thread::scoped(move|| {
126126
let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
127127
let init_r_slice = vec_init_r;
128128

@@ -143,7 +143,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
143143

144144
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
145145
for res in data {
146-
try!(out.write(&res.join().ok().unwrap()));
146+
try!(out.write(&res.join()));
147147
}
148148
out.flush()
149149
}

src/test/compile-fail/send-is-not-static-ensures-scoping.rs

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

11-
#![feature(core, std_misc)]
12-
use std::thread::Thread;
11+
use std::thread;
1312

1413
fn main() {
1514
let bad = {
1615
let x = 1;
1716
let y = &x;
1817

19-
Thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
18+
thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
2019
let _z = y;
2120
})
2221
};
2322

24-
bad.join().ok().unwrap();
23+
bad.join();
2524
}

src/test/pretty/attr-fn-inner.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// preserved, and that the first outer item parsed in main is not
1414
// accidentally carried over to each inner function
1515

16+
#![feature(custom_attribute)]
17+
1618
fn main() {
1719
#![inner_attr]
1820
#[outer_attr]

src/test/run-make/static-unwinding/lib.rs

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

1111
#![crate_type = "rlib"]
1212

13-
pub static mut statik: int = 0;
13+
pub static mut statik: isize = 0;
1414

1515
struct A;
1616
impl Drop for A {

0 commit comments

Comments
 (0)