diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-31 10:11:48 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-31 10:11:48 +0100 |
commit | c5ca49678f129045e59438df279829902034ec71 (patch) | |
tree | 3fd54185e0c064fbd6f718ac345064ce9c559efb /crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt | |
parent | 23dd53eb35ff50508d0c0fc5878a55754b12d381 (diff) | |
parent | 55dcdb7d094f473c73f87ecf997b24f8e35f2a5e (diff) |
Merge #1077
1077: Improve parsing of type bounds r=matklad a=vipentti
This adds new TYPE_BOUND_LIST and TYPE_BOUND syntax kinds. These are now used when parsing type bounds. In addition parsing paths inside a bound now does not recursively parse paths, rather they are treated as separate bounds, separated by +.
Basically now the generic params `struct S<T: 'a + ?Sized + (Copy)>;` in will be parsed as
```
TYPE_PARAM_LIST@[8; 33)
L_ANGLE@[8; 9)
TYPE_PARAM@[9; 32)
NAME@[9; 10)
IDENT@[9; 10) "T"
COLON@[10; 11)
WHITESPACE@[11; 12)
TYPE_BOUND_LIST@[12; 32)
TYPE_BOUND@[12; 14)
LIFETIME@[12; 14) "'a"
WHITESPACE@[14; 15)
PLUS@[15; 16)
WHITESPACE@[16; 17)
TYPE_BOUND@[17; 23)
QUESTION@[17; 18)
PATH_TYPE@[18; 23)
PATH@[18; 23)
PATH_SEGMENT@[18; 23)
NAME_REF@[18; 23)
IDENT@[18; 23) "Sized"
WHITESPACE@[23; 24)
PLUS@[24; 25)
WHITESPACE@[25; 26)
TYPE_BOUND@[26; 32)
L_PAREN@[26; 27)
PATH_TYPE@[27; 31)
PATH@[27; 31)
PATH_SEGMENT@[27; 31)
NAME_REF@[27; 31)
IDENT@[27; 31) "Copy"
R_PAREN@[31; 32)
R_ANGLE@[32; 33)
```
Previously it was parsed, with the paths nested:
```
TYPE_PARAM_LIST@[8; 33)
L_ANGLE@[8; 9)
TYPE_PARAM@[9; 32)
NAME@[9; 10)
IDENT@[9; 10) "T"
COLON@[10; 11)
WHITESPACE@[11; 12)
LIFETIME@[12; 14) "'a"
WHITESPACE@[14; 15)
PLUS@[15; 16)
WHITESPACE@[16; 17)
QUESTION@[17; 18)
PATH_TYPE@[18; 32)
PATH@[18; 23)
PATH_SEGMENT@[18; 23)
NAME_REF@[18; 23)
IDENT@[18; 23) "Sized"
WHITESPACE@[23; 24)
PLUS@[24; 25)
WHITESPACE@[25; 26)
L_PAREN@[26; 27)
PATH_TYPE@[27; 31)
PATH@[27; 31)
PATH_SEGMENT@[27; 31)
NAME_REF@[27; 31)
IDENT@[27; 31) "Copy"
R_PAREN@[31; 32)
R_ANGLE@[32; 33)
```
Looking for feedback.
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt')
-rw-r--r-- | crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt b/crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt index 150a9e483..7236d9e62 100644 --- a/crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt +++ b/crates/ra_syntax/tests/data/parser/ok/0032_where_for.txt | |||
@@ -25,43 +25,48 @@ SOURCE_FILE@[0; 116) | |||
25 | IDENT@[39; 42) "SER" | 25 | IDENT@[39; 42) "SER" |
26 | COLON@[42; 43) | 26 | COLON@[42; 43) |
27 | WHITESPACE@[43; 44) | 27 | WHITESPACE@[43; 44) |
28 | PATH_TYPE@[44; 111) | 28 | TYPE_BOUND_LIST@[44; 111) |
29 | PATH@[44; 53) | 29 | TYPE_BOUND@[44; 53) |
30 | PATH_SEGMENT@[44; 53) | 30 | PATH_TYPE@[44; 53) |
31 | NAME_REF@[44; 53) | 31 | PATH@[44; 53) |
32 | IDENT@[44; 53) "Serialize" | 32 | PATH_SEGMENT@[44; 53) |
33 | NAME_REF@[44; 53) | ||
34 | IDENT@[44; 53) "Serialize" | ||
33 | WHITESPACE@[53; 54) | 35 | WHITESPACE@[53; 54) |
34 | PLUS@[54; 55) | 36 | PLUS@[54; 55) |
35 | WHITESPACE@[55; 56) | 37 | WHITESPACE@[55; 56) |
36 | FOR_TYPE@[56; 81) | 38 | TYPE_BOUND@[56; 81) |
37 | FOR_KW@[56; 59) | 39 | FOR_TYPE@[56; 81) |
38 | TYPE_PARAM_LIST@[59; 64) | 40 | FOR_KW@[56; 59) |
39 | L_ANGLE@[59; 60) | 41 | TYPE_PARAM_LIST@[59; 64) |
40 | LIFETIME_PARAM@[60; 63) | 42 | L_ANGLE@[59; 60) |
41 | LIFETIME@[60; 63) "'de" | 43 | LIFETIME_PARAM@[60; 63) |
42 | R_ANGLE@[63; 64) | 44 | LIFETIME@[60; 63) "'de" |
43 | WHITESPACE@[64; 65) | 45 | R_ANGLE@[63; 64) |
44 | PATH_TYPE@[65; 81) | 46 | WHITESPACE@[64; 65) |
45 | PATH@[65; 81) | 47 | PATH_TYPE@[65; 81) |
46 | PATH_SEGMENT@[65; 81) | 48 | PATH@[65; 81) |
47 | NAME_REF@[65; 76) | 49 | PATH_SEGMENT@[65; 81) |
48 | IDENT@[65; 76) "Deserialize" | 50 | NAME_REF@[65; 76) |
49 | TYPE_ARG_LIST@[76; 81) | 51 | IDENT@[65; 76) "Deserialize" |
50 | L_ANGLE@[76; 77) | 52 | TYPE_ARG_LIST@[76; 81) |
51 | LIFETIME_ARG@[77; 80) | 53 | L_ANGLE@[76; 77) |
52 | LIFETIME@[77; 80) "'de" | 54 | LIFETIME_ARG@[77; 80) |
53 | R_ANGLE@[80; 81) | 55 | LIFETIME@[77; 80) "'de" |
56 | R_ANGLE@[80; 81) | ||
54 | WHITESPACE@[81; 82) | 57 | WHITESPACE@[81; 82) |
55 | PLUS@[82; 83) | 58 | PLUS@[82; 83) |
56 | WHITESPACE@[83; 84) | 59 | WHITESPACE@[83; 84) |
57 | PATH_TYPE@[84; 111) | 60 | TYPE_BOUND@[84; 93) |
58 | PATH@[84; 93) | 61 | PATH_TYPE@[84; 93) |
59 | PATH_SEGMENT@[84; 93) | 62 | PATH@[84; 93) |
60 | NAME_REF@[84; 93) | 63 | PATH_SEGMENT@[84; 93) |
61 | IDENT@[84; 93) "PartialEq" | 64 | NAME_REF@[84; 93) |
62 | WHITESPACE@[93; 94) | 65 | IDENT@[84; 93) "PartialEq" |
63 | PLUS@[94; 95) | 66 | WHITESPACE@[93; 94) |
64 | WHITESPACE@[95; 96) | 67 | PLUS@[94; 95) |
68 | WHITESPACE@[95; 96) | ||
69 | TYPE_BOUND@[96; 111) | ||
65 | PATH_TYPE@[96; 111) | 70 | PATH_TYPE@[96; 111) |
66 | PATH@[96; 111) | 71 | PATH@[96; 111) |
67 | PATH@[96; 104) | 72 | PATH@[96; 104) |