aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs14
-rw-r--r--crates/ra_parser/src/grammar/items.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/nominal.rs30
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs16
4 files changed, 32 insertions, 32 deletions
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// }
580pub(crate) fn named_field_list(p: &mut Parser) { 580pub(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;
4mod use_item; 4mod use_item;
5 5
6pub(crate) use self::{ 6pub(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
94pub(crate) fn named_field_def_list(p: &mut Parser) { 94pub(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
132fn pos_field_def_list(p: &mut Parser) { 132fn 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// }
159fn field_pat_list(p: &mut Parser) { 159fn 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
180fn field_pat(p: &mut Parser) { 180fn 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