]> git.proxmox.com Git - rustc.git/blob - src/test/ui/object-safety/object-safety-no-static.rs
New upstream version 1.40.0+dfsg1
[rustc.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 }