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/inline/ok/0003_where_pred_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/inline/ok/0003_where_pred_for.txt')
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt index 41420ea92..8bc29564e 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0003_where_pred_for.txt | |||
@@ -33,24 +33,26 @@ SOURCE_FILE@[0; 49) | |||
33 | IDENT@[30; 31) "F" | 33 | IDENT@[30; 31) "F" |
34 | COLON@[31; 32) | 34 | COLON@[31; 32) |
35 | WHITESPACE@[32; 33) | 35 | WHITESPACE@[32; 33) |
36 | PATH_TYPE@[33; 44) | 36 | TYPE_BOUND_LIST@[33; 44) |
37 | PATH@[33; 44) | 37 | TYPE_BOUND@[33; 44) |
38 | PATH_SEGMENT@[33; 44) | 38 | PATH_TYPE@[33; 44) |
39 | NAME_REF@[33; 35) | 39 | PATH@[33; 44) |
40 | IDENT@[33; 35) "Fn" | 40 | PATH_SEGMENT@[33; 44) |
41 | PARAM_LIST@[35; 44) | 41 | NAME_REF@[33; 35) |
42 | L_PAREN@[35; 36) | 42 | IDENT@[33; 35) "Fn" |
43 | PARAM@[36; 43) | 43 | PARAM_LIST@[35; 44) |
44 | REFERENCE_TYPE@[36; 43) | 44 | L_PAREN@[35; 36) |
45 | AMP@[36; 37) | 45 | PARAM@[36; 43) |
46 | LIFETIME@[37; 39) "'a" | 46 | REFERENCE_TYPE@[36; 43) |
47 | WHITESPACE@[39; 40) | 47 | AMP@[36; 37) |
48 | PATH_TYPE@[40; 43) | 48 | LIFETIME@[37; 39) "'a" |
49 | PATH@[40; 43) | 49 | WHITESPACE@[39; 40) |
50 | PATH_SEGMENT@[40; 43) | 50 | PATH_TYPE@[40; 43) |
51 | NAME_REF@[40; 43) | 51 | PATH@[40; 43) |
52 | IDENT@[40; 43) "str" | 52 | PATH_SEGMENT@[40; 43) |
53 | R_PAREN@[43; 44) | 53 | NAME_REF@[40; 43) |
54 | IDENT@[40; 43) "str" | ||
55 | R_PAREN@[43; 44) | ||
54 | WHITESPACE@[44; 45) | 56 | WHITESPACE@[44; 45) |
55 | BLOCK@[45; 48) | 57 | BLOCK@[45; 48) |
56 | L_CURLY@[45; 46) | 58 | L_CURLY@[45; 46) |