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.rs11
-rw-r--r--crates/ra_parser/src/grammar/params.rs13
-rw-r--r--crates/ra_parser/src/grammar/type_args.rs7
3 files changed, 24 insertions, 7 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index b60a2f68c..742076c1a 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -489,10 +489,8 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
489 assert!(p.at(T![.])); 489 assert!(p.at(T![.]));
490 let m = lhs.precede(p); 490 let m = lhs.precede(p);
491 p.bump(); 491 p.bump();
492 if p.at(IDENT) { 492 if p.at(IDENT) || p.at(INT_NUMBER) {
493 name_ref(p) 493 name_ref_or_index(p)
494 } else if p.at(INT_NUMBER) {
495 p.bump();
496 } else if p.at(FLOAT_NUMBER) { 494 } else if p.at(FLOAT_NUMBER) {
497 // FIXME: How to recover and instead parse INT + T![.]? 495 // FIXME: How to recover and instead parse INT + T![.]?
498 p.bump(); 496 p.bump();
@@ -577,6 +575,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
577// S {}; 575// S {};
578// S { x, y: 32, }; 576// S { x, y: 32, };
579// S { x, y: 32, ..Default::default() }; 577// S { x, y: 32, ..Default::default() };
578// TupleStruct { 0: 1 };
580// } 579// }
581pub(crate) fn named_field_list(p: &mut Parser) { 580pub(crate) fn named_field_list(p: &mut Parser) {
582 assert!(p.at(T!['{'])); 581 assert!(p.at(T!['{']));
@@ -588,10 +587,10 @@ pub(crate) fn named_field_list(p: &mut Parser) {
588 // fn main() { 587 // fn main() {
589 // S { #[cfg(test)] field: 1 } 588 // S { #[cfg(test)] field: 1 }
590 // } 589 // }
591 IDENT | T![#] => { 590 IDENT | INT_NUMBER | T![#] => {
592 let m = p.start(); 591 let m = p.start();
593 attributes::outer_attributes(p); 592 attributes::outer_attributes(p);
594 name_ref(p); 593 name_ref_or_index(p);
595 if p.eat(T![:]) { 594 if p.eat(T![:]) {
596 expr(p); 595 expr(p);
597 } 596 }
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs
index 723b56343..0b09f1874 100644
--- a/crates/ra_parser/src/grammar/params.rs
+++ b/crates/ra_parser/src/grammar/params.rs
@@ -41,9 +41,20 @@ fn list_(p: &mut Parser, flavor: Flavor) {
41 let m = p.start(); 41 let m = p.start();
42 p.bump(); 42 p.bump();
43 if flavor.type_required() { 43 if flavor.type_required() {
44 // test self_param_outer_attr
45 // fn f(#[must_use] self) {}
46 attributes::outer_attributes(p);
44 opt_self_param(p); 47 opt_self_param(p);
45 } 48 }
46 while !p.at(EOF) && !p.at(ket) && !(flavor.type_required() && p.at(T![...])) { 49 while !p.at(EOF) && !p.at(ket) {
50 // test param_outer_arg
51 // fn f(#[attr1] pat: Type) {}
52 attributes::outer_attributes(p);
53
54 if flavor.type_required() && p.at(T![...]) {
55 break;
56 }
57
47 if !p.at_ts(VALUE_PARAMETER_FIRST) { 58 if !p.at_ts(VALUE_PARAMETER_FIRST) {
48 p.error("expected value parameter"); 59 p.error("expected value parameter");
49 break; 60 break;
diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs
index f391b63db..3db08b280 100644
--- a/crates/ra_parser/src/grammar/type_args.rs
+++ b/crates/ra_parser/src/grammar/type_args.rs
@@ -35,6 +35,13 @@ fn type_arg(p: &mut Parser) {
35 p.bump(); 35 p.bump();
36 m.complete(p, LIFETIME_ARG); 36 m.complete(p, LIFETIME_ARG);
37 } 37 }
38 // test associated_type_bounds
39 // fn print_all<T: Iterator<Item: Display>>(printables: T) {}
40 IDENT if p.nth(1) == T![:] => {
41 name_ref(p);
42 type_params::bounds(p);
43 m.complete(p, ASSOC_TYPE_ARG);
44 }
38 IDENT if p.nth(1) == T![=] => { 45 IDENT if p.nth(1) == T![=] => {
39 name_ref(p); 46 name_ref(p);
40 p.bump(); 47 p.bump();