Skip to content

Commit

Permalink
Use std::intrinsics::TypeId
Browse files Browse the repository at this point in the history
Fix indentation + update comment
  • Loading branch information
Jim Berlage committed Oct 1, 2014
1 parent 6358b7d commit 28e29dc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/devtools/actor.rs
Expand Up @@ -4,9 +4,10 @@

/// General actor system infrastructure.

use std::any::{Any, AnyRefExt, AnyMutRefExt};
use std::any::{AnyPrivate, AnyRefExt, AnyMutRefExt};
use std::collections::hashmap::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;
Expand All @@ -15,7 +16,7 @@ use serialize::json;
/// A common trait for all devtools actors that encompasses an immutable name
/// and the ability to process messages that are directed to particular actors.
/// TODO: ensure the name is immutable
pub trait Actor: Any {
pub trait Actor: AnyPrivate {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
Expand All @@ -42,14 +43,11 @@ impl<'a> AnyMutRefExt<'a> for &'a mut Actor + 'a {

impl<'a> AnyRefExt<'a> for &'a Actor + 'a {
fn is<T: 'static>(self) -> bool {
//FIXME: This implementation is bogus since get_type_id is private now.
// However, this implementation is only needed so long as there's a Rust bug
// that prevents downcast_ref from giving realistic return values, and this is
// ok since we're careful with the types we pull out of the hashmap.
/*let t = TypeId::of::<T>();
// 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 = self.get_type_id();
t == boxed*/
true
t == boxed
}

fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
Expand Down

5 comments on commit 28e29dc

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at jimberlage@28e29dc

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jamesberlage/servo/fix/meaningful-is = 28e29dc into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jamesberlage/servo/fix/meaningful-is = 28e29dc merged ok, testing candidate = da6878a

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = da6878a

Please sign in to comment.