rust/tests/ui/dyn-compatibility/no-static.rs

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

22 lines
335 B
Rust
Raw Normal View History

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