2014-12-16 02:11:09 +00:00
|
|
|
// Check that we correctly prevent users from making trait objects
|
|
|
|
// from traits with static methods.
|
2019-01-08 21:14:04 +00:00
|
|
|
//
|
|
|
|
// revisions: curr object_safe_for_dispatch
|
|
|
|
|
|
|
|
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
2014-11-02 03:21:55 +00:00
|
|
|
|
2015-04-18 05:12:20 +00:00
|
|
|
trait Foo {
|
2019-01-08 21:14:04 +00:00
|
|
|
fn foo() {}
|
2014-11-02 03:21:55 +00:00
|
|
|
}
|
|
|
|
|
2019-01-08 21:14:04 +00:00
|
|
|
fn diverges() -> Box<dyn Foo> {
|
|
|
|
//[curr]~^ ERROR E0038
|
2015-12-15 09:31:58 +00:00
|
|
|
loop { }
|
2014-11-02 03:21:55 +00:00
|
|
|
}
|
|
|
|
|
2019-01-08 21:14:04 +00:00
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
impl Foo for Bar {}
|
|
|
|
|
2014-11-02 03:21:55 +00:00
|
|
|
fn main() {
|
2019-01-08 21:14:04 +00:00
|
|
|
let b: Box<dyn Foo> = Box::new(Bar);
|
|
|
|
//[object_safe_for_dispatch]~^ ERROR E0038
|
2014-11-02 03:21:55 +00:00
|
|
|
}
|