Debian Codegraph @

tests/ui/maybe.rs

raw
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2
3 // See also `maybe` test in test.rs
4
5 use easy_ext::ext;
6
7 #[ext(E1)]
8 impl<T: ?Sized> T // Ok
9 {
10 fn f(&self) {}
11 }
12
13 #[ext(E2)]
14 impl<T> T
15 where
16 T: ?Sized, // Ok
17 {
18 fn f(&self) {}
19 }
20
21 #[ext(E3)]
22 impl<T> T
23 where
24 Self: ?Sized,
25 {
26 //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
27 fn f(&self) {}
28 }
29
30 // The following is a case where #[ext] is not used. The behavior should match in both cases.
31
32 trait T1
33 where
34 Self: ?Sized,
35 {
36 //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
37 fn f(&self);
38 }
39
40 trait T2 {
41 fn f(&self);
42 }
43 impl<T> T2 for T
44 where
45 Self: ?Sized,
46 {
47 //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
48 fn f(&self) {}
49 }
50
51 trait T3 {
52 fn f(&self);
53 }
54 impl<T: ?Sized> T3 for T // Ok
55 {
56 fn f(&self) {}
57 }
58
59 trait T4 {
60 fn f(&self);
61 }
62 impl<T> T4 for T
63 where
64 T: ?Sized, // Ok
65 {
66 fn f(&self) {}
67 }
68
69 trait T5 {
70 fn f(&self);
71 }
72 impl<T> T5 for T {
73 fn f(&self)
74 where
75 T: ?Sized,
76 {
77 //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
78 }
79 }
80
81 fn main() {}