diff options
Diffstat (limited to 'crates/ra_syntax')
5 files changed, 139 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index 863f8e00c..7db25beba 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs | |||
@@ -96,6 +96,7 @@ pub(super) fn bounds_without_colon(p: &mut Parser) { | |||
96 | // 'a: 'b + 'c, | 96 | // 'a: 'b + 'c, |
97 | // T: Clone + Copy + 'static, | 97 | // T: Clone + Copy + 'static, |
98 | // Iterator::Item: 'a, | 98 | // Iterator::Item: 'a, |
99 | // <T as Iterator>::Item: 'a | ||
99 | // {} | 100 | // {} |
100 | pub(super) fn opt_where_clause(p: &mut Parser) { | 101 | pub(super) fn opt_where_clause(p: &mut Parser) { |
101 | if !p.at(WHERE_KW) { | 102 | if !p.at(WHERE_KW) { |
@@ -104,7 +105,11 @@ pub(super) fn opt_where_clause(p: &mut Parser) { | |||
104 | let m = p.start(); | 105 | let m = p.start(); |
105 | p.bump(); | 106 | p.bump(); |
106 | loop { | 107 | loop { |
107 | if !(paths::is_path_start(p) || p.current() == LIFETIME || p.current() == FOR_KW) { | 108 | if !(paths::is_path_start(p) |
109 | || p.current() == LIFETIME | ||
110 | || p.current() == FOR_KW | ||
111 | || p.current() == L_ANGLE) | ||
112 | { | ||
108 | break; | 113 | break; |
109 | } | 114 | } |
110 | where_predicate(p); | 115 | where_predicate(p); |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs index 592a005f9..19d7e571b 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs | |||
@@ -3,4 +3,5 @@ where | |||
3 | 'a: 'b + 'c, | 3 | 'a: 'b + 'c, |
4 | T: Clone + Copy + 'static, | 4 | T: Clone + Copy + 'static, |
5 | Iterator::Item: 'a, | 5 | Iterator::Item: 'a, |
6 | <T as Iterator>::Item: 'a | ||
6 | {} | 7 | {} |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt index 54c3d64f1..68485dc0b 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 87) | 1 | SOURCE_FILE@[0; 116) |
2 | FN_DEF@[0; 86) | 2 | FN_DEF@[0; 115) |
3 | FN_KW@[0; 2) | 3 | FN_KW@[0; 2) |
4 | WHITESPACE@[2; 3) | 4 | WHITESPACE@[2; 3) |
5 | NAME@[3; 6) | 5 | NAME@[3; 6) |
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 87) | |||
8 | L_PAREN@[6; 7) | 8 | L_PAREN@[6; 7) |
9 | R_PAREN@[7; 8) | 9 | R_PAREN@[7; 8) |
10 | WHITESPACE@[8; 9) | 10 | WHITESPACE@[8; 9) |
11 | WHERE_CLAUSE@[9; 83) | 11 | WHERE_CLAUSE@[9; 112) |
12 | WHERE_KW@[9; 14) | 12 | WHERE_KW@[9; 14) |
13 | WHITESPACE@[14; 18) | 13 | WHITESPACE@[14; 18) |
14 | WHERE_PRED@[18; 29) | 14 | WHERE_PRED@[18; 29) |
@@ -64,8 +64,36 @@ SOURCE_FILE@[0; 87) | |||
64 | WHITESPACE@[79; 80) | 64 | WHITESPACE@[79; 80) |
65 | LIFETIME@[80; 82) "'a" | 65 | LIFETIME@[80; 82) "'a" |
66 | COMMA@[82; 83) | 66 | COMMA@[82; 83) |
67 | WHITESPACE@[83; 84) | 67 | WHITESPACE@[83; 87) |
68 | BLOCK@[84; 86) | 68 | WHERE_PRED@[87; 112) |
69 | L_CURLY@[84; 85) | 69 | PATH_TYPE@[87; 108) |
70 | R_CURLY@[85; 86) | 70 | PATH@[87; 108) |
71 | WHITESPACE@[86; 87) | 71 | PATH@[87; 102) |
72 | PATH_SEGMENT@[87; 102) | ||
73 | L_ANGLE@[87; 88) | ||
74 | PATH_TYPE@[88; 89) | ||
75 | PATH@[88; 89) | ||
76 | PATH_SEGMENT@[88; 89) | ||
77 | NAME_REF@[88; 89) | ||
78 | IDENT@[88; 89) "T" | ||
79 | WHITESPACE@[89; 90) | ||
80 | AS_KW@[90; 92) | ||
81 | WHITESPACE@[92; 93) | ||
82 | PATH_TYPE@[93; 101) | ||
83 | PATH@[93; 101) | ||
84 | PATH_SEGMENT@[93; 101) | ||
85 | NAME_REF@[93; 101) | ||
86 | IDENT@[93; 101) "Iterator" | ||
87 | R_ANGLE@[101; 102) | ||
88 | COLONCOLON@[102; 104) | ||
89 | PATH_SEGMENT@[104; 108) | ||
90 | NAME_REF@[104; 108) | ||
91 | IDENT@[104; 108) "Item" | ||
92 | COLON@[108; 109) | ||
93 | WHITESPACE@[109; 110) | ||
94 | LIFETIME@[110; 112) "'a" | ||
95 | WHITESPACE@[112; 113) | ||
96 | BLOCK@[113; 115) | ||
97 | L_CURLY@[113; 114) | ||
98 | R_CURLY@[114; 115) | ||
99 | WHITESPACE@[115; 116) | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs new file mode 100644 index 000000000..6da27933e --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs | |||
@@ -0,0 +1,8 @@ | |||
1 | // https://github.com/rust-analyzer/rust-analyzer/issues/311 | ||
2 | |||
3 | pub fn foo<S: Iterator>() -> String | ||
4 | where | ||
5 | <S as Iterator>::Item: Eq, | ||
6 | { | ||
7 | "".to_owned() | ||
8 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt new file mode 100644 index 000000000..208e5e51c --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt | |||
@@ -0,0 +1,88 @@ | |||
1 | SOURCE_FILE@[0; 157) | ||
2 | COMMENT@[0; 60) | ||
3 | WHITESPACE@[60; 62) | ||
4 | FN_DEF@[62; 156) | ||
5 | VISIBILITY@[62; 65) | ||
6 | PUB_KW@[62; 65) | ||
7 | WHITESPACE@[65; 66) | ||
8 | FN_KW@[66; 68) | ||
9 | WHITESPACE@[68; 69) | ||
10 | NAME@[69; 72) | ||
11 | IDENT@[69; 72) "foo" | ||
12 | TYPE_PARAM_LIST@[72; 85) | ||
13 | L_ANGLE@[72; 73) | ||
14 | TYPE_PARAM@[73; 84) | ||
15 | NAME@[73; 74) | ||
16 | IDENT@[73; 74) "S" | ||
17 | COLON@[74; 75) | ||
18 | WHITESPACE@[75; 76) | ||
19 | PATH_TYPE@[76; 84) | ||
20 | PATH@[76; 84) | ||
21 | PATH_SEGMENT@[76; 84) | ||
22 | NAME_REF@[76; 84) | ||
23 | IDENT@[76; 84) "Iterator" | ||
24 | R_ANGLE@[84; 85) | ||
25 | PARAM_LIST@[85; 87) | ||
26 | L_PAREN@[85; 86) | ||
27 | R_PAREN@[86; 87) | ||
28 | WHITESPACE@[87; 88) | ||
29 | RET_TYPE@[88; 97) | ||
30 | THIN_ARROW@[88; 90) | ||
31 | WHITESPACE@[90; 91) | ||
32 | PATH_TYPE@[91; 97) | ||
33 | PATH@[91; 97) | ||
34 | PATH_SEGMENT@[91; 97) | ||
35 | NAME_REF@[91; 97) | ||
36 | IDENT@[91; 97) "String" | ||
37 | WHITESPACE@[97; 98) | ||
38 | WHERE_CLAUSE@[98; 134) | ||
39 | WHERE_KW@[98; 103) | ||
40 | WHITESPACE@[103; 108) | ||
41 | WHERE_PRED@[108; 133) | ||
42 | PATH_TYPE@[108; 129) | ||
43 | PATH@[108; 129) | ||
44 | PATH@[108; 123) | ||
45 | PATH_SEGMENT@[108; 123) | ||
46 | L_ANGLE@[108; 109) | ||
47 | PATH_TYPE@[109; 110) | ||
48 | PATH@[109; 110) | ||
49 | PATH_SEGMENT@[109; 110) | ||
50 | NAME_REF@[109; 110) | ||
51 | IDENT@[109; 110) "S" | ||
52 | WHITESPACE@[110; 111) | ||
53 | AS_KW@[111; 113) | ||
54 | WHITESPACE@[113; 114) | ||
55 | PATH_TYPE@[114; 122) | ||
56 | PATH@[114; 122) | ||
57 | PATH_SEGMENT@[114; 122) | ||
58 | NAME_REF@[114; 122) | ||
59 | IDENT@[114; 122) "Iterator" | ||
60 | R_ANGLE@[122; 123) | ||
61 | COLONCOLON@[123; 125) | ||
62 | PATH_SEGMENT@[125; 129) | ||
63 | NAME_REF@[125; 129) | ||
64 | IDENT@[125; 129) "Item" | ||
65 | COLON@[129; 130) | ||
66 | WHITESPACE@[130; 131) | ||
67 | PATH_TYPE@[131; 133) | ||
68 | PATH@[131; 133) | ||
69 | PATH_SEGMENT@[131; 133) | ||
70 | NAME_REF@[131; 133) | ||
71 | IDENT@[131; 133) "Eq" | ||
72 | COMMA@[133; 134) | ||
73 | WHITESPACE@[134; 135) | ||
74 | BLOCK@[135; 156) | ||
75 | L_CURLY@[135; 136) | ||
76 | WHITESPACE@[136; 141) | ||
77 | METHOD_CALL_EXPR@[141; 154) | ||
78 | LITERAL@[141; 143) | ||
79 | STRING@[141; 143) | ||
80 | DOT@[143; 144) | ||
81 | NAME_REF@[144; 152) | ||
82 | IDENT@[144; 152) "to_owned" | ||
83 | ARG_LIST@[152; 154) | ||
84 | L_PAREN@[152; 153) | ||
85 | R_PAREN@[153; 154) | ||
86 | WHITESPACE@[154; 155) | ||
87 | R_CURLY@[155; 156) | ||
88 | WHITESPACE@[156; 157) | ||