2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2014-11-16 18:20:19 +00: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 18:47:21 +00:00
|
|
|
struct Blah { x: Box<dyn TraitWithSend> }
|
2014-11-16 18:20:19 +00:00
|
|
|
impl TraitWithSend for Blah {}
|
|
|
|
|
|
|
|
// Struct instantiation 2-levels deep
|
|
|
|
#[allow(dead_code)]
|
2019-05-28 18:47:21 +00:00
|
|
|
struct IndirectBlah { x: Box<dyn IndirectTraitWithSend> }
|
2014-11-16 18:20:19 +00:00
|
|
|
impl TraitWithSend for IndirectBlah {}
|
|
|
|
impl IndirectTraitWithSend for IndirectBlah {}
|
|
|
|
|
2014-12-24 07:05:30 +00:00
|
|
|
fn test_trait<T: Send + ?Sized>() { println!("got here!") }
|
2014-11-16 18:20:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
2019-05-28 18:47:21 +00:00
|
|
|
test_trait::<dyn TraitWithSend>();
|
|
|
|
test_trait::<dyn IndirectTraitWithSend>();
|
2014-11-16 18:20:19 +00:00
|
|
|
}
|