]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-safety/object-safety-mentions-Self.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / object-safety / object-safety-mentions-Self.rs
1 // Check that we correctly prevent users from making trait objects
2 // form traits that make use of `Self` in an argument or return
3 // position, unless `where Self : Sized` is present..
4
5 trait Bar {
6     fn bar(&self, x: &Self);
7 }
8
9 trait Baz {
10     fn bar(&self) -> Self;
11 }
12
13 trait Quux {
14     fn get(&self, s: &Self) -> Self where Self : Sized;
15 }
16
17 fn make_bar<T:Bar>(t: &T) -> &Bar {
18         //~^ ERROR E0038
19     loop { }
20 }
21
22 fn make_baz<T:Baz>(t: &T) -> &Baz {
23         //~^ ERROR E0038
24     t
25 }
26
27 fn make_quux<T:Quux>(t: &T) -> &Quux {
28     t
29 }
30
31 fn make_quux_explicit<T:Quux>(t: &T) -> &Quux {
32     t as &Quux
33 }
34
35 fn main() {
36 }