Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev.

This commit is contained in:
Josh Matthews 2015-01-15 13:26:44 -05:00 committed by Glenn Watson
parent ff8cbff810
commit 95fc29fa0d
255 changed files with 3550 additions and 3362 deletions

View file

@ -4,13 +4,11 @@
/// General actor system infrastructure.
use std::any::{Any, AnyRefExt, AnyMutRefExt};
use std::any::Any;
use std::collections::HashMap;
use std::cell::{Cell, RefCell};
use std::intrinsics::TypeId;
use std::io::TcpStream;
use std::mem::{transmute, transmute_copy, replace};
use std::raw::TraitObject;
use std::mem::replace;
use serialize::json;
/// A common trait for all devtools actors that encompasses an immutable name
@ -25,46 +23,6 @@ pub trait Actor : Any {
fn name(&self) -> String;
}
impl<'a> AnyMutRefExt<'a> for &'a mut (Actor + 'a) {
fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let to: TraitObject = transmute_copy(&self);
// Extract the data pointer
Some(transmute(to.data))
}
} else {
None
}
}
}
impl<'a> AnyRefExt<'a> for &'a (Actor + 'a) {
fn is<T: 'static>(self) -> bool {
// This implementation is only needed so long as there's a Rust bug that
// prevents downcast_ref from giving realistic return values.
let t = TypeId::of::<T>();
let boxed: TypeId = (*self).get_type_id();
t == boxed
}
fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let to: TraitObject = transmute_copy(&self);
// Extract the data pointer
Some(transmute(to.data))
}
} else {
None
}
}
}
/// A list of known, owned actors.
pub struct ActorRegistry {
actors: HashMap<String, Box<Actor+Send+Sized>>,
@ -130,20 +88,14 @@ impl ActorRegistry {
/// Find an actor by registered name
pub fn find<'a, T: 'static>(&'a self, name: &str) -> &'a T {
//FIXME: Rust bug forces us to implement bogus Any for Actor since downcast_ref currently
// fails for unknown reasons.
/*let actor: &Actor+Send+Sized = *self.actors.find(&name.to_string()).unwrap();
(actor as &Any).downcast_ref::<T>().unwrap()*/
self.actors.get(&name.to_string()).unwrap().downcast_ref::<T>().unwrap()
let actor: &Any = self.actors.get(&name.to_string()).unwrap();
actor.downcast_ref::<T>().unwrap()
}
/// Find an actor by registered name
pub fn find_mut<'a, T: 'static>(&'a mut self, name: &str) -> &'a mut T {
//FIXME: Rust bug forces us to implement bogus Any for Actor since downcast_ref currently
// fails for unknown reasons.
/*let actor: &mut Actor+Send+Sized = *self.actors.find_mut(&name.to_string()).unwrap();
(actor as &mut Any).downcast_mut::<T>().unwrap()*/
self.actors.get_mut(&name.to_string()).unwrap().downcast_mut::<T>().unwrap()
let actor: &mut Any = self.actors.get_mut(&name.to_string()).unwrap();
actor.downcast_mut::<T>().unwrap()
}
/// Attempt to process a message as directed by its `to` property. If the actor is not