1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// Test traits
trait Foo {
fn bar(x: i32 ) -> Baz< U> { Baz::new()
}
fn baz(a: AAAAAAAAAAAAAAAAAAAAAA,
b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
-> RetType;
fn foo(a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Another comment
b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
-> RetType ; // Some comment
fn baz(&mut self ) -> i32 ;
fn increment(& mut self, x: i32 );
fn read(&mut self, x: BufReader<R> /* Used to be MemReader */)
where R: Read;
}
pub trait WriteMessage {
fn write_message (&mut self, &FrontendMessage) -> io::Result<()>;
}
trait Runnable {
fn handler(self: & Runnable );
}
trait TraitWithExpr {
fn fn_with_expr(x: [i32; 1]);
}
trait Test {
fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) -> Result<T, Self::Error> where F: FnOnce(&mut Self) -> Result<T, Self::Error>;
}
trait T<> {}
trait Foo { type Bar: Baz; type Inner: Foo = Box< Foo >; }
trait ConstCheck<T>:Foo where T: Baz {
const J: i32;
}
trait Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T>
where T: Foo {}
trait Ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T> where T: Foo {}
trait FooBar<T> : Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt where J: Bar { fn test(); }
trait WhereList<T, J> where T: Foo, J: Bar {}
trait X /* comment */ {}
trait Y // comment
{
}
// #2055
pub trait Foo:
// A and C
A + C
// and B
+ B
{}
// #2158
trait Foo {
type ItRev = <MergingUntypedTimeSeries<SliceSeries<SliceWindow>> as UntypedTimeSeries>::IterRev;
type IteRev = <MergingUntypedTimeSeries<SliceSeries<SliceWindow>> as UntypedTimeSeries>::IterRev;
}
// #2331
trait MyTrait<AAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBBBBBBBBBB, CCCCCCCCCCCCCCCCCCCC, DDDDDDDDDDDDDDDDDDDD> {
fn foo() {}
}
// Trait aliases
trait FooBar =
Foo
+ Bar;
trait FooBar <A, B, C>=
Foo
+ Bar;
pub trait FooBar =
Foo
+ Bar;
pub trait FooBar <A, B, C>=
Foo
+ Bar;
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
pub trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
trait AAAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDDD;
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> = FooBar;
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> = FooBar;
#[rustfmt::skip]
trait FooBar = Foo
+ Bar;
// #2637
auto trait Example {}
pub auto trait PubExample {}
pub unsafe auto trait PubUnsafeExample {}
// #3006
trait Foo<'a> {
type Bar< 'a >;
}
impl<'a> Foo<'a> for i32 {
type Bar< 'a > = i32;
}
// #3092
pub mod test {
pub trait ATraitWithALooongName {}
pub trait ATrait
:ATraitWithALooongName + ATraitWithALooongName + ATraitWithALooongName + ATraitWithALooongName
{
}
}
// Trait aliases with where clauses.
trait A = where for<'b> &'b Self: Send;
trait B = where for<'b> &'b Self: Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCC;
trait B = where for<'b> &'b Self: Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCCC;
trait B = where
for<'b> &'b Self:
Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCCCCCCCCCCCCCCC;
trait B = where
for<'b> &'b Self:
Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC;
trait B = where
for<'b> &'b Self:
Send
+ Clone
+ Copy
+ SomeTrait
+ AAAAAAAA
+ BBBBBBB
+ CCCCCCCCC
+ DDDDDDD
+ DDDDDDDD
+ DDDDDDDDD
+ EEEEEEE;
trait A<'a, 'b, 'c> = Debug<T> + Foo where for<'b> &'b Self: Send;
trait B<'a, 'b, 'c> = Debug<T> +Foo
where for<'b> &'b Self:
Send
+ Clone
+ Copy
+ SomeTrait
+ AAAAAAAA
+ BBBBBBB
+ CCCCCCCCC
+ DDDDDDD;
trait B<'a, 'b, 'c,T> = Debug<'a, T> where for<'b> &'b Self:
Send
+ Clone
+ Copy
+ SomeTrait
+ AAAAAAAA
+ BBBBBBB
+ CCCCCCCCC
+ DDDDDDD
+ DDDDDDDD
+ DDDDDDDDD
+ EEEEEEE;
trait Visible {
pub const C: i32;
pub type T;
pub fn f();
pub fn g() {}
}
|