Test fixes and rebase conflicts
This commit is contained in:
parent
ba8ce4c2c2
commit
665ea963d3
18 changed files with 65 additions and 64 deletions
|
@ -343,7 +343,7 @@ trait ConvertTo<Output> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConvertTo<i64> for i32 {
|
impl ConvertTo<i64> for i32 {
|
||||||
fn convert(&self) -> i64 { *self as i32 }
|
fn convert(&self) -> i64 { *self as i64 }
|
||||||
}
|
}
|
||||||
|
|
||||||
// can be called with T == i32
|
// can be called with T == i32
|
||||||
|
|
|
@ -8,11 +8,13 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
//! RingBuf is a double-ended queue, which is implemented with the help of a growing circular buffer.
|
//! RingBuf is a double-ended queue, which is implemented with the help of a
|
||||||
|
//! growing circular buffer.
|
||||||
//!
|
//!
|
||||||
//! This queue has `O(1)` amortized inserts and removals from both ends of the container. It also
|
//! This queue has `O(1)` amortized inserts and removals from both ends of the
|
||||||
//! has `O(1)` indexing like a vector. The contained elements are not required to be copyable, and
|
//! container. It also has `O(1)` indexing like a vector. The contained elements
|
||||||
//! the queue will be sendable if the contained type is sendable.
|
//! are not required to be copyable, and the queue will be sendable if the
|
||||||
|
//! contained type is sendable.
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
|
@ -115,7 +117,8 @@ impl<T> RingBuf<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_full(&self) -> bool { self.cap - self.len() == 1 }
|
fn is_full(&self) -> bool { self.cap - self.len() == 1 }
|
||||||
|
|
||||||
/// Returns the index in the underlying buffer for a given logical element index.
|
/// Returns the index in the underlying buffer for a given logical element
|
||||||
|
/// index.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn wrap_index(&self, idx: usize) -> usize { wrap_index(idx, self.cap) }
|
fn wrap_index(&self, idx: usize) -> usize { wrap_index(idx, self.cap) }
|
||||||
|
|
||||||
|
|
|
@ -764,7 +764,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) ->
|
||||||
///
|
///
|
||||||
/// The diagnostic emitter yielded to the procedure should be used for reporting
|
/// The diagnostic emitter yielded to the procedure should be used for reporting
|
||||||
/// errors of the compiler.
|
/// errors of the compiler.
|
||||||
pub fn monitor<F:FnOnce()+Send>(f: F) {
|
pub fn monitor<F:FnOnce()+Send+'static>(f: F) {
|
||||||
static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
|
static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
|
|
@ -234,10 +234,7 @@ mod test {
|
||||||
writer.write_be_u32(42).unwrap();
|
writer.write_be_u32(42).unwrap();
|
||||||
|
|
||||||
let wanted = vec![0u8, 0u8, 0u8, 42u8];
|
let wanted = vec![0u8, 0u8, 0u8, 42u8];
|
||||||
let got = match thread::spawn(move|| { rx.recv().unwrap() }).join() {
|
let got = thread::scoped(move|| { rx.recv().unwrap() }).join();
|
||||||
Ok(got) => got,
|
|
||||||
Err(_) => panic!(),
|
|
||||||
};
|
|
||||||
assert_eq!(wanted, got);
|
assert_eq!(wanted, got);
|
||||||
|
|
||||||
match writer.write_u8(1) {
|
match writer.write_u8(1) {
|
||||||
|
|
|
@ -520,7 +520,7 @@ mod tests {
|
||||||
fn test_null_byte() {
|
fn test_null_byte() {
|
||||||
use thread;
|
use thread;
|
||||||
let result = thread::spawn(move|| {
|
let result = thread::spawn(move|| {
|
||||||
Path::new(b"foo/bar\0")
|
Path::new(b"foo/bar\0");
|
||||||
}).join();
|
}).join();
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
|
|
@ -1307,7 +1307,7 @@ mod tests {
|
||||||
fn test_null_byte() {
|
fn test_null_byte() {
|
||||||
use thread;
|
use thread;
|
||||||
let result = thread::spawn(move|| {
|
let result = thread::spawn(move|| {
|
||||||
Path::new(b"foo/bar\0")
|
Path::new(b"foo/bar\0");
|
||||||
}).join();
|
}).join();
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
|
|
@ -425,8 +425,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn frob() {
|
fn frob() {
|
||||||
static R: StaticRwLock = RW_LOCK_INIT;
|
static R: StaticRwLock = RW_LOCK_INIT;
|
||||||
static N: uint = 10;
|
static N: usize = 10;
|
||||||
static M: uint = 1000;
|
static M: usize = 1000;
|
||||||
|
|
||||||
let (tx, rx) = channel::<()>();
|
let (tx, rx) = channel::<()>();
|
||||||
for _ in 0..N {
|
for _ in 0..N {
|
||||||
|
@ -452,7 +452,7 @@ mod tests {
|
||||||
fn test_rw_arc_poison_wr() {
|
fn test_rw_arc_poison_wr() {
|
||||||
let arc = Arc::new(RwLock::new(1));
|
let arc = Arc::new(RwLock::new(1));
|
||||||
let arc2 = arc.clone();
|
let arc2 = arc.clone();
|
||||||
let _: Result<uint, _> = thread::spawn(move|| {
|
let _: Result<(), _> = thread::spawn(move|| {
|
||||||
let _lock = arc2.write().unwrap();
|
let _lock = arc2.write().unwrap();
|
||||||
panic!();
|
panic!();
|
||||||
}).join();
|
}).join();
|
||||||
|
@ -464,7 +464,7 @@ mod tests {
|
||||||
let arc = Arc::new(RwLock::new(1));
|
let arc = Arc::new(RwLock::new(1));
|
||||||
assert!(!arc.is_poisoned());
|
assert!(!arc.is_poisoned());
|
||||||
let arc2 = arc.clone();
|
let arc2 = arc.clone();
|
||||||
let _: Result<uint, _> = thread::spawn(move|| {
|
let _: Result<(), _> = thread::spawn(move|| {
|
||||||
let _lock = arc2.write().unwrap();
|
let _lock = arc2.write().unwrap();
|
||||||
panic!();
|
panic!();
|
||||||
}).join();
|
}).join();
|
||||||
|
@ -476,7 +476,7 @@ mod tests {
|
||||||
fn test_rw_arc_no_poison_rr() {
|
fn test_rw_arc_no_poison_rr() {
|
||||||
let arc = Arc::new(RwLock::new(1));
|
let arc = Arc::new(RwLock::new(1));
|
||||||
let arc2 = arc.clone();
|
let arc2 = arc.clone();
|
||||||
let _: Result<uint, _> = thread::spawn(move|| {
|
let _: Result<(), _> = thread::spawn(move|| {
|
||||||
let _lock = arc2.read().unwrap();
|
let _lock = arc2.read().unwrap();
|
||||||
panic!();
|
panic!();
|
||||||
}).join();
|
}).join();
|
||||||
|
@ -487,7 +487,7 @@ mod tests {
|
||||||
fn test_rw_arc_no_poison_rw() {
|
fn test_rw_arc_no_poison_rw() {
|
||||||
let arc = Arc::new(RwLock::new(1));
|
let arc = Arc::new(RwLock::new(1));
|
||||||
let arc2 = arc.clone();
|
let arc2 = arc.clone();
|
||||||
let _: Result<uint, _> = thread::spawn(move|| {
|
let _: Result<(), _> = thread::spawn(move|| {
|
||||||
let _lock = arc2.read().unwrap();
|
let _lock = arc2.read().unwrap();
|
||||||
panic!()
|
panic!()
|
||||||
}).join();
|
}).join();
|
||||||
|
|
|
@ -260,7 +260,7 @@ impl Builder {
|
||||||
T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
|
T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
|
||||||
{
|
{
|
||||||
self.spawn_inner(Thunk::new(f)).map(|inner| {
|
self.spawn_inner(Thunk::new(f)).map(|inner| {
|
||||||
JoinGuard { inner: inner, _marker: marker::PhantomData }
|
JoinGuard { inner: inner, _marker: marker::CovariantType }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ impl Drop for JoinHandle {
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct JoinGuard<'a, T: 'a> {
|
pub struct JoinGuard<'a, T: 'a> {
|
||||||
inner: JoinInner<T>,
|
inner: JoinInner<T>,
|
||||||
_marker: marker::PhantomData<&'a T>,
|
_marker: marker::CovariantType<&'a T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -686,7 +686,9 @@ impl<T: Send> JoinGuard<'static, T> {
|
||||||
impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
|
impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if !self.inner.joined {
|
if !self.inner.joined {
|
||||||
unsafe { imp::join(self.inner.native) };
|
if self.inner.join().is_err() {
|
||||||
|
panic!("child thread {:?} panicked", self.thread());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,7 +702,8 @@ mod test {
|
||||||
use boxed::BoxAny;
|
use boxed::BoxAny;
|
||||||
use result;
|
use result;
|
||||||
use std::old_io::{ChanReader, ChanWriter};
|
use std::old_io::{ChanReader, ChanWriter};
|
||||||
use super::{self, Thread, Builder};
|
use super::{Thread, Builder};
|
||||||
|
use thread;
|
||||||
use thunk::Thunk;
|
use thunk::Thunk;
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
|
|
||||||
|
@ -718,7 +721,7 @@ mod test {
|
||||||
fn test_named_thread() {
|
fn test_named_thread() {
|
||||||
Builder::new().name("ada lovelace".to_string()).scoped(move|| {
|
Builder::new().name("ada lovelace".to_string()).scoped(move|| {
|
||||||
assert!(thread::current().name().unwrap() == "ada lovelace".to_string());
|
assert!(thread::current().name().unwrap() == "ada lovelace".to_string());
|
||||||
}).join().ok().unwrap();
|
}).unwrap().join();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -732,12 +735,9 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_join_success() {
|
fn test_join_success() {
|
||||||
match thread::spawn(move|| -> String {
|
assert!(thread::scoped(move|| -> String {
|
||||||
"Success!".to_string()
|
"Success!".to_string()
|
||||||
}).join().as_ref().map(|s| &**s) {
|
}).join() == "Success!");
|
||||||
result::Result::Ok("Success!") => (),
|
|
||||||
_ => panic!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -928,10 +928,9 @@ mod test {
|
||||||
let mut reader = ChanReader::new(rx);
|
let mut reader = ChanReader::new(rx);
|
||||||
let stdout = ChanWriter::new(tx);
|
let stdout = ChanWriter::new(tx);
|
||||||
|
|
||||||
let r = Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
|
Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
|
||||||
print!("Hello, world!");
|
print!("Hello, world!");
|
||||||
}).join();
|
}).unwrap().join();
|
||||||
assert!(r.is_ok());
|
|
||||||
|
|
||||||
let output = reader.read_to_string().unwrap();
|
let output = reader.read_to_string().unwrap();
|
||||||
assert_eq!(output, "Hello, world!".to_string());
|
assert_eq!(output, "Hello, world!".to_string());
|
||||||
|
|
|
@ -84,7 +84,7 @@ macro_rules! __scoped_thread_local_inner {
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64")),
|
target_arch = "aarch64")),
|
||||||
thread_local)]
|
thread_local)]
|
||||||
static $name: ::std::thread_local::spawn::Key<$t> =
|
static $name: ::std::thread_local::scoped::Key<$t> =
|
||||||
__scoped_thread_local_inner!($t);
|
__scoped_thread_local_inner!($t);
|
||||||
);
|
);
|
||||||
(pub static $name:ident: $t:ty) => (
|
(pub static $name:ident: $t:ty) => (
|
||||||
|
@ -94,11 +94,11 @@ macro_rules! __scoped_thread_local_inner {
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64")),
|
target_arch = "aarch64")),
|
||||||
thread_local)]
|
thread_local)]
|
||||||
pub static $name: ::std::thread_local::spawn::Key<$t> =
|
pub static $name: ::std::thread_local::scoped::Key<$t> =
|
||||||
__scoped_thread_local_inner!($t);
|
__scoped_thread_local_inner!($t);
|
||||||
);
|
);
|
||||||
($t:ty) => ({
|
($t:ty) => ({
|
||||||
use std::thread_local::spawn::Key as __Key;
|
use std::thread_local::scoped::Key as __Key;
|
||||||
|
|
||||||
#[cfg(not(any(windows,
|
#[cfg(not(any(windows,
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
|
@ -106,7 +106,7 @@ macro_rules! __scoped_thread_local_inner {
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64")))]
|
target_arch = "aarch64")))]
|
||||||
const _INIT: __Key<$t> = __Key {
|
const _INIT: __Key<$t> = __Key {
|
||||||
inner: ::std::thread_local::spawn::__impl::KeyInner {
|
inner: ::std::thread_local::scoped::__impl::KeyInner {
|
||||||
inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
|
inner: ::std::cell::UnsafeCell { value: 0 as *mut _ },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -117,8 +117,8 @@ macro_rules! __scoped_thread_local_inner {
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_arch = "aarch64"))]
|
target_arch = "aarch64"))]
|
||||||
const _INIT: __Key<$t> = __Key {
|
const _INIT: __Key<$t> = __Key {
|
||||||
inner: ::std::thread_local::spawn::__impl::KeyInner {
|
inner: ::std::thread_local::scoped::__impl::KeyInner {
|
||||||
inner: ::std::thread_local::spawn::__impl::OS_INIT,
|
inner: ::std::thread_local::scoped::__impl::OS_INIT,
|
||||||
marker: ::std::marker::InvariantType,
|
marker: ::std::marker::InvariantType,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
extern crate arena;
|
extern crate arena;
|
||||||
|
|
||||||
use std::iter::range_step;
|
use std::iter::range_step;
|
||||||
use std::thread::{Thread, JoinGuard};
|
use std::thread;
|
||||||
use arena::TypedArena;
|
use arena::TypedArena;
|
||||||
|
|
||||||
struct Tree<'a> {
|
struct Tree<'a> {
|
||||||
|
@ -110,11 +110,11 @@ fn main() {
|
||||||
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
let messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
|
||||||
use std::num::Int;
|
use std::num::Int;
|
||||||
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
|
let iterations = 2.pow((max_depth - depth + min_depth) as usize);
|
||||||
thread::spawn(move || inner(depth, iterations))
|
thread::scoped(move || inner(depth, iterations))
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
for message in messages {
|
for message in messages {
|
||||||
println!("{}", message.join().ok().unwrap());
|
println!("{}", message.join());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("long lived tree of depth {}\t check: {}",
|
println!("long lived tree of depth {}\t check: {}",
|
||||||
|
|
|
@ -164,7 +164,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
||||||
for (_, j) in (0..N).zip(iter::count(0, k)) {
|
for (_, j) in (0..N).zip(iter::count(0, k)) {
|
||||||
let max = cmp::min(j+k, perm.max());
|
let max = cmp::min(j+k, perm.max());
|
||||||
|
|
||||||
futures.push(thread::spawn(move|| {
|
futures.push(thread::scoped(move|| {
|
||||||
work(perm, j as uint, max as uint)
|
work(perm, j as uint, max as uint)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
|
||||||
let mut checksum = 0;
|
let mut checksum = 0;
|
||||||
let mut maxflips = 0;
|
let mut maxflips = 0;
|
||||||
for fut in futures {
|
for fut in futures {
|
||||||
let (cs, mf) = fut.join().ok().unwrap();
|
let (cs, mf) = fut.join();
|
||||||
checksum += cs;
|
checksum += cs;
|
||||||
maxflips = cmp::max(maxflips, mf);
|
maxflips = cmp::max(maxflips, mf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,17 +303,17 @@ fn main() {
|
||||||
|
|
||||||
let nb_freqs: Vec<_> = (1u..3).map(|i| {
|
let nb_freqs: Vec<_> = (1u..3).map(|i| {
|
||||||
let input = input.clone();
|
let input = input.clone();
|
||||||
(i, thread::spawn(move|| generate_frequencies(&input, i)))
|
(i, thread::scoped(move|| generate_frequencies(&input, i)))
|
||||||
}).collect();
|
}).collect();
|
||||||
let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
|
let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
|
||||||
let input = input.clone();
|
let input = input.clone();
|
||||||
thread::spawn(move|| generate_frequencies(&input, occ.len()))
|
thread::scoped(move|| generate_frequencies(&input, occ.len()))
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
for (i, freq) in nb_freqs {
|
for (i, freq) in nb_freqs {
|
||||||
print_frequencies(&freq.join().ok().unwrap(), i);
|
print_frequencies(&freq.join(), i);
|
||||||
}
|
}
|
||||||
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {
|
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {
|
||||||
print_occurrences(&mut freq.join().ok().unwrap(), occ);
|
print_occurrences(&mut freq.join(), occ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
||||||
let mut precalc_i = Vec::with_capacity(h);
|
let mut precalc_i = Vec::with_capacity(h);
|
||||||
|
|
||||||
let precalc_futures = (0..WORKERS).map(|i| {
|
let precalc_futures = (0..WORKERS).map(|i| {
|
||||||
thread::spawn(move|| {
|
thread::scoped(move|| {
|
||||||
let mut rs = Vec::with_capacity(w / WORKERS);
|
let mut rs = Vec::with_capacity(w / WORKERS);
|
||||||
let mut is = Vec::with_capacity(w / WORKERS);
|
let mut is = Vec::with_capacity(w / WORKERS);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
for res in precalc_futures {
|
for res in precalc_futures {
|
||||||
let (rs, is) = res.join().ok().unwrap();
|
let (rs, is) = res.join();
|
||||||
precalc_r.extend(rs.into_iter());
|
precalc_r.extend(rs.into_iter());
|
||||||
precalc_i.extend(is.into_iter());
|
precalc_i.extend(is.into_iter());
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
||||||
let vec_init_r = arc_init_r.clone();
|
let vec_init_r = arc_init_r.clone();
|
||||||
let vec_init_i = arc_init_i.clone();
|
let vec_init_i = arc_init_i.clone();
|
||||||
|
|
||||||
thread::spawn(move|| {
|
thread::scoped(move|| {
|
||||||
let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
|
let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
|
||||||
let init_r_slice = vec_init_r;
|
let init_r_slice = vec_init_r;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
|
||||||
|
|
||||||
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
|
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
|
||||||
for res in data {
|
for res in data {
|
||||||
try!(out.write(&res.join().ok().unwrap()));
|
try!(out.write(&res.join()));
|
||||||
}
|
}
|
||||||
out.flush()
|
out.flush()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,17 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(core, std_misc)]
|
use std::thread;
|
||||||
use std::thread::Thread;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let bad = {
|
let bad = {
|
||||||
let x = 1;
|
let x = 1;
|
||||||
let y = &x;
|
let y = &x;
|
||||||
|
|
||||||
Thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
|
thread::scoped(|| { //~ ERROR cannot infer an appropriate lifetime
|
||||||
let _z = y;
|
let _z = y;
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
bad.join().ok().unwrap();
|
bad.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// preserved, and that the first outer item parsed in main is not
|
// preserved, and that the first outer item parsed in main is not
|
||||||
// accidentally carried over to each inner function
|
// accidentally carried over to each inner function
|
||||||
|
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#![inner_attr]
|
#![inner_attr]
|
||||||
#[outer_attr]
|
#[outer_attr]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
pub static mut statik: int = 0;
|
pub static mut statik: isize = 0;
|
||||||
|
|
||||||
struct A;
|
struct A;
|
||||||
impl Drop for A {
|
impl Drop for A {
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
extern crate lib;
|
extern crate lib;
|
||||||
|
|
||||||
use std::thread::Thread;
|
use std::thread;
|
||||||
|
|
||||||
static mut statik: int = 0;
|
static mut statik: isize = 0;
|
||||||
|
|
||||||
struct A;
|
struct A;
|
||||||
impl Drop for A {
|
impl Drop for A {
|
||||||
|
@ -22,10 +22,9 @@ impl Drop for A {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Thread::scoped(move|| {
|
thread::spawn(move|| {
|
||||||
let _a = A;
|
let _a = A;
|
||||||
lib::callback(|| panic!());
|
lib::callback(|| panic!());
|
||||||
1
|
|
||||||
}).join().err().unwrap();
|
}).join().err().unwrap();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#![allow(unknown_features)]
|
#![allow(unknown_features)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
use std::thread::Thread;
|
use std::thread;
|
||||||
use std::sync::mpsc::{channel, Sender};
|
use std::sync::mpsc::{channel, Sender};
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
|
@ -69,15 +69,16 @@ pub fn main() {
|
||||||
assert_eq!(receiver.recv().ok(), None);
|
assert_eq!(receiver.recv().ok(), None);
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let _t = Thread::scoped(move|| {
|
let t = thread::spawn(move|| {
|
||||||
let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
|
let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
|
||||||
});
|
});
|
||||||
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
|
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
|
||||||
assert_eq!(receiver.recv().ok(), None);
|
assert_eq!(receiver.recv().ok(), None);
|
||||||
|
drop(t.join());
|
||||||
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let _t = {
|
let t = {
|
||||||
Thread::scoped(move|| {
|
thread::spawn(move|| {
|
||||||
let mut v = Foo::NestedVariant(box 42u, SendOnDrop {
|
let mut v = Foo::NestedVariant(box 42u, SendOnDrop {
|
||||||
sender: sender.clone()
|
sender: sender.clone()
|
||||||
}, sender.clone());
|
}, sender.clone());
|
||||||
|
@ -93,4 +94,5 @@ pub fn main() {
|
||||||
assert_eq!(receiver.recv().unwrap(), Message::DestructorRan);
|
assert_eq!(receiver.recv().unwrap(), Message::DestructorRan);
|
||||||
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
|
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
|
||||||
assert_eq!(receiver.recv().ok(), None);
|
assert_eq!(receiver.recv().ok(), None);
|
||||||
|
drop(t.join());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue