2015-01-07 18:53:58 -08:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2013-11-21 21:30:34 -08:00
|
|
|
use std::cell::RefCell;
|
2014-05-05 18:56:44 -07:00
|
|
|
use std::rc::Rc;
|
2013-08-16 21:22:06 -07:00
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
trait Foo {
|
2013-11-21 21:30:34 -08:00
|
|
|
fn set(&mut self, v: Rc<RefCell<A>>);
|
2013-08-16 21:22:06 -07:00
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
struct B {
|
2013-11-21 21:30:34 -08:00
|
|
|
v: Option<Rc<RefCell<A>>>
|
2013-08-16 21:22:06 -07:00
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
impl Foo for B {
|
2013-11-21 21:30:34 -08:00
|
|
|
fn set(&mut self, v: Rc<RefCell<A>>)
|
2013-08-16 21:22:06 -07:00
|
|
|
{
|
|
|
|
self.v = Some(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
struct A {
|
2014-06-14 11:03:34 -07:00
|
|
|
v: Box<Foo + Send>,
|
2013-08-16 21:22:06 -07:00
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
fn main() {
|
2014-06-11 12:14:38 -07:00
|
|
|
let a = A {v: box B{v: None} as Box<Foo+Send>};
|
2018-06-09 16:53:36 -07:00
|
|
|
//~^ ERROR `std::rc::Rc<std::cell::RefCell<A>>` cannot be sent between threads safely
|
2013-08-16 21:22:06 -07:00
|
|
|
}
|