1
Fork 0
rust/tests/ui/object-safety/object-safety-no-static.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
470 B
Rust
Raw Normal View History

// Check that we correctly prevent users from making trait objects
// from traits with static methods.
//
//@ revisions: curr object_safe_for_dispatch
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
2014-11-01 20:21:55 -07:00
2015-04-17 22:12:20 -07:00
trait Foo {
fn foo() {}
2014-11-01 20:21:55 -07:00
}
fn diverges() -> Box<dyn Foo> {
//[curr]~^ ERROR E0038
loop { }
2014-11-01 20:21:55 -07:00
}
struct Bar;
impl Foo for Bar {}
2014-11-01 20:21:55 -07:00
fn main() {
let b: Box<dyn Foo> = Box::new(Bar);
//~^ ERROR E0038
//[curr]~| ERROR E0038
2014-11-01 20:21:55 -07:00
}