]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / impl-trait / object-unsafe-trait-in-return-position-impl-trait.rs
1 trait NotObjectSafe {
2     fn foo() -> Self;
3 }
4
5 trait ObjectSafe {
6     fn bar(&self);
7 }
8
9 struct A;
10 struct B;
11
12 impl NotObjectSafe for A {
13     fn foo() -> Self {
14         A
15     }
16 }
17
18 impl NotObjectSafe for B {
19     fn foo() -> Self {
20         B
21     }
22 }
23
24 impl ObjectSafe for A {
25     fn bar(&self) {}
26 }
27
28 impl ObjectSafe for B {
29     fn bar(&self) {}
30 }
31
32 fn can() -> impl NotObjectSafe {
33     if true {
34         return A;
35     }
36     B //~ ERROR mismatched types
37 }
38
39 fn cat() -> impl ObjectSafe {
40     if true {
41         return A;
42     }
43     B //~ ERROR mismatched types
44 }
45
46 fn main() {}