2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
2012-11-01 15:08:36 -07:00
|
|
|
mod base {
|
2015-02-12 10:29:52 -05:00
|
|
|
pub trait HasNew {
|
2013-08-08 11:38:10 -07:00
|
|
|
fn new() -> Self;
|
2012-11-01 15:08:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Foo {
|
|
|
|
dummy: (),
|
|
|
|
}
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
impl ::base::HasNew for Foo {
|
2013-03-22 11:23:21 -07:00
|
|
|
fn new() -> Foo {
|
2014-01-09 21:06:55 +11:00
|
|
|
println!("Foo");
|
2012-11-01 15:08:36 -07:00
|
|
|
Foo { dummy: () }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Bar {
|
|
|
|
dummy: (),
|
|
|
|
}
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
impl ::base::HasNew for Bar {
|
2013-03-22 11:23:21 -07:00
|
|
|
fn new() -> Bar {
|
2014-01-09 21:06:55 +11:00
|
|
|
println!("Bar");
|
2012-11-01 15:08:36 -07:00
|
|
|
Bar { dummy: () }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-02-12 10:29:52 -05:00
|
|
|
let _f: base::Foo = base::HasNew::new();
|
|
|
|
let _b: base::Bar = base::HasNew::new();
|
2012-11-01 15:08:36 -07:00
|
|
|
}
|