blob: 7256c2697ceeb3aeeb12261a171c20ce4824f1b6 (
plain)
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
|
//! FIXME: write short doc here
use super::*;
pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) {
let m;
if p.at(T![::]) && p.nth(2) == T![<] {
m = p.start();
p.bump(T![::]);
p.bump(T![<]);
} else if !colon_colon_required && p.at(T![<]) && p.nth(1) != T![=] {
m = p.start();
p.bump(T![<]);
} else {
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(LIFETIME);
m.complete(p, LIFETIME_ARG);
}
// test associated_type_bounds
// fn print_all<T: Iterator<Item: Display>>(printables: T) {}
IDENT if p.nth(1) == T![:] && p.nth(2) != 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_any();
types::type_(p);
m.complete(p, ASSOC_TYPE_ARG);
}
_ => {
types::type_(p);
m.complete(p, TYPE_ARG);
}
}
}
|