diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-18 09:32:28 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-18 09:32:28 +0000 |
commit | 1cd18f9237b6ac48ca8461307f2a4eaf273ee394 (patch) | |
tree | 7971e3753c74b98e0e5b4120adb8706a86d99e3e /crates/ra_syntax/tests/data/parser | |
parent | 7c117567ab55046a9303fc7a6676a50008ad4f33 (diff) | |
parent | 76075c74103b3204ebc1bde54a330629d9e00811 (diff) |
Merge #991
991: Use Marker argument for item parsers r=matklad a=pcpthm
Before doing this for expressions, I found that the pattern (Marker argument) should be applied to the item parsers because visiblity and modifiers are parsed in a separate function.
Fixed some parser bugs:
- Fix pub_expr: `pub 42;` was allowed.
- Fix incorrect parsing of crate::path: incorrectly parsed as `crate` as a visibility.
Co-authored-by: pcpthm <[email protected]>
Diffstat (limited to 'crates/ra_syntax/tests/data/parser')
-rw-r--r-- | crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt | 6 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt (renamed from crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.txt) | 10 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.txt | 46 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.txt | 31 |
8 files changed, 88 insertions, 10 deletions
diff --git a/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt b/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt index e9400d03b..b87fe46bd 100644 --- a/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt +++ b/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 40) | 1 | SOURCE_FILE@[0; 40) |
2 | STRUCT_DEF@[0; 40) | 2 | STRUCT_DEF@[0; 39) |
3 | STRUCT_KW@[0; 6) | 3 | STRUCT_KW@[0; 6) |
4 | WHITESPACE@[6; 7) | 4 | WHITESPACE@[6; 7) |
5 | NAME@[7; 8) | 5 | NAME@[7; 8) |
@@ -35,5 +35,5 @@ SOURCE_FILE@[0; 40) | |||
35 | R_CURLY@[38; 39) | 35 | R_CURLY@[38; 39) |
36 | err: `expected item, found `;` | 36 | err: `expected item, found `;` |
37 | consider removing this semicolon` | 37 | consider removing this semicolon` |
38 | ERROR@[39; 40) | 38 | ERROR@[39; 40) |
39 | SEMI@[39; 40) | 39 | SEMI@[39; 40) |
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.rs b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.rs new file mode 100644 index 000000000..2976f6862 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.rs | |||
@@ -0,0 +1 @@ | |||
fn foo() { pub 92; } | |||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.txt b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt index de20eee7a..e65d9c9e1 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.txt +++ b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@[0; 29) | 1 | SOURCE_FILE@[0; 21) |
2 | FN_DEF@[0; 20) | 2 | FN_DEF@[0; 20) |
3 | FN_KW@[0; 2) | 3 | FN_KW@[0; 2) |
4 | WHITESPACE@[2; 3) | 4 | WHITESPACE@[2; 3) |
@@ -11,15 +11,15 @@ SOURCE_FILE@[0; 29) | |||
11 | BLOCK@[9; 20) | 11 | BLOCK@[9; 20) |
12 | L_CURLY@[9; 10) | 12 | L_CURLY@[9; 10) |
13 | WHITESPACE@[10; 11) | 13 | WHITESPACE@[10; 11) |
14 | EXPR_STMT@[11; 18) | 14 | ERROR@[11; 14) |
15 | VISIBILITY@[11; 14) | 15 | VISIBILITY@[11; 14) |
16 | PUB_KW@[11; 14) | 16 | PUB_KW@[11; 14) |
17 | WHITESPACE@[14; 15) | 17 | err: `expected an item` |
18 | WHITESPACE@[14; 15) | ||
19 | EXPR_STMT@[15; 18) | ||
18 | LITERAL@[15; 17) | 20 | LITERAL@[15; 17) |
19 | INT_NUMBER@[15; 17) "92" | 21 | INT_NUMBER@[15; 17) "92" |
20 | SEMI@[17; 18) | 22 | SEMI@[17; 18) |
21 | WHITESPACE@[18; 19) | 23 | WHITESPACE@[18; 19) |
22 | R_CURLY@[19; 20) | 24 | R_CURLY@[19; 20) |
23 | WHITESPACE@[20; 21) | 25 | WHITESPACE@[20; 21) |
24 | COMMENT@[21; 28) | ||
25 | WHITESPACE@[28; 29) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.rs deleted file mode 100644 index d9d99d2d3..000000000 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0035_pub_expr.rs +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | fn foo() { pub 92; } //FIXME | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.rs index 660d927cf..e2b5f2161 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.rs | |||
@@ -1 +1,3 @@ | |||
1 | crate fn main() { } | 1 | crate fn main() { } |
2 | struct S { crate field: u32 } | ||
3 | struct T(crate u32); | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.txt index ff5add838..695734d54 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0040_crate_keyword_vis.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@[0; 20) | 1 | SOURCE_FILE@[0; 71) |
2 | FN_DEF@[0; 19) | 2 | FN_DEF@[0; 19) |
3 | VISIBILITY@[0; 5) | 3 | VISIBILITY@[0; 5) |
4 | CRATE_KW@[0; 5) | 4 | CRATE_KW@[0; 5) |
@@ -16,3 +16,47 @@ SOURCE_FILE@[0; 20) | |||
16 | WHITESPACE@[17; 18) | 16 | WHITESPACE@[17; 18) |
17 | R_CURLY@[18; 19) | 17 | R_CURLY@[18; 19) |
18 | WHITESPACE@[19; 20) | 18 | WHITESPACE@[19; 20) |
19 | STRUCT_DEF@[20; 49) | ||
20 | STRUCT_KW@[20; 26) | ||
21 | WHITESPACE@[26; 27) | ||
22 | NAME@[27; 28) | ||
23 | IDENT@[27; 28) "S" | ||
24 | WHITESPACE@[28; 29) | ||
25 | NAMED_FIELD_DEF_LIST@[29; 49) | ||
26 | L_CURLY@[29; 30) | ||
27 | WHITESPACE@[30; 31) | ||
28 | NAMED_FIELD_DEF@[31; 47) | ||
29 | VISIBILITY@[31; 36) | ||
30 | CRATE_KW@[31; 36) | ||
31 | WHITESPACE@[36; 37) | ||
32 | NAME@[37; 42) | ||
33 | IDENT@[37; 42) "field" | ||
34 | COLON@[42; 43) | ||
35 | WHITESPACE@[43; 44) | ||
36 | PATH_TYPE@[44; 47) | ||
37 | PATH@[44; 47) | ||
38 | PATH_SEGMENT@[44; 47) | ||
39 | NAME_REF@[44; 47) | ||
40 | IDENT@[44; 47) "u32" | ||
41 | WHITESPACE@[47; 48) | ||
42 | R_CURLY@[48; 49) | ||
43 | WHITESPACE@[49; 50) | ||
44 | STRUCT_DEF@[50; 70) | ||
45 | STRUCT_KW@[50; 56) | ||
46 | WHITESPACE@[56; 57) | ||
47 | NAME@[57; 58) | ||
48 | IDENT@[57; 58) "T" | ||
49 | POS_FIELD_DEF_LIST@[58; 69) | ||
50 | L_PAREN@[58; 59) | ||
51 | POS_FIELD_DEF@[59; 68) | ||
52 | VISIBILITY@[59; 64) | ||
53 | CRATE_KW@[59; 64) | ||
54 | WHITESPACE@[64; 65) | ||
55 | PATH_TYPE@[65; 68) | ||
56 | PATH@[65; 68) | ||
57 | PATH_SEGMENT@[65; 68) | ||
58 | NAME_REF@[65; 68) | ||
59 | IDENT@[65; 68) "u32" | ||
60 | R_PAREN@[68; 69) | ||
61 | SEMI@[69; 70) | ||
62 | WHITESPACE@[70; 71) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.rs new file mode 100644 index 000000000..0f454d121 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.rs | |||
@@ -0,0 +1 @@ | |||
fn foo() { crate::foo(); } | |||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.txt new file mode 100644 index 000000000..7c637b079 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0125_crate_keyword_path.txt | |||
@@ -0,0 +1,31 @@ | |||
1 | SOURCE_FILE@[0; 27) | ||
2 | FN_DEF@[0; 26) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 8) | ||
8 | L_PAREN@[6; 7) | ||
9 | R_PAREN@[7; 8) | ||
10 | WHITESPACE@[8; 9) | ||
11 | BLOCK@[9; 26) | ||
12 | L_CURLY@[9; 10) | ||
13 | WHITESPACE@[10; 11) | ||
14 | EXPR_STMT@[11; 24) | ||
15 | CALL_EXPR@[11; 23) | ||
16 | PATH_EXPR@[11; 21) | ||
17 | PATH@[11; 21) | ||
18 | PATH@[11; 16) | ||
19 | PATH_SEGMENT@[11; 16) | ||
20 | CRATE_KW@[11; 16) | ||
21 | COLONCOLON@[16; 18) | ||
22 | PATH_SEGMENT@[18; 21) | ||
23 | NAME_REF@[18; 21) | ||
24 | IDENT@[18; 21) "foo" | ||
25 | ARG_LIST@[21; 23) | ||
26 | L_PAREN@[21; 22) | ||
27 | R_PAREN@[22; 23) | ||
28 | SEMI@[23; 24) | ||
29 | WHITESPACE@[24; 25) | ||
30 | R_CURLY@[25; 26) | ||
31 | WHITESPACE@[26; 27) | ||