aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-20 07:51:24 +0000
committerGitHub <[email protected]>2020-03-20 07:51:24 +0000
commite0952899aee50b813379ca8e6dcab49a895ff0a0 (patch)
treeae389283c137194fdabc5e5e45b7021ac9fa3b7f /crates
parent1878fbe8bd60c7f9e58fda6dc7788e5f44ad0f89 (diff)
parent89694ec8f685e545585b96b2db6e5410ba117527 (diff)
Merge #3662
3662: Support arbitrary discriminants r=matklad a=matklad Closes #3661 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/items/adt.rs10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs1
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt30
3 files changed, 37 insertions, 4 deletions
diff --git a/crates/ra_parser/src/grammar/items/adt.rs b/crates/ra_parser/src/grammar/items/adt.rs
index c777bc9d0..74b9f514b 100644
--- a/crates/ra_parser/src/grammar/items/adt.rs
+++ b/crates/ra_parser/src/grammar/items/adt.rs
@@ -83,12 +83,14 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
83 match p.current() { 83 match p.current() {
84 T!['{'] => record_field_def_list(p), 84 T!['{'] => record_field_def_list(p),
85 T!['('] => tuple_field_def_list(p), 85 T!['('] => tuple_field_def_list(p),
86 T![=] => {
87 p.bump(T![=]);
88 expressions::expr(p);
89 }
90 _ => (), 86 _ => (),
91 } 87 }
88
89 // test variant_discriminant
90 // enum E { X(i32) = 10 }
91 if p.eat(T![=]) {
92 expressions::expr(p);
93 }
92 var.complete(p, ENUM_VARIANT); 94 var.complete(p, ENUM_VARIANT);
93 } else { 95 } else {
94 var.abandon(p); 96 var.abandon(p);
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs
new file mode 100644
index 000000000..c8c5c0f17
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs
@@ -0,0 +1 @@
enum E { X(i32) = 10 }
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt
new file mode 100644
index 000000000..a378dd80b
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt
@@ -0,0 +1,30 @@
1SOURCE_FILE@[0; 23)
2 ENUM_DEF@[0; 22)
3 ENUM_KW@[0; 4) "enum"
4 WHITESPACE@[4; 5) " "
5 NAME@[5; 6)
6 IDENT@[5; 6) "E"
7 WHITESPACE@[6; 7) " "
8 ENUM_VARIANT_LIST@[7; 22)
9 L_CURLY@[7; 8) "{"
10 WHITESPACE@[8; 9) " "
11 ENUM_VARIANT@[9; 20)
12 NAME@[9; 10)
13 IDENT@[9; 10) "X"
14 TUPLE_FIELD_DEF_LIST@[10; 15)
15 L_PAREN@[10; 11) "("
16 TUPLE_FIELD_DEF@[11; 14)
17 PATH_TYPE@[11; 14)
18 PATH@[11; 14)
19 PATH_SEGMENT@[11; 14)
20 NAME_REF@[11; 14)
21 IDENT@[11; 14) "i32"
22 R_PAREN@[14; 15) ")"
23 WHITESPACE@[15; 16) " "
24 EQ@[16; 17) "="
25 WHITESPACE@[17; 18) " "
26 LITERAL@[18; 20)
27 INT_NUMBER@[18; 20) "10"
28 WHITESPACE@[20; 21) " "
29 R_CURLY@[21; 22) "}"
30 WHITESPACE@[22; 23) "\n"