]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/arbitrary-self-types-not-object-safe.rs
Update ui tests
[rust.git] / src / test / ui / self / arbitrary-self-types-not-object-safe.rs
1 #![feature(arbitrary_self_types)]
2
3 use std::rc::Rc;
4
5 trait Foo {
6     fn foo(self: &Rc<Self>) -> usize;
7 }
8
9 trait Bar {
10     fn foo(self: &Rc<Self>) -> usize where Self: Sized;
11     fn bar(self: Rc<Self>) -> usize;
12 }
13
14 impl Foo for usize {
15     fn foo(self: &Rc<Self>) -> usize {
16         **self
17     }
18 }
19
20 impl Bar for usize {
21     fn foo(self: &Rc<Self>) -> usize {
22         **self
23     }
24
25     fn bar(self: Rc<Self>) -> usize {
26         *self
27     }
28 }
29
30 fn make_foo() {
31     let x = Rc::new(5usize) as Rc<dyn Foo>;
32     //~^ ERROR E0038
33     //~| ERROR E0038
34 }
35
36 fn make_bar() {
37     let x = Rc::new(5usize) as Rc<dyn Bar>;
38     x.bar();
39 }
40
41 fn main() {}