Rollup test fixes and rebase conflicts

This commit is contained in:
Alex Crichton 2015-01-02 09:24:56 -08:00
parent 1f2ead1629
commit e921e3f045
31 changed files with 56 additions and 95 deletions

View file

@ -3177,7 +3177,6 @@ then the expression completes.
Some examples of call expressions: Some examples of call expressions:
``` ```
# use std::str::from_str;
# fn add(x: int, y: int) -> int { 0 } # fn add(x: int, y: int) -> int { 0 }
let x: int = add(1, 2); let x: int = add(1, 2);

View file

@ -113,28 +113,9 @@ impl<S: hash::Writer, Sized? T: Hash<S>> Hash<S> for Box<T> {
} }
} }
#[cfg(not(stage0))]
impl Box<Any> {
pub fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let to: TraitObject =
mem::transmute::<Box<Any>, TraitObject>(self);
// Extract the data pointer
Ok(mem::transmute(to.data))
}
} else {
Err(self)
}
}
}
/// Extension methods for an owning `Any` trait object. /// Extension methods for an owning `Any` trait object.
#[unstable = "post-DST and coherence changes, this will not be a trait but \ #[unstable = "post-DST and coherence changes, this will not be a trait but \
rather a direct `impl` on `Box<Any>`"] rather a direct `impl` on `Box<Any>`"]
#[cfg(stage0)]
pub trait BoxAny { pub trait BoxAny {
/// Returns the boxed value if it is of type `T`, or /// Returns the boxed value if it is of type `T`, or
/// `Err(Self)` if it isn't. /// `Err(Self)` if it isn't.
@ -142,10 +123,10 @@ pub trait BoxAny {
fn downcast<T: 'static>(self) -> Result<Box<T>, Self>; fn downcast<T: 'static>(self) -> Result<Box<T>, Self>;
} }
#[stable]
#[cfg(stage0)]
impl BoxAny for Box<Any> { impl BoxAny for Box<Any> {
#[inline] #[inline]
#[unstable = "method may be renamed with respect to other downcasting \
methods"]
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> { fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
if self.is::<T>() { if self.is::<T>() {
unsafe { unsafe {

View file

@ -92,7 +92,7 @@ use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned};
use core::iter::{mod, FromIterator}; use core::iter::{mod, FromIterator};
use core::num::Int; use core::num::Int;
use core::ops::Index; use core::ops::Index;
use core::slice::{Iter, IterMut}; use core::slice;
use core::{u8, u32, uint}; use core::{u8, u32, uint};
use bitv_set; //so meta use bitv_set; //so meta

View file

@ -723,8 +723,6 @@ impl<T: Default> Option<T> {
/// `None` on error. /// `None` on error.
/// ///
/// ``` /// ```
/// use std::str::from_str;
///
/// let good_year_from_input = "1909"; /// let good_year_from_input = "1909";
/// let bad_year_from_input = "190blarg"; /// let bad_year_from_input = "190blarg";
/// let good_year = good_year_from_input.parse().unwrap_or_default(); /// let good_year = good_year_from_input.parse().unwrap_or_default();

View file

@ -449,7 +449,6 @@ impl<T, E> Result<T, E> {
/// ///
/// ``` /// ```
/// use std::io::IoResult; /// use std::io::IoResult;
/// use std::str::from_str;
/// ///
/// let mut buffer = &mut b"1\n2\n3\n4\n"; /// let mut buffer = &mut b"1\n2\n3\n4\n";
/// ///

View file

@ -23,7 +23,6 @@ use syntax::diagnostic;
use syntax::diagnostic::{Emitter, Handler, Level, mk_handler}; use syntax::diagnostic::{Emitter, Handler, Level, mk_handler};
use std::c_str::{ToCStr, CString}; use std::c_str::{ToCStr, CString};
use std::comm::channel;
use std::io::Command; use std::io::Command;
use std::io::fs; use std::io::fs;
use std::iter::Unfold; use std::iter::Unfold;

View file

@ -402,7 +402,7 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
} }
fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result { fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result {
let mut buf = [0, .. 4]; let mut buf = [0; 4];
let n = v.encode_utf8(&mut buf).unwrap(); let n = v.encode_utf8(&mut buf).unwrap();
let buf = unsafe { str::from_utf8_unchecked(buf[0..n]) }; let buf = unsafe { str::from_utf8_unchecked(buf[0..n]) };
escape_str(writer, buf) escape_str(writer, buf)

View file

@ -1918,7 +1918,7 @@ impl fmt::Show for FilePermission {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use self::BadReaderBehavior::*; use self::BadReaderBehavior::*;
use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput}; use super::{IoResult, MemReader, NoProgress, InvalidInput};
use prelude::v1::*; use prelude::v1::*;
use uint; use uint;

View file

@ -225,8 +225,6 @@ fn in_ms_u64(d: Duration) -> u64 {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use prelude::v1::*;
use super::Timer; use super::Timer;
use thread::Thread; use thread::Thread;
use time::Duration; use time::Duration;

View file

@ -1119,10 +1119,6 @@ fn prefix_len(p: Option<PathPrefix>) -> uint {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use prelude::v1::Option::{mod, Some, None};
use prelude::v1::{Vec, Clone, AsSlice, SliceExt, CloneSliceExt, IteratorExt};
use prelude::v1::{DoubleEndedIteratorExt, Str, ToString, GenericPath};
use super::PathPrefix::*; use super::PathPrefix::*;
use super::parse_prefix; use super::parse_prefix;
use super::*; use super::*;

View file

@ -307,7 +307,7 @@ mod tests {
static C: StaticCondvar = CONDVAR_INIT; static C: StaticCondvar = CONDVAR_INIT;
static M: StaticMutex = MUTEX_INIT; static M: StaticMutex = MUTEX_INIT;
let mut g = M.lock().unwrap(); let g = M.lock().unwrap();
let _t = Thread::spawn(move|| { let _t = Thread::spawn(move|| {
let _g = M.lock().unwrap(); let _g = M.lock().unwrap();
C.notify_one(); C.notify_one();
@ -386,6 +386,6 @@ mod tests {
g = C.wait(g).unwrap(); g = C.wait(g).unwrap();
drop(g); drop(g);
C.wait(M2.lock().unwrap()).unwrap(); let _ = C.wait(M2.lock().unwrap()).unwrap();
} }
} }

View file

@ -337,7 +337,6 @@ mod test {
use prelude::v1::*; use prelude::v1::*;
use thread::Thread; use thread::Thread;
use super::*;
use sync::mpsc::*; use sync::mpsc::*;
// Don't use the libstd version so we can pull in the right Select structure // Don't use the libstd version so we can pull in the right Select structure

View file

@ -447,7 +447,7 @@ mod test {
fn test_mutex_arc_poison() { fn test_mutex_arc_poison() {
let arc = Arc::new(Mutex::new(1i)); let arc = Arc::new(Mutex::new(1i));
let arc2 = arc.clone(); let arc2 = arc.clone();
Thread::spawn(move|| { let _ = Thread::spawn(move|| {
let lock = arc2.lock().unwrap(); let lock = arc2.lock().unwrap();
assert_eq!(*lock, 2); assert_eq!(*lock, 2);
}).join(); }).join();

View file

@ -23,7 +23,6 @@
use prelude::v1::*; use prelude::v1::*;
use cell::UnsafeCell; use cell::UnsafeCell;
use comm::{channel, Sender, Receiver};
use mem; use mem;
use rt; use rt;
use sync::{StaticMutex, StaticCondvar}; use sync::{StaticMutex, StaticCondvar};

View file

@ -10,8 +10,6 @@
use prelude::v1::*; use prelude::v1::*;
use prelude::*;
use libc; use libc;
use c_str::CString; use c_str::CString;
use mem; use mem;

View file

@ -24,13 +24,12 @@ use num;
use mem; use mem;
use io::{mod, IoResult, IoError}; use io::{mod, IoResult, IoError};
use sync::{Once, ONCE_INIT}; use sync::{Once, ONCE_INIT};
use comm::Sender;
macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => (
static $name: Helper<$m> = Helper { static $name: Helper<$m> = Helper {
lock: ::sync::MUTEX_INIT, lock: ::sync::MUTEX_INIT,
cond: ::sync::CONDVAR_INIT, cond: ::sync::CONDVAR_INIT,
chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> }, chan: ::cell::UnsafeCell { value: 0 as *mut ::sync::mpsc::Sender<$m> },
signal: ::cell::UnsafeCell { value: 0 }, signal: ::cell::UnsafeCell { value: 0 },
initialized: ::cell::UnsafeCell { value: false }, initialized: ::cell::UnsafeCell { value: false },
shutdown: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false },

View file

@ -25,10 +25,9 @@ use prelude::v1::*;
use libc; use libc;
use ptr; use ptr;
use comm;
use comm::{channel, Sender, Receiver};
use io::IoResult; use io::IoResult;
use sync::mpsc::{channel, Sender, Receiver, TryRecvError};
use sys::c; use sys::c;
use sys::fs::FileDesc; use sys::fs::FileDesc;
use sys_common::helper_thread::Helper; use sys_common::helper_thread::Helper;
@ -72,7 +71,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) {
chans.push((c, one)); chans.push((c, one));
} }
Ok(RemoveTimer(obj, c)) => { Ok(RemoveTimer(obj, c)) => {
c.send(()); c.send(()).unwrap();
match objs.iter().position(|&o| o == obj) { match objs.iter().position(|&o| o == obj) {
Some(i) => { Some(i) => {
drop(objs.remove(i)); drop(objs.remove(i));
@ -81,7 +80,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) {
None => {} None => {}
} }
} }
Err(comm::Disconnected) => { Err(TryRecvError::Disconnected) => {
assert_eq!(objs.len(), 1); assert_eq!(objs.len(), 1);
assert_eq!(chans.len(), 0); assert_eq!(chans.len(), 0);
break 'outer; break 'outer;
@ -133,7 +132,7 @@ impl Timer {
let (tx, rx) = channel(); let (tx, rx) = channel();
HELPER.send(RemoveTimer(self.obj, tx)); HELPER.send(RemoveTimer(self.obj, tx));
rx.recv(); rx.recv().unwrap();
self.on_worker = false; self.on_worker = false;
} }

View file

@ -443,8 +443,8 @@ mod test {
use prelude::v1::*; use prelude::v1::*;
use any::{Any, AnyRefExt}; use any::{Any, AnyRefExt};
use boxed::BoxAny;
use sync::mpsc::{channel, Sender}; use sync::mpsc::{channel, Sender};
use boxed::BoxAny;
use result; use result;
use std::io::{ChanReader, ChanWriter}; use std::io::{ChanReader, ChanWriter};
use super::{Thread, Builder}; use super::{Thread, Builder};

View file

@ -18,8 +18,7 @@
// different scalability characteristics compared to the select // different scalability characteristics compared to the select
// version. // version.
use std::comm::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use std::comm;
use std::os; use std::os;
use std::str::from_str; use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;
@ -38,8 +37,8 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
let mut count = 0u; let mut count = 0u;
let mut done = false; let mut done = false;
while !done { while !done {
match requests.recv_opt() { match requests.recv() {
Ok(request::get_count) => { responses.send(count.clone()); } Ok(request::get_count) => { responses.send(count.clone()).unwrap(); }
Ok(request::bytes(b)) => { Ok(request::bytes(b)) => {
//println!("server: received {} bytes", b); //println!("server: received {} bytes", b);
count += b; count += b;
@ -48,7 +47,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
_ => { } _ => { }
} }
} }
responses.send(count); responses.send(count).unwrap();
//println!("server exiting"); //println!("server exiting");
} }
@ -69,7 +68,7 @@ fn run(args: &[String]) {
worker_results.push(Thread::spawn(move|| { worker_results.push(Thread::spawn(move|| {
for _ in range(0u, size / workers) { for _ in range(0u, size / workers) {
//println!("worker {}: sending {} bytes", i, num_bytes); //println!("worker {}: sending {} bytes", i, num_bytes);
to_child.send(request::bytes(num_bytes)); to_child.send(request::bytes(num_bytes)).unwrap();
} }
//println!("worker {} exiting", i); //println!("worker {} exiting", i);
})); }));
@ -83,9 +82,9 @@ fn run(args: &[String]) {
} }
//println!("sending stop message"); //println!("sending stop message");
to_child.send(request::stop); to_child.send(request::stop).unwrap();
move_out(to_child); move_out(to_child);
result = Some(from_child.recv()); result = Some(from_child.recv().unwrap());
}); });
let result = result.unwrap(); let result = result.unwrap();
print!("Count is {}\n", result); print!("Count is {}\n", result);

View file

@ -14,9 +14,8 @@
// //
// I *think* it's the same, more or less. // I *think* it's the same, more or less.
use std::comm::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use std::os; use std::os;
use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;
use std::time::Duration; use std::time::Duration;
use std::uint; use std::uint;
@ -33,7 +32,7 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
let mut count: uint = 0; let mut count: uint = 0;
let mut done = false; let mut done = false;
while !done { while !done {
match requests.recv_opt() { match requests.recv() {
Ok(request::get_count) => { responses.send(count.clone()); } Ok(request::get_count) => { responses.send(count.clone()); }
Ok(request::bytes(b)) => { Ok(request::bytes(b)) => {
//println!("server: received {} bytes", b); //println!("server: received {} bytes", b);
@ -50,8 +49,8 @@ fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
fn run(args: &[String]) { fn run(args: &[String]) {
let (to_parent, from_child) = channel(); let (to_parent, from_child) = channel();
let size = from_str::<uint>(args[1].as_slice()).unwrap(); let size = args[1].parse::<uint>().unwrap();
let workers = from_str::<uint>(args[2].as_slice()).unwrap(); let workers = args[2].parse::<uint>().unwrap();
let num_bytes = 100; let num_bytes = 100;
let mut result = None; let mut result = None;
let mut to_parent = Some(to_parent); let mut to_parent = Some(to_parent);
@ -93,7 +92,7 @@ fn run(args: &[String]) {
//println!("sending stop message"); //println!("sending stop message");
//to_child.send(stop); //to_child.send(stop);
//move_out(to_child); //move_out(to_child);
result = Some(from_child.recv()); result = Some(from_child.recv().unwrap());
}); });
let result = result.unwrap(); let result = result.unwrap();
print!("Count is {}\n", result); print!("Count is {}\n", result);

View file

@ -17,7 +17,7 @@
// 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.
use std::comm::channel; use std::sync::mpsc::channel;
use std::os; use std::os;
use std::str::from_str; use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;

View file

@ -8,9 +8,8 @@
// 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.
use std::comm::channel; use std::sync::mpsc::channel;
use std::os; use std::os;
use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;
use std::uint; use std::uint;
@ -28,7 +27,7 @@ fn parfib(n: uint) -> uint {
tx.send(parfib(n-1)); tx.send(parfib(n-1));
}).detach(); }).detach();
let m2 = parfib(n-2); let m2 = parfib(n-2);
return (rx.recv() + m2); return (rx.recv().unwrap() + m2);
} }
fn main() { fn main() {
@ -36,7 +35,7 @@ fn main() {
let args = os::args(); let args = os::args();
let args = args.as_slice(); let args = args.as_slice();
let n = if args.len() == 2 { let n = if args.len() == 2 {
from_str::<uint>(args[1].as_slice()).unwrap() args[1].parse::<uint>().unwrap()
} else { } else {
10 10
}; };

View file

@ -75,7 +75,7 @@ fn main() {
} else if args.len() <= 1u { } else if args.len() <= 1u {
8 8
} else { } else {
from_str(args[1].as_slice()).unwrap() args[1].parse().unwrap()
}; };
let min_depth = 4; let min_depth = 4;
let max_depth = if min_depth + 2 > n {min_depth + 2} else {n}; let max_depth = if min_depth + 2 > n {min_depth + 2} else {n};

View file

@ -41,7 +41,7 @@
// no-pretty-expanded // no-pretty-expanded
use self::Color::{Red, Yellow, Blue}; use self::Color::{Red, Yellow, Blue};
use std::comm::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use std::fmt; use std::fmt;
use std::str::from_str; use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;
@ -154,7 +154,7 @@ fn creature(
loop { loop {
// ask for a pairing // ask for a pairing
to_rendezvous.send(CreatureInfo {name: name, color: color}); to_rendezvous.send(CreatureInfo {name: name, color: color}).unwrap();
// log and change, or quit // log and change, or quit
match rendezvous.next() { match rendezvous.next() {
@ -172,7 +172,7 @@ fn creature(
} }
// log creatures met and evil clones of self // log creatures met and evil clones of self
let report = format!("{}{}", creatures_met, Number(evil_clones_met)); let report = format!("{}{}", creatures_met, Number(evil_clones_met));
to_rendezvous_log.send(report); to_rendezvous_log.send(report).unwrap();
} }
fn rendezvous(nn: uint, set: Vec<Color>) { fn rendezvous(nn: uint, set: Vec<Color>) {
@ -204,13 +204,13 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
// set up meetings... // set up meetings...
for _ in range(0, nn) { for _ in range(0, nn) {
let fst_creature = from_creatures.recv(); let fst_creature = from_creatures.recv().unwrap();
let snd_creature = from_creatures.recv(); let snd_creature = from_creatures.recv().unwrap();
creatures_met += 2; creatures_met += 2;
to_creature[fst_creature.name].send(snd_creature); to_creature[fst_creature.name].send(snd_creature).unwrap();
to_creature[snd_creature.name].send(fst_creature); to_creature[snd_creature.name].send(fst_creature).unwrap();
} }
// tell each creature to stop // tell each creature to stop

View file

@ -186,7 +186,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
fn main() { fn main() {
let n = std::os::args().as_slice() let n = std::os::args().as_slice()
.get(1) .get(1)
.and_then(|arg| from_str(arg.as_slice())) .and_then(|arg| arg.parse())
.unwrap_or(2i32); .unwrap_or(2i32);
let (checksum, maxflips) = fannkuch(n); let (checksum, maxflips) = fannkuch(n);

View file

@ -20,7 +20,7 @@ extern crate collections;
use std::ascii::{AsciiExt, OwnedAsciiExt}; use std::ascii::{AsciiExt, OwnedAsciiExt};
use std::cmp::Ordering::{mod, Less, Greater, Equal}; use std::cmp::Ordering::{mod, Less, Greater, Equal};
use std::collections::HashMap; use std::collections::HashMap;
use std::comm::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use std::mem::replace; use std::mem::replace;
use std::num::Float; use std::num::Float;
use std::option; use std::option;
@ -120,7 +120,7 @@ fn make_sequence_processor(sz: uint,
loop { loop {
line = from_parent.recv(); line = from_parent.recv().unwrap();
if line == Vec::new() { break; } if line == Vec::new() { break; }
carry.push_all(line.as_slice()); carry.push_all(line.as_slice());
@ -222,6 +222,6 @@ fn main() {
// now fetch and print result messages // now fetch and print result messages
for (ii, _sz) in sizes.iter().enumerate() { for (ii, _sz) in sizes.iter().enumerate() {
println!("{}", from_child[ii].recv()); println!("{}", from_child[ii].recv().unwrap());
} }
} }

View file

@ -40,7 +40,7 @@
// no-pretty-expanded FIXME #15189 // no-pretty-expanded FIXME #15189
use std::comm::channel; use std::sync::mpsc::channel;
use std::sync::Arc; use std::sync::Arc;
use std::thread::Thread; use std::thread::Thread;
@ -315,13 +315,13 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
Thread::spawn(move|| { Thread::spawn(move|| {
let mut data = Data::new(); let mut data = Data::new();
search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data); search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data);
tx.send(data); tx.send(data).unwrap();
}).detach(); }).detach();
} }
// collecting the results // collecting the results
drop(tx); drop(tx);
let mut data = rx.recv(); let mut data = rx.recv().unwrap();
for d in rx.iter() { data.reduce_from(d); } for d in rx.iter() { data.reduce_from(d); }
data data
} }

View file

@ -20,7 +20,7 @@
extern crate getopts; extern crate getopts;
use std::comm::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::os; use std::os;
use std::result::Result::{Ok, Err}; use std::result::Result::{Ok, Err};
use std::str::from_str; use std::str::from_str;
@ -30,22 +30,22 @@ use std::time::Duration;
fn fib(n: int) -> int { fn fib(n: int) -> int {
fn pfib(tx: &Sender<int>, n: int) { fn pfib(tx: &Sender<int>, n: int) {
if n == 0 { if n == 0 {
tx.send(0); tx.send(0).unwrap();
} else if n <= 2 { } else if n <= 2 {
tx.send(1); tx.send(1).unwrap();
} else { } else {
let (tx1, rx) = channel(); let (tx1, rx) = channel();
let tx2 = tx1.clone(); let tx2 = tx1.clone();
Thread::spawn(move|| pfib(&tx2, n - 1)).detach(); Thread::spawn(move|| pfib(&tx2, n - 1)).detach();
let tx2 = tx1.clone(); let tx2 = tx1.clone();
Thread::spawn(move|| pfib(&tx2, n - 2)).detach(); Thread::spawn(move|| pfib(&tx2, n - 2)).detach();
tx.send(rx.recv() + rx.recv()); tx.send(rx.recv().unwrap() + rx.recv().unwrap());
} }
} }
let (tx, rx) = channel(); let (tx, rx) = channel();
Thread::spawn(move|| pfib(&tx, n) ).detach(); Thread::spawn(move|| pfib(&tx, n) ).detach();
rx.recv() rx.recv().unwrap()
} }
struct Config { struct Config {

View file

@ -38,7 +38,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE. // OF THE POSSIBILITY OF SUCH DAMAGE.
use std::comm::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use std::str::from_str; use std::str::from_str;
use std::thread::Thread; use std::thread::Thread;

View file

@ -17,14 +17,14 @@
// ignore-pretty very bad with line comments // ignore-pretty very bad with line comments
use std::comm::{mod, channel}; use std::sync::mpsc::{channel, Sender};
use std::os; use std::os;
use std::str::from_str; use std::str::from_str;
use std::task; use std::task;
use std::thread::Thread; use std::thread::Thread;
use std::uint; use std::uint;
fn child_generation(gens_left: uint, tx: comm::Sender<()>) { fn child_generation(gens_left: uint, tx: Sender<()>) {
// This used to be O(n^2) in the number of generations that ever existed. // This used to be O(n^2) in the number of generations that ever existed.
// With this code, only as many generations are alive at a time as tasks // With this code, only as many generations are alive at a time as tasks
// alive at a time, // alive at a time,
@ -35,7 +35,7 @@ fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
if gens_left > 0 { if gens_left > 0 {
child_generation(gens_left - 1, tx); // recurse child_generation(gens_left - 1, tx); // recurse
} else { } else {
tx.send(()) tx.send(()).unwrap()
} }
}).detach(); }).detach();
} }
@ -52,7 +52,7 @@ fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
child_generation(from_str::<uint>(args[1].as_slice()).unwrap(), tx); child_generation(from_str::<uint>(args[1].as_slice()).unwrap(), tx);
if rx.recv_opt().is_err() { if rx.recv().is_err() {
panic!("it happened when we slumbered"); panic!("it happened when we slumbered");
} }
} }

View file

@ -19,7 +19,7 @@ trait From<Src> {
trait To { trait To {
// This is a typo, the return type should be `<Dst as From<Self>>::Output` // This is a typo, the return type should be `<Dst as From<Self>>::Output`
fn to<Dst: From<Self>>(self) -> <Dst as From<Self>>::Dst { fn to<Dst: From<Self>>(self) -> <Dst as From<Self>>::Dst {
//~ error: the trait `core::kinds::Sized` is not implemented //~^ error: the trait `core::kinds::Sized` is not implemented
From::from(self) From::from(self)
} }
} }