2014-12-15 21:11:09 -05:00
|
|
|
// Check that we correctly prevent users from making trait objects
|
|
|
|
|
// from traits with static methods.
|
2014-11-01 20:21:55 -07:00
|
|
|
|
2015-04-17 22:12:20 -07:00
|
|
|
trait Foo {
|
2019-01-08 22:14:04 +01:00
|
|
|
fn foo() {}
|
2014-11-01 20:21:55 -07:00
|
|
|
}
|
|
|
|
|
|
2019-01-08 22:14:04 +01:00
|
|
|
fn diverges() -> Box<dyn Foo> {
|
2025-02-04 02:37:13 +00:00
|
|
|
//~^ ERROR E0038
|
2015-12-15 04:31:58 -05:00
|
|
|
loop { }
|
2014-11-01 20:21:55 -07:00
|
|
|
}
|
|
|
|
|
|
2019-01-08 22:14:04 +01:00
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
|
|
impl Foo for Bar {}
|
|
|
|
|
|
2014-11-01 20:21:55 -07:00
|
|
|
fn main() {
|
2019-01-08 22:14:04 +01:00
|
|
|
let b: Box<dyn Foo> = Box::new(Bar);
|
2024-02-09 12:17:55 +00:00
|
|
|
//~^ ERROR E0038
|
2014-11-01 20:21:55 -07:00
|
|
|
}
|