]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-safety/object-safety-no-static.rs
Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22
[rust.git] / src / test / ui / object-safety / object-safety-no-static.rs
1 // Check that we correctly prevent users from making trait objects
2 // from traits with static methods.
3 //
4 // revisions: curr object_safe_for_dispatch
5
6 #![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
7
8 trait Foo {
9     fn foo() {}
10 }
11
12 fn diverges() -> Box<dyn Foo> {
13     //[curr]~^ ERROR E0038
14     loop { }
15 }
16
17 struct Bar;
18
19 impl Foo for Bar {}
20
21 fn main() {
22     let b: Box<dyn Foo> = Box::new(Bar);
23     //[object_safe_for_dispatch]~^ ERROR E0038
24 }