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
|
use super::*;
pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) {
let m;
match (colon_colon_required, p.nth(0), p.nth(1)) {
(_, T![::], T![<]) => {
m = p.start();
p.bump();
p.bump();
}
(false, T![<], T![=]) => return,
(false, T![<], _) => {
m = p.start();
p.bump();
}
_ => return,
};
while !p.at(EOF) && !p.at(T![>]) {
type_arg(p);
if !p.at(T![>]) && !p.expect(T![,]) {
break;
}
}
p.expect(T![>]);
m.complete(p, TYPE_ARG_LIST);
}
// test type_arg
// type A = B<'static, i32, Item=u64>;
fn type_arg(p: &mut Parser) {
let m = p.start();
match p.current() {
LIFETIME => {
p.bump();
m.complete(p, LIFETIME_ARG);
}
// test associated_type_bounds
// fn print_all<T: Iterator<Item: Display>>(printables: T) {}
IDENT if p.nth(1) == T![:] => {
name_ref(p);
type_params::bounds(p);
m.complete(p, ASSOC_TYPE_ARG);
}
IDENT if p.nth(1) == T![=] => {
name_ref(p);
p.bump();
types::type_(p);
m.complete(p, ASSOC_TYPE_ARG);
}
_ => {
types::type_(p);
m.complete(p, TYPE_ARG);
}
}
}
|