diff options
Diffstat (limited to 'crates/ra_parser/src/grammar/items')
-rw-r--r-- | crates/ra_parser/src/grammar/items/consts.rs | 10 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/nominal.rs | 66 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/traits.rs | 38 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/use_item.rs | 30 |
4 files changed, 72 insertions, 72 deletions
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs index 1f802246f..b4908ebba 100644 --- a/crates/ra_parser/src/grammar/items/consts.rs +++ b/crates/ra_parser/src/grammar/items/consts.rs | |||
@@ -1,22 +1,22 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn static_def(p: &mut Parser, m: Marker) { | 3 | pub(super) fn static_def(p: &mut Parser, m: Marker) { |
4 | const_or_static(p, m, STATIC_KW, STATIC_DEF) | 4 | const_or_static(p, m, T![static], STATIC_DEF) |
5 | } | 5 | } |
6 | 6 | ||
7 | pub(super) fn const_def(p: &mut Parser, m: Marker) { | 7 | pub(super) fn const_def(p: &mut Parser, m: Marker) { |
8 | const_or_static(p, m, CONST_KW, CONST_DEF) | 8 | const_or_static(p, m, T![const], CONST_DEF) |
9 | } | 9 | } |
10 | 10 | ||
11 | fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { | 11 | fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { |
12 | assert!(p.at(kw)); | 12 | assert!(p.at(kw)); |
13 | p.bump(); | 13 | p.bump(); |
14 | p.eat(MUT_KW); // FIXME: validator to forbid const mut | 14 | p.eat(T![mut]); // FIXME: validator to forbid const mut |
15 | name(p); | 15 | name(p); |
16 | types::ascription(p); | 16 | types::ascription(p); |
17 | if p.eat(EQ) { | 17 | if p.eat(T![=]) { |
18 | expressions::expr(p); | 18 | expressions::expr(p); |
19 | } | 19 | } |
20 | p.expect(SEMI); | 20 | p.expect(T![;]); |
21 | m.complete(p, def); | 21 | m.complete(p, def); |
22 | } | 22 | } |
diff --git a/crates/ra_parser/src/grammar/items/nominal.rs b/crates/ra_parser/src/grammar/items/nominal.rs index e93bd76b8..bd4edab89 100644 --- a/crates/ra_parser/src/grammar/items/nominal.rs +++ b/crates/ra_parser/src/grammar/items/nominal.rs | |||
@@ -1,38 +1,38 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | 3 | pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { |
4 | assert!(p.at(STRUCT_KW) || p.at_contextual_kw("union")); | 4 | assert!(p.at(T![struct]) || p.at_contextual_kw("union")); |
5 | p.bump_remap(kind); | 5 | p.bump_remap(kind); |
6 | 6 | ||
7 | name_r(p, ITEM_RECOVERY_SET); | 7 | name_r(p, ITEM_RECOVERY_SET); |
8 | type_params::opt_type_param_list(p); | 8 | type_params::opt_type_param_list(p); |
9 | match p.current() { | 9 | match p.current() { |
10 | WHERE_KW => { | 10 | T![where] => { |
11 | type_params::opt_where_clause(p); | 11 | type_params::opt_where_clause(p); |
12 | match p.current() { | 12 | match p.current() { |
13 | SEMI => { | 13 | T![;] => { |
14 | p.bump(); | 14 | p.bump(); |
15 | } | 15 | } |
16 | L_CURLY => named_field_def_list(p), | 16 | T!['{'] => named_field_def_list(p), |
17 | _ => { | 17 | _ => { |
18 | //FIXME: special case `(` error message | 18 | //FIXME: special case `(` error message |
19 | p.error("expected `;` or `{`"); | 19 | p.error("expected `;` or `{`"); |
20 | } | 20 | } |
21 | } | 21 | } |
22 | } | 22 | } |
23 | SEMI if kind == STRUCT_KW => { | 23 | T![;] if kind == T![struct] => { |
24 | p.bump(); | 24 | p.bump(); |
25 | } | 25 | } |
26 | L_CURLY => named_field_def_list(p), | 26 | T!['{'] => named_field_def_list(p), |
27 | L_PAREN if kind == STRUCT_KW => { | 27 | T!['('] if kind == T![struct] => { |
28 | pos_field_def_list(p); | 28 | pos_field_def_list(p); |
29 | // test tuple_struct_where | 29 | // test tuple_struct_where |
30 | // struct Test<T>(T) where T: Clone; | 30 | // struct Test<T>(T) where T: Clone; |
31 | // struct Test<T>(T); | 31 | // struct Test<T>(T); |
32 | type_params::opt_where_clause(p); | 32 | type_params::opt_where_clause(p); |
33 | p.expect(SEMI); | 33 | p.expect(T![;]); |
34 | } | 34 | } |
35 | _ if kind == STRUCT_KW => { | 35 | _ if kind == T![struct] => { |
36 | p.error("expected `;`, `{`, or `(`"); | 36 | p.error("expected `;`, `{`, or `(`"); |
37 | } | 37 | } |
38 | _ => { | 38 | _ => { |
@@ -43,12 +43,12 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
43 | } | 43 | } |
44 | 44 | ||
45 | pub(super) fn enum_def(p: &mut Parser, m: Marker) { | 45 | pub(super) fn enum_def(p: &mut Parser, m: Marker) { |
46 | assert!(p.at(ENUM_KW)); | 46 | assert!(p.at(T![enum])); |
47 | p.bump(); | 47 | p.bump(); |
48 | name_r(p, ITEM_RECOVERY_SET); | 48 | name_r(p, ITEM_RECOVERY_SET); |
49 | type_params::opt_type_param_list(p); | 49 | type_params::opt_type_param_list(p); |
50 | type_params::opt_where_clause(p); | 50 | type_params::opt_where_clause(p); |
51 | if p.at(L_CURLY) { | 51 | if p.at(T!['{']) { |
52 | enum_variant_list(p); | 52 | enum_variant_list(p); |
53 | } else { | 53 | } else { |
54 | p.error("expected `{`") | 54 | p.error("expected `{`") |
@@ -57,11 +57,11 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | pub(crate) fn enum_variant_list(p: &mut Parser) { | 59 | pub(crate) fn enum_variant_list(p: &mut Parser) { |
60 | assert!(p.at(L_CURLY)); | 60 | assert!(p.at(T!['{'])); |
61 | let m = p.start(); | 61 | let m = p.start(); |
62 | p.bump(); | 62 | p.bump(); |
63 | while !p.at(EOF) && !p.at(R_CURLY) { | 63 | while !p.at(EOF) && !p.at(T!['}']) { |
64 | if p.at(L_CURLY) { | 64 | if p.at(T!['{']) { |
65 | error_block(p, "expected enum variant"); | 65 | error_block(p, "expected enum variant"); |
66 | continue; | 66 | continue; |
67 | } | 67 | } |
@@ -70,9 +70,9 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { | |||
70 | if p.at(IDENT) { | 70 | if p.at(IDENT) { |
71 | name(p); | 71 | name(p); |
72 | match p.current() { | 72 | match p.current() { |
73 | L_CURLY => named_field_def_list(p), | 73 | T!['{'] => named_field_def_list(p), |
74 | L_PAREN => pos_field_def_list(p), | 74 | T!['('] => pos_field_def_list(p), |
75 | EQ => { | 75 | T![=] => { |
76 | p.bump(); | 76 | p.bump(); |
77 | expressions::expr(p); | 77 | expressions::expr(p); |
78 | } | 78 | } |
@@ -83,29 +83,29 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { | |||
83 | var.abandon(p); | 83 | var.abandon(p); |
84 | p.err_and_bump("expected enum variant"); | 84 | p.err_and_bump("expected enum variant"); |
85 | } | 85 | } |
86 | if !p.at(R_CURLY) { | 86 | if !p.at(T!['}']) { |
87 | p.expect(COMMA); | 87 | p.expect(T![,]); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | p.expect(R_CURLY); | 90 | p.expect(T!['}']); |
91 | m.complete(p, ENUM_VARIANT_LIST); | 91 | m.complete(p, ENUM_VARIANT_LIST); |
92 | } | 92 | } |
93 | 93 | ||
94 | pub(crate) fn named_field_def_list(p: &mut Parser) { | 94 | pub(crate) fn named_field_def_list(p: &mut Parser) { |
95 | assert!(p.at(L_CURLY)); | 95 | assert!(p.at(T!['{'])); |
96 | let m = p.start(); | 96 | let m = p.start(); |
97 | p.bump(); | 97 | p.bump(); |
98 | while !p.at(R_CURLY) && !p.at(EOF) { | 98 | while !p.at(T!['}']) && !p.at(EOF) { |
99 | if p.at(L_CURLY) { | 99 | if p.at(T!['{']) { |
100 | error_block(p, "expected field"); | 100 | error_block(p, "expected field"); |
101 | continue; | 101 | continue; |
102 | } | 102 | } |
103 | named_field_def(p); | 103 | named_field_def(p); |
104 | if !p.at(R_CURLY) { | 104 | if !p.at(T!['}']) { |
105 | p.expect(COMMA); | 105 | p.expect(T![,]); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | p.expect(R_CURLY); | 108 | p.expect(T!['}']); |
109 | m.complete(p, NAMED_FIELD_DEF_LIST); | 109 | m.complete(p, NAMED_FIELD_DEF_LIST); |
110 | 110 | ||
111 | fn named_field_def(p: &mut Parser) { | 111 | fn named_field_def(p: &mut Parser) { |
@@ -119,7 +119,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { | |||
119 | opt_visibility(p); | 119 | opt_visibility(p); |
120 | if p.at(IDENT) { | 120 | if p.at(IDENT) { |
121 | name(p); | 121 | name(p); |
122 | p.expect(COLON); | 122 | p.expect(T![:]); |
123 | types::type_(p); | 123 | types::type_(p); |
124 | m.complete(p, NAMED_FIELD_DEF); | 124 | m.complete(p, NAMED_FIELD_DEF); |
125 | } else { | 125 | } else { |
@@ -130,12 +130,12 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { | |||
130 | } | 130 | } |
131 | 131 | ||
132 | fn pos_field_def_list(p: &mut Parser) { | 132 | fn pos_field_def_list(p: &mut Parser) { |
133 | assert!(p.at(L_PAREN)); | 133 | assert!(p.at(T!['('])); |
134 | let m = p.start(); | 134 | let m = p.start(); |
135 | if !p.expect(L_PAREN) { | 135 | if !p.expect(T!['(']) { |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | while !p.at(R_PAREN) && !p.at(EOF) { | 138 | while !p.at(T![')']) && !p.at(EOF) { |
139 | let m = p.start(); | 139 | let m = p.start(); |
140 | // test pos_field_attrs | 140 | // test pos_field_attrs |
141 | // struct S ( | 141 | // struct S ( |
@@ -156,10 +156,10 @@ fn pos_field_def_list(p: &mut Parser) { | |||
156 | types::type_(p); | 156 | types::type_(p); |
157 | m.complete(p, POS_FIELD_DEF); | 157 | m.complete(p, POS_FIELD_DEF); |
158 | 158 | ||
159 | if !p.at(R_PAREN) { | 159 | if !p.at(T![')']) { |
160 | p.expect(COMMA); | 160 | p.expect(T![,]); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | p.expect(R_PAREN); | 163 | p.expect(T![')']); |
164 | m.complete(p, POS_FIELD_DEF_LIST); | 164 | m.complete(p, POS_FIELD_DEF_LIST); |
165 | } | 165 | } |
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs index d03a6be0d..09ab3bfd4 100644 --- a/crates/ra_parser/src/grammar/items/traits.rs +++ b/crates/ra_parser/src/grammar/items/traits.rs | |||
@@ -4,15 +4,15 @@ use super::*; | |||
4 | // trait T<U>: Hash + Clone where U: Copy {} | 4 | // trait T<U>: Hash + Clone where U: Copy {} |
5 | // trait X<U: Debug + Display>: Hash + Clone where U: Copy {} | 5 | // trait X<U: Debug + Display>: Hash + Clone where U: Copy {} |
6 | pub(super) fn trait_def(p: &mut Parser) { | 6 | pub(super) fn trait_def(p: &mut Parser) { |
7 | assert!(p.at(TRAIT_KW)); | 7 | assert!(p.at(T![trait])); |
8 | p.bump(); | 8 | p.bump(); |
9 | name_r(p, ITEM_RECOVERY_SET); | 9 | name_r(p, ITEM_RECOVERY_SET); |
10 | type_params::opt_type_param_list(p); | 10 | type_params::opt_type_param_list(p); |
11 | if p.at(COLON) { | 11 | if p.at(T![:]) { |
12 | type_params::bounds(p); | 12 | type_params::bounds(p); |
13 | } | 13 | } |
14 | type_params::opt_where_clause(p); | 14 | type_params::opt_where_clause(p); |
15 | if p.at(L_CURLY) { | 15 | if p.at(T!['{']) { |
16 | trait_item_list(p); | 16 | trait_item_list(p); |
17 | } else { | 17 | } else { |
18 | p.error("expected `{`"); | 18 | p.error("expected `{`"); |
@@ -27,24 +27,24 @@ pub(super) fn trait_def(p: &mut Parser) { | |||
27 | // fn bar(&self); | 27 | // fn bar(&self); |
28 | // } | 28 | // } |
29 | pub(crate) fn trait_item_list(p: &mut Parser) { | 29 | pub(crate) fn trait_item_list(p: &mut Parser) { |
30 | assert!(p.at(L_CURLY)); | 30 | assert!(p.at(T!['{'])); |
31 | let m = p.start(); | 31 | let m = p.start(); |
32 | p.bump(); | 32 | p.bump(); |
33 | while !p.at(EOF) && !p.at(R_CURLY) { | 33 | while !p.at(EOF) && !p.at(T!['}']) { |
34 | if p.at(L_CURLY) { | 34 | if p.at(T!['{']) { |
35 | error_block(p, "expected an item"); | 35 | error_block(p, "expected an item"); |
36 | continue; | 36 | continue; |
37 | } | 37 | } |
38 | item_or_macro(p, true, ItemFlavor::Trait); | 38 | item_or_macro(p, true, ItemFlavor::Trait); |
39 | } | 39 | } |
40 | p.expect(R_CURLY); | 40 | p.expect(T!['}']); |
41 | m.complete(p, ITEM_LIST); | 41 | m.complete(p, ITEM_LIST); |
42 | } | 42 | } |
43 | 43 | ||
44 | // test impl_block | 44 | // test impl_block |
45 | // impl Foo {} | 45 | // impl Foo {} |
46 | pub(super) fn impl_block(p: &mut Parser) { | 46 | pub(super) fn impl_block(p: &mut Parser) { |
47 | assert!(p.at(IMPL_KW)); | 47 | assert!(p.at(T![impl ])); |
48 | p.bump(); | 48 | p.bump(); |
49 | if choose_type_params_over_qpath(p) { | 49 | if choose_type_params_over_qpath(p) { |
50 | type_params::opt_type_param_list(p); | 50 | type_params::opt_type_param_list(p); |
@@ -55,13 +55,13 @@ pub(super) fn impl_block(p: &mut Parser) { | |||
55 | 55 | ||
56 | // test impl_block_neg | 56 | // test impl_block_neg |
57 | // impl !Send for X {} | 57 | // impl !Send for X {} |
58 | p.eat(EXCL); | 58 | p.eat(T![!]); |
59 | impl_type(p); | 59 | impl_type(p); |
60 | if p.eat(FOR_KW) { | 60 | if p.eat(T![for]) { |
61 | impl_type(p); | 61 | impl_type(p); |
62 | } | 62 | } |
63 | type_params::opt_where_clause(p); | 63 | type_params::opt_where_clause(p); |
64 | if p.at(L_CURLY) { | 64 | if p.at(T!['{']) { |
65 | impl_item_list(p); | 65 | impl_item_list(p); |
66 | } else { | 66 | } else { |
67 | p.error("expected `{`"); | 67 | p.error("expected `{`"); |
@@ -76,7 +76,7 @@ pub(super) fn impl_block(p: &mut Parser) { | |||
76 | // fn bar(&self) {} | 76 | // fn bar(&self) {} |
77 | // } | 77 | // } |
78 | pub(crate) fn impl_item_list(p: &mut Parser) { | 78 | pub(crate) fn impl_item_list(p: &mut Parser) { |
79 | assert!(p.at(L_CURLY)); | 79 | assert!(p.at(T!['{'])); |
80 | let m = p.start(); | 80 | let m = p.start(); |
81 | p.bump(); | 81 | p.bump(); |
82 | // test impl_inner_attributes | 82 | // test impl_inner_attributes |
@@ -87,14 +87,14 @@ pub(crate) fn impl_item_list(p: &mut Parser) { | |||
87 | // } | 87 | // } |
88 | attributes::inner_attributes(p); | 88 | attributes::inner_attributes(p); |
89 | 89 | ||
90 | while !p.at(EOF) && !p.at(R_CURLY) { | 90 | while !p.at(EOF) && !p.at(T!['}']) { |
91 | if p.at(L_CURLY) { | 91 | if p.at(T!['{']) { |
92 | error_block(p, "expected an item"); | 92 | error_block(p, "expected an item"); |
93 | continue; | 93 | continue; |
94 | } | 94 | } |
95 | item_or_macro(p, true, ItemFlavor::Mod); | 95 | item_or_macro(p, true, ItemFlavor::Mod); |
96 | } | 96 | } |
97 | p.expect(R_CURLY); | 97 | p.expect(T!['}']); |
98 | m.complete(p, ITEM_LIST); | 98 | m.complete(p, ITEM_LIST); |
99 | } | 99 | } |
100 | 100 | ||
@@ -114,14 +114,14 @@ fn choose_type_params_over_qpath(p: &Parser) -> bool { | |||
114 | // we disambiguate it in favor of generics (`impl<T> ::absolute::Path<T> { ... }`) | 114 | // we disambiguate it in favor of generics (`impl<T> ::absolute::Path<T> { ... }`) |
115 | // because this is what almost always expected in practice, qualified paths in impls | 115 | // because this is what almost always expected in practice, qualified paths in impls |
116 | // (`impl <Type>::AssocTy { ... }`) aren't even allowed by type checker at the moment. | 116 | // (`impl <Type>::AssocTy { ... }`) aren't even allowed by type checker at the moment. |
117 | if !p.at(L_ANGLE) { | 117 | if !p.at(T![<]) { |
118 | return false; | 118 | return false; |
119 | } | 119 | } |
120 | if p.nth(1) == POUND || p.nth(1) == R_ANGLE { | 120 | if p.nth(1) == T![#] || p.nth(1) == T![>] { |
121 | return true; | 121 | return true; |
122 | } | 122 | } |
123 | (p.nth(1) == LIFETIME || p.nth(1) == IDENT) | 123 | (p.nth(1) == LIFETIME || p.nth(1) == IDENT) |
124 | && (p.nth(2) == R_ANGLE || p.nth(2) == COMMA || p.nth(2) == COLON || p.nth(2) == EQ) | 124 | && (p.nth(2) == T![>] || p.nth(2) == T![,] || p.nth(2) == T![:] || p.nth(2) == T![=]) |
125 | } | 125 | } |
126 | 126 | ||
127 | // test_err impl_type | 127 | // test_err impl_type |
@@ -130,7 +130,7 @@ fn choose_type_params_over_qpath(p: &Parser) -> bool { | |||
130 | // impl impl NotType {} | 130 | // impl impl NotType {} |
131 | // impl Trait2 for impl NotType {} | 131 | // impl Trait2 for impl NotType {} |
132 | pub(crate) fn impl_type(p: &mut Parser) { | 132 | pub(crate) fn impl_type(p: &mut Parser) { |
133 | if p.at(IMPL_KW) { | 133 | if p.at(T![impl ]) { |
134 | p.error("expected trait or type"); | 134 | p.error("expected trait or type"); |
135 | return; | 135 | return; |
136 | } | 136 | } |
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index 908493789..c3a0b4410 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn use_item(p: &mut Parser, m: Marker) { | 3 | pub(super) fn use_item(p: &mut Parser, m: Marker) { |
4 | assert!(p.at(USE_KW)); | 4 | assert!(p.at(T![use])); |
5 | p.bump(); | 5 | p.bump(); |
6 | use_tree(p); | 6 | use_tree(p); |
7 | p.expect(SEMI); | 7 | p.expect(T![;]); |
8 | m.complete(p, USE_ITEM); | 8 | m.complete(p, USE_ITEM); |
9 | } | 9 | } |
10 | 10 | ||
@@ -28,8 +28,8 @@ fn use_tree(p: &mut Parser) { | |||
28 | // use ::*; | 28 | // use ::*; |
29 | // use some::path::{*}; | 29 | // use some::path::{*}; |
30 | // use some::path::{::*}; | 30 | // use some::path::{::*}; |
31 | (STAR, _) => p.bump(), | 31 | (T![*], _) => p.bump(), |
32 | (COLONCOLON, STAR) => { | 32 | (T![::], T![*]) => { |
33 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 | 33 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 |
34 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) | 34 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) |
35 | // but still parses and errors later: ('crate root in paths can only be used in start position') | 35 | // but still parses and errors later: ('crate root in paths can only be used in start position') |
@@ -47,8 +47,8 @@ fn use_tree(p: &mut Parser) { | |||
47 | // use {path::from::root}; // Rust 2015 | 47 | // use {path::from::root}; // Rust 2015 |
48 | // use ::{some::arbritrary::path}; // Rust 2015 | 48 | // use ::{some::arbritrary::path}; // Rust 2015 |
49 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | 49 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig |
50 | (L_CURLY, _) | (COLONCOLON, L_CURLY) => { | 50 | (T!['{'], _) | (T![::], T!['{']) => { |
51 | if p.at(COLONCOLON) { | 51 | if p.at(T![::]) { |
52 | p.bump(); | 52 | p.bump(); |
53 | } | 53 | } |
54 | use_tree_list(p); | 54 | use_tree_list(p); |
@@ -68,7 +68,7 @@ fn use_tree(p: &mut Parser) { | |||
68 | _ if paths::is_path_start(p) => { | 68 | _ if paths::is_path_start(p) => { |
69 | paths::use_path(p); | 69 | paths::use_path(p); |
70 | match p.current() { | 70 | match p.current() { |
71 | AS_KW => { | 71 | T![as] => { |
72 | // test use_alias | 72 | // test use_alias |
73 | // use some::path as some_name; | 73 | // use some::path as some_name; |
74 | // use some::{ | 74 | // use some::{ |
@@ -80,16 +80,16 @@ fn use_tree(p: &mut Parser) { | |||
80 | // use Trait as _; | 80 | // use Trait as _; |
81 | opt_alias(p); | 81 | opt_alias(p); |
82 | } | 82 | } |
83 | COLONCOLON => { | 83 | T![::] => { |
84 | p.bump(); | 84 | p.bump(); |
85 | match p.current() { | 85 | match p.current() { |
86 | STAR => { | 86 | T![*] => { |
87 | p.bump(); | 87 | p.bump(); |
88 | } | 88 | } |
89 | // test use_tree_list_after_path | 89 | // test use_tree_list_after_path |
90 | // use crate::{Item}; | 90 | // use crate::{Item}; |
91 | // use self::{Item}; | 91 | // use self::{Item}; |
92 | L_CURLY => use_tree_list(p), | 92 | T!['{'] => use_tree_list(p), |
93 | _ => { | 93 | _ => { |
94 | // is this unreachable? | 94 | // is this unreachable? |
95 | p.error("expected `{` or `*`"); | 95 | p.error("expected `{` or `*`"); |
@@ -109,15 +109,15 @@ fn use_tree(p: &mut Parser) { | |||
109 | } | 109 | } |
110 | 110 | ||
111 | pub(crate) fn use_tree_list(p: &mut Parser) { | 111 | pub(crate) fn use_tree_list(p: &mut Parser) { |
112 | assert!(p.at(L_CURLY)); | 112 | assert!(p.at(T!['{'])); |
113 | let m = p.start(); | 113 | let m = p.start(); |
114 | p.bump(); | 114 | p.bump(); |
115 | while !p.at(EOF) && !p.at(R_CURLY) { | 115 | while !p.at(EOF) && !p.at(T!['}']) { |
116 | use_tree(p); | 116 | use_tree(p); |
117 | if !p.at(R_CURLY) { | 117 | if !p.at(T!['}']) { |
118 | p.expect(COMMA); | 118 | p.expect(T![,]); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | p.expect(R_CURLY); | 121 | p.expect(T!['}']); |
122 | m.complete(p, USE_TREE_LIST); | 122 | m.complete(p, USE_TREE_LIST); |
123 | } | 123 | } |