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