Skip to content

Commit

Permalink
workaround for broken cross-crate generic newtype structs
Browse files Browse the repository at this point in the history
add issue number for newtype struct issue
  • Loading branch information
Tim Kuehn committed Sep 20, 2013
1 parent c804db0 commit 9df66ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/components/gfx/render_task.rs
Expand Up @@ -58,13 +58,28 @@ pub fn BufferRequest(screen_rect: Rect<uint>, page_rect: Rect<f32>) -> BufferReq
}
}

// FIXME(rust#9155): this should be a newtype struct, but
// generic newtypes ICE when compiled cross-crate
#[deriving(Clone)]
pub struct RenderChan<T>{chan:SharedChan<Msg<T>>}
impl<T> RenderChan<T> {
pub struct RenderChan<T> {
chan: SharedChan<Msg<T>>,
}
impl<T: Send> RenderChan<T> {
pub fn new(chan: Chan<Msg<T>>) -> RenderChan<T> {
RenderChan{chan:SharedChan::new(chan)}
RenderChan {
chan: SharedChan::new(chan),
}
}
}
impl<T: Send> GenericChan<Msg<T>> for RenderChan<T> {
fn send(&self, msg: Msg<T>) {
assert!(self.try_send(msg), "RenderChan.send: render port closed")
}
}
impl<T: Send> GenericSmartChan<Msg<T>> for RenderChan<T> {
fn try_send(&self, msg: Msg<T>) -> bool {
self.chan.try_send(msg)
}
pub fn send(&self, msg: Msg<T>) { self.chan.send(msg) }
}

struct RenderTask<C,T> {
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/constellation.rs
Expand Up @@ -438,7 +438,7 @@ impl Constellation {
if pipeline.subpage_id.expect("Constellation: child frame does not have a
subpage id. This should not be possible.") == subpage_id {
child_frame_tree.rect = Some(rect.clone());
let Rect { size: Size2D { width, height }, _ } = rect;
let Size2D { width, height } = rect.size;
pipeline.script_chan.send(ResizeMsg(pipeline.id.clone(), Size2D {
width: width as uint,
height: height as uint
Expand Down

0 comments on commit 9df66ff

Please sign in to comment.