2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-11-16 12:20:19 -06:00
|
|
|
trait TraitWithSend: Send {}
|
|
|
|
trait IndirectTraitWithSend: TraitWithSend {}
|
|
|
|
|
|
|
|
// Check struct instantiation (Box<TraitWithSend> will only have Send if TraitWithSend has Send)
|
|
|
|
#[allow(dead_code)]
|
2019-05-28 13:47:21 -05:00
|
|
|
struct Blah { x: Box<dyn TraitWithSend> }
|
2014-11-16 12:20:19 -06:00
|
|
|
impl TraitWithSend for Blah {}
|
|
|
|
|
|
|
|
// Struct instantiation 2-levels deep
|
|
|
|
#[allow(dead_code)]
|
2019-05-28 13:47:21 -05:00
|
|
|
struct IndirectBlah { x: Box<dyn IndirectTraitWithSend> }
|
2014-11-16 12:20:19 -06:00
|
|
|
impl TraitWithSend for IndirectBlah {}
|
|
|
|
impl IndirectTraitWithSend for IndirectBlah {}
|
|
|
|
|
2014-12-24 01:05:30 -06:00
|
|
|
fn test_trait<T: Send + ?Sized>() { println!("got here!") }
|
2014-11-16 12:20:19 -06:00
|
|
|
|
|
|
|
fn main() {
|
2019-05-28 13:47:21 -05:00
|
|
|
test_trait::<dyn TraitWithSend>();
|
|
|
|
test_trait::<dyn IndirectTraitWithSend>();
|
2014-11-16 12:20:19 -06:00
|
|
|
}
|