diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-23 15:01:06 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-23 15:01:06 +0100 |
commit | a832a2f7dd22c93bc69a7be5d24799bb042b8129 (patch) | |
tree | 15f55b3eab48c3d0bbb1975fbd4db7cbb56d3e3e /crates/ra_parser/src | |
parent | c12dce0073c1766f7d2b10a69f8526a8093e70dc (diff) | |
parent | 5b18a4eef9e69260ce2f105b33553c929cb7d827 (diff) |
Merge #1731
1731: rename pos_field -> tuple_field r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 14 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/nominal.rs | 30 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/patterns.rs | 16 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 20 |
6 files changed, 44 insertions, 44 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index beedac457..dee3a229d 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -150,8 +150,8 @@ pub(crate) fn reparser( | |||
150 | ) -> Option<fn(&mut Parser)> { | 150 | ) -> Option<fn(&mut Parser)> { |
151 | let res = match node { | 151 | let res = match node { |
152 | BLOCK => expressions::block, | 152 | BLOCK => expressions::block, |
153 | NAMED_FIELD_DEF_LIST => items::named_field_def_list, | 153 | RECORD_FIELD_DEF_LIST => items::record_field_def_list, |
154 | NAMED_FIELD_LIST => items::named_field_list, | 154 | RECORD_FIELD_LIST => items::record_field_list, |
155 | ENUM_VARIANT_LIST => items::enum_variant_list, | 155 | ENUM_VARIANT_LIST => items::enum_variant_list, |
156 | MATCH_ARM_LIST => items::match_arm_list, | 156 | MATCH_ARM_LIST => items::match_arm_list, |
157 | USE_TREE_LIST => items::use_tree_list, | 157 | USE_TREE_LIST => items::use_tree_list, |
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 0495f34ae..783d6a6f0 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -559,8 +559,8 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { | |||
559 | paths::expr_path(p); | 559 | paths::expr_path(p); |
560 | match p.current() { | 560 | match p.current() { |
561 | T!['{'] if !r.forbid_structs => { | 561 | T!['{'] if !r.forbid_structs => { |
562 | named_field_list(p); | 562 | record_field_list(p); |
563 | (m.complete(p, STRUCT_LIT), BlockLike::NotBlock) | 563 | (m.complete(p, RECORD_LIT), BlockLike::NotBlock) |
564 | } | 564 | } |
565 | T![!] => { | 565 | T![!] => { |
566 | let block_like = items::macro_call_after_excl(p); | 566 | let block_like = items::macro_call_after_excl(p); |
@@ -570,20 +570,20 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { | |||
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | // test struct_lit | 573 | // test record_lit |
574 | // fn foo() { | 574 | // fn foo() { |
575 | // S {}; | 575 | // S {}; |
576 | // S { x, y: 32, }; | 576 | // S { x, y: 32, }; |
577 | // S { x, y: 32, ..Default::default() }; | 577 | // S { x, y: 32, ..Default::default() }; |
578 | // TupleStruct { 0: 1 }; | 578 | // TupleStruct { 0: 1 }; |
579 | // } | 579 | // } |
580 | pub(crate) fn named_field_list(p: &mut Parser) { | 580 | pub(crate) fn record_field_list(p: &mut Parser) { |
581 | assert!(p.at(T!['{'])); | 581 | assert!(p.at(T!['{'])); |
582 | let m = p.start(); | 582 | let m = p.start(); |
583 | p.bump(); | 583 | p.bump(); |
584 | while !p.at(EOF) && !p.at(T!['}']) { | 584 | while !p.at(EOF) && !p.at(T!['}']) { |
585 | match p.current() { | 585 | match p.current() { |
586 | // test struct_literal_field_with_attr | 586 | // test record_literal_field_with_attr |
587 | // fn main() { | 587 | // fn main() { |
588 | // S { #[cfg(test)] field: 1 } | 588 | // S { #[cfg(test)] field: 1 } |
589 | // } | 589 | // } |
@@ -594,7 +594,7 @@ pub(crate) fn named_field_list(p: &mut Parser) { | |||
594 | if p.eat(T![:]) { | 594 | if p.eat(T![:]) { |
595 | expr(p); | 595 | expr(p); |
596 | } | 596 | } |
597 | m.complete(p, NAMED_FIELD); | 597 | m.complete(p, RECORD_FIELD); |
598 | } | 598 | } |
599 | T![..] => { | 599 | T![..] => { |
600 | p.bump(); | 600 | p.bump(); |
@@ -608,5 +608,5 @@ pub(crate) fn named_field_list(p: &mut Parser) { | |||
608 | } | 608 | } |
609 | } | 609 | } |
610 | p.expect(T!['}']); | 610 | p.expect(T!['}']); |
611 | m.complete(p, NAMED_FIELD_LIST); | 611 | m.complete(p, RECORD_FIELD_LIST); |
612 | } | 612 | } |
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index b7da44758..6d426206e 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -4,8 +4,8 @@ mod traits; | |||
4 | mod use_item; | 4 | mod use_item; |
5 | 5 | ||
6 | pub(crate) use self::{ | 6 | pub(crate) use self::{ |
7 | expressions::{match_arm_list, named_field_list}, | 7 | expressions::{match_arm_list, record_field_list}, |
8 | nominal::{enum_variant_list, named_field_def_list}, | 8 | nominal::{enum_variant_list, record_field_def_list}, |
9 | traits::{impl_item_list, trait_item_list}, | 9 | traits::{impl_item_list, trait_item_list}, |
10 | use_item::use_tree_list, | 10 | use_item::use_tree_list, |
11 | }; | 11 | }; |
diff --git a/crates/ra_parser/src/grammar/items/nominal.rs b/crates/ra_parser/src/grammar/items/nominal.rs index bd4edab89..54f02c7c9 100644 --- a/crates/ra_parser/src/grammar/items/nominal.rs +++ b/crates/ra_parser/src/grammar/items/nominal.rs | |||
@@ -13,7 +13,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
13 | T![;] => { | 13 | T![;] => { |
14 | p.bump(); | 14 | p.bump(); |
15 | } | 15 | } |
16 | T!['{'] => named_field_def_list(p), | 16 | T!['{'] => record_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 `{`"); |
@@ -23,9 +23,9 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
23 | T![;] if kind == T![struct] => { | 23 | T![;] if kind == T![struct] => { |
24 | p.bump(); | 24 | p.bump(); |
25 | } | 25 | } |
26 | T!['{'] => named_field_def_list(p), | 26 | T!['{'] => record_field_def_list(p), |
27 | T!['('] if kind == T![struct] => { | 27 | T!['('] if kind == T![struct] => { |
28 | pos_field_def_list(p); | 28 | tuple_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); |
@@ -70,8 +70,8 @@ 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 | T!['{'] => named_field_def_list(p), | 73 | T!['{'] => record_field_def_list(p), |
74 | T!['('] => pos_field_def_list(p), | 74 | T!['('] => tuple_field_def_list(p), |
75 | T![=] => { | 75 | T![=] => { |
76 | p.bump(); | 76 | p.bump(); |
77 | expressions::expr(p); | 77 | expressions::expr(p); |
@@ -91,7 +91,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { | |||
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 record_field_def_list(p: &mut Parser) { |
95 | assert!(p.at(T!['{'])); | 95 | assert!(p.at(T!['{'])); |
96 | let m = p.start(); | 96 | let m = p.start(); |
97 | p.bump(); | 97 | p.bump(); |
@@ -100,17 +100,17 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { | |||
100 | error_block(p, "expected field"); | 100 | error_block(p, "expected field"); |
101 | continue; | 101 | continue; |
102 | } | 102 | } |
103 | named_field_def(p); | 103 | record_field_def(p); |
104 | if !p.at(T!['}']) { | 104 | if !p.at(T!['}']) { |
105 | p.expect(T![,]); | 105 | p.expect(T![,]); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | p.expect(T!['}']); | 108 | p.expect(T!['}']); |
109 | m.complete(p, NAMED_FIELD_DEF_LIST); | 109 | m.complete(p, RECORD_FIELD_DEF_LIST); |
110 | 110 | ||
111 | fn named_field_def(p: &mut Parser) { | 111 | fn record_field_def(p: &mut Parser) { |
112 | let m = p.start(); | 112 | let m = p.start(); |
113 | // test field_attrs | 113 | // test record_field_attrs |
114 | // struct S { | 114 | // struct S { |
115 | // #[serde(with = "url_serde")] | 115 | // #[serde(with = "url_serde")] |
116 | // pub uri: Uri, | 116 | // pub uri: Uri, |
@@ -121,7 +121,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { | |||
121 | name(p); | 121 | name(p); |
122 | p.expect(T![:]); | 122 | p.expect(T![:]); |
123 | types::type_(p); | 123 | types::type_(p); |
124 | m.complete(p, NAMED_FIELD_DEF); | 124 | m.complete(p, RECORD_FIELD_DEF); |
125 | } else { | 125 | } else { |
126 | m.abandon(p); | 126 | m.abandon(p); |
127 | p.err_and_bump("expected field declaration"); | 127 | p.err_and_bump("expected field declaration"); |
@@ -129,7 +129,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { | |||
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | fn pos_field_def_list(p: &mut Parser) { | 132 | fn tuple_field_def_list(p: &mut Parser) { |
133 | assert!(p.at(T!['('])); | 133 | assert!(p.at(T!['('])); |
134 | let m = p.start(); | 134 | let m = p.start(); |
135 | if !p.expect(T!['(']) { | 135 | if !p.expect(T!['(']) { |
@@ -137,7 +137,7 @@ fn pos_field_def_list(p: &mut Parser) { | |||
137 | } | 137 | } |
138 | while !p.at(T![')']) && !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 tuple_field_attrs |
141 | // struct S ( | 141 | // struct S ( |
142 | // #[serde(with = "url_serde")] | 142 | // #[serde(with = "url_serde")] |
143 | // pub Uri, | 143 | // pub Uri, |
@@ -154,12 +154,12 @@ fn pos_field_def_list(p: &mut Parser) { | |||
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | types::type_(p); | 156 | types::type_(p); |
157 | m.complete(p, POS_FIELD_DEF); | 157 | m.complete(p, TUPLE_FIELD_DEF); |
158 | 158 | ||
159 | if !p.at(T![')']) { | 159 | if !p.at(T![')']) { |
160 | p.expect(T![,]); | 160 | p.expect(T![,]); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | p.expect(T![')']); | 163 | p.expect(T![')']); |
164 | m.complete(p, POS_FIELD_DEF_LIST); | 164 | m.complete(p, TUPLE_FIELD_DEF_LIST); |
165 | } | 165 | } |
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index 1f6a6fd48..8979aa499 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs | |||
@@ -127,8 +127,8 @@ fn path_pat(p: &mut Parser) -> CompletedMarker { | |||
127 | TUPLE_STRUCT_PAT | 127 | TUPLE_STRUCT_PAT |
128 | } | 128 | } |
129 | T!['{'] => { | 129 | T!['{'] => { |
130 | field_pat_list(p); | 130 | record_field_pat_list(p); |
131 | STRUCT_PAT | 131 | RECORD_PAT |
132 | } | 132 | } |
133 | _ => PATH_PAT, | 133 | _ => PATH_PAT, |
134 | }; | 134 | }; |
@@ -149,21 +149,21 @@ fn tuple_pat_fields(p: &mut Parser) { | |||
149 | p.expect(T![')']); | 149 | p.expect(T![')']); |
150 | } | 150 | } |
151 | 151 | ||
152 | // test field_pat_list | 152 | // test record_field_pat_list |
153 | // fn foo() { | 153 | // fn foo() { |
154 | // let S {} = (); | 154 | // let S {} = (); |
155 | // let S { f, ref mut g } = (); | 155 | // let S { f, ref mut g } = (); |
156 | // let S { h: _, ..} = (); | 156 | // let S { h: _, ..} = (); |
157 | // let S { h: _, } = (); | 157 | // let S { h: _, } = (); |
158 | // } | 158 | // } |
159 | fn field_pat_list(p: &mut Parser) { | 159 | fn record_field_pat_list(p: &mut Parser) { |
160 | assert!(p.at(T!['{'])); | 160 | assert!(p.at(T!['{'])); |
161 | let m = p.start(); | 161 | let m = p.start(); |
162 | p.bump(); | 162 | p.bump(); |
163 | while !p.at(EOF) && !p.at(T!['}']) { | 163 | while !p.at(EOF) && !p.at(T!['}']) { |
164 | match p.current() { | 164 | match p.current() { |
165 | T![..] => p.bump(), | 165 | T![..] => p.bump(), |
166 | IDENT if p.nth(1) == T![:] => field_pat(p), | 166 | IDENT if p.nth(1) == T![:] => record_field_pat(p), |
167 | T!['{'] => error_block(p, "expected ident"), | 167 | T!['{'] => error_block(p, "expected ident"), |
168 | _ => { | 168 | _ => { |
169 | bind_pat(p, false); | 169 | bind_pat(p, false); |
@@ -174,10 +174,10 @@ fn field_pat_list(p: &mut Parser) { | |||
174 | } | 174 | } |
175 | } | 175 | } |
176 | p.expect(T!['}']); | 176 | p.expect(T!['}']); |
177 | m.complete(p, FIELD_PAT_LIST); | 177 | m.complete(p, RECORD_FIELD_PAT_LIST); |
178 | } | 178 | } |
179 | 179 | ||
180 | fn field_pat(p: &mut Parser) { | 180 | fn record_field_pat(p: &mut Parser) { |
181 | assert!(p.at(IDENT)); | 181 | assert!(p.at(IDENT)); |
182 | assert!(p.nth(1) == T![:]); | 182 | assert!(p.nth(1) == T![:]); |
183 | 183 | ||
@@ -185,7 +185,7 @@ fn field_pat(p: &mut Parser) { | |||
185 | name(p); | 185 | name(p); |
186 | p.bump(); | 186 | p.bump(); |
187 | pattern(p); | 187 | pattern(p); |
188 | m.complete(p, FIELD_PAT); | 188 | m.complete(p, RECORD_FIELD_PAT); |
189 | } | 189 | } |
190 | 190 | ||
191 | // test placeholder_pat | 191 | // test placeholder_pat |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 3a67d7ddd..f15e98e68 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -152,9 +152,9 @@ pub enum SyntaxKind { | |||
152 | BIND_PAT, | 152 | BIND_PAT, |
153 | PLACEHOLDER_PAT, | 153 | PLACEHOLDER_PAT, |
154 | PATH_PAT, | 154 | PATH_PAT, |
155 | STRUCT_PAT, | 155 | RECORD_PAT, |
156 | FIELD_PAT_LIST, | 156 | RECORD_FIELD_PAT_LIST, |
157 | FIELD_PAT, | 157 | RECORD_FIELD_PAT, |
158 | TUPLE_STRUCT_PAT, | 158 | TUPLE_STRUCT_PAT, |
159 | TUPLE_PAT, | 159 | TUPLE_PAT, |
160 | SLICE_PAT, | 160 | SLICE_PAT, |
@@ -179,9 +179,9 @@ pub enum SyntaxKind { | |||
179 | MATCH_ARM_LIST, | 179 | MATCH_ARM_LIST, |
180 | MATCH_ARM, | 180 | MATCH_ARM, |
181 | MATCH_GUARD, | 181 | MATCH_GUARD, |
182 | STRUCT_LIT, | 182 | RECORD_LIT, |
183 | NAMED_FIELD_LIST, | 183 | RECORD_FIELD_LIST, |
184 | NAMED_FIELD, | 184 | RECORD_FIELD, |
185 | TRY_BLOCK_EXPR, | 185 | TRY_BLOCK_EXPR, |
186 | BOX_EXPR, | 186 | BOX_EXPR, |
187 | CALL_EXPR, | 187 | CALL_EXPR, |
@@ -199,10 +199,10 @@ pub enum SyntaxKind { | |||
199 | EXTERN_BLOCK, | 199 | EXTERN_BLOCK, |
200 | EXTERN_ITEM_LIST, | 200 | EXTERN_ITEM_LIST, |
201 | ENUM_VARIANT, | 201 | ENUM_VARIANT, |
202 | NAMED_FIELD_DEF_LIST, | 202 | RECORD_FIELD_DEF_LIST, |
203 | NAMED_FIELD_DEF, | 203 | RECORD_FIELD_DEF, |
204 | POS_FIELD_DEF_LIST, | 204 | TUPLE_FIELD_DEF_LIST, |
205 | POS_FIELD_DEF, | 205 | TUPLE_FIELD_DEF, |
206 | ENUM_VARIANT_LIST, | 206 | ENUM_VARIANT_LIST, |
207 | ITEM_LIST, | 207 | ITEM_LIST, |
208 | ATTR, | 208 | ATTR, |