diff options
-rw-r--r-- | crates/ra_parser/src/grammar/types.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.txt | 126 |
3 files changed, 130 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs index adc189a29..fdd4f2c52 100644 --- a/crates/ra_parser/src/grammar/types.rs +++ b/crates/ra_parser/src/grammar/types.rs | |||
@@ -202,12 +202,15 @@ pub(super) fn for_binder(p: &mut Parser) { | |||
202 | 202 | ||
203 | // test for_type | 203 | // test for_type |
204 | // type A = for<'a> fn() -> (); | 204 | // type A = for<'a> fn() -> (); |
205 | // fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | ||
206 | // fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | ||
205 | pub(super) fn for_type(p: &mut Parser) { | 207 | pub(super) fn for_type(p: &mut Parser) { |
206 | assert!(p.at(FOR_KW)); | 208 | assert!(p.at(FOR_KW)); |
207 | let m = p.start(); | 209 | let m = p.start(); |
208 | for_binder(p); | 210 | for_binder(p); |
209 | match p.current() { | 211 | match p.current() { |
210 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), | 212 | FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), |
213 | AMP => reference_type(p), | ||
211 | _ if paths::is_path_start(p) => path_type_(p, false), | 214 | _ if paths::is_path_start(p) => path_type_(p, false), |
212 | _ => p.error("expected a path"), | 215 | _ => p.error("expected a path"), |
213 | } | 216 | } |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.rs index 4d6a18c6b..7cde5c532 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.rs | |||
@@ -1 +1,3 @@ | |||
1 | type A = for<'a> fn() -> (); | 1 | type A = for<'a> fn() -> (); |
2 | fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | ||
3 | fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.txt index 6e7e6bda1..568f61fb2 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0081_for_type.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@[0; 29) | 1 | SOURCE_FILE@[0; 135) |
2 | TYPE_ALIAS_DEF@[0; 28) | 2 | TYPE_ALIAS_DEF@[0; 28) |
3 | TYPE_KW@[0; 4) | 3 | TYPE_KW@[0; 4) |
4 | WHITESPACE@[4; 5) | 4 | WHITESPACE@[4; 5) |
@@ -29,3 +29,127 @@ SOURCE_FILE@[0; 29) | |||
29 | R_PAREN@[26; 27) | 29 | R_PAREN@[26; 27) |
30 | SEMI@[27; 28) | 30 | SEMI@[27; 28) |
31 | WHITESPACE@[28; 29) | 31 | WHITESPACE@[28; 29) |
32 | FN_DEF@[29; 79) | ||
33 | FN_KW@[29; 31) | ||
34 | WHITESPACE@[31; 32) | ||
35 | NAME@[32; 35) | ||
36 | IDENT@[32; 35) "foo" | ||
37 | TYPE_PARAM_LIST@[35; 38) | ||
38 | L_ANGLE@[35; 36) | ||
39 | TYPE_PARAM@[36; 37) | ||
40 | NAME@[36; 37) | ||
41 | IDENT@[36; 37) "T" | ||
42 | R_ANGLE@[37; 38) | ||
43 | PARAM_LIST@[38; 46) | ||
44 | L_PAREN@[38; 39) | ||
45 | PARAM@[39; 45) | ||
46 | BIND_PAT@[39; 41) | ||
47 | NAME@[39; 41) | ||
48 | IDENT@[39; 41) "_t" | ||
49 | COLON@[41; 42) | ||
50 | WHITESPACE@[42; 43) | ||
51 | REFERENCE_TYPE@[43; 45) | ||
52 | AMP@[43; 44) | ||
53 | PATH_TYPE@[44; 45) | ||
54 | PATH@[44; 45) | ||
55 | PATH_SEGMENT@[44; 45) | ||
56 | NAME_REF@[44; 45) | ||
57 | IDENT@[44; 45) "T" | ||
58 | R_PAREN@[45; 46) | ||
59 | WHITESPACE@[46; 47) | ||
60 | WHERE_CLAUSE@[47; 76) | ||
61 | WHERE_KW@[47; 52) | ||
62 | WHITESPACE@[52; 53) | ||
63 | WHERE_PRED@[53; 76) | ||
64 | FOR_TYPE@[53; 66) | ||
65 | FOR_KW@[53; 56) | ||
66 | TYPE_PARAM_LIST@[56; 60) | ||
67 | L_ANGLE@[56; 57) | ||
68 | LIFETIME_PARAM@[57; 59) | ||
69 | LIFETIME@[57; 59) "'a" | ||
70 | R_ANGLE@[59; 60) | ||
71 | WHITESPACE@[60; 61) | ||
72 | REFERENCE_TYPE@[61; 66) | ||
73 | AMP@[61; 62) | ||
74 | LIFETIME@[62; 64) "'a" | ||
75 | WHITESPACE@[64; 65) | ||
76 | PATH_TYPE@[65; 66) | ||
77 | PATH@[65; 66) | ||
78 | PATH_SEGMENT@[65; 66) | ||
79 | NAME_REF@[65; 66) | ||
80 | IDENT@[65; 66) "T" | ||
81 | COLON@[66; 67) | ||
82 | WHITESPACE@[67; 68) | ||
83 | PATH_TYPE@[68; 76) | ||
84 | PATH@[68; 76) | ||
85 | PATH_SEGMENT@[68; 76) | ||
86 | NAME_REF@[68; 76) | ||
87 | IDENT@[68; 76) "Iterator" | ||
88 | WHITESPACE@[76; 77) | ||
89 | BLOCK@[77; 79) | ||
90 | L_CURLY@[77; 78) | ||
91 | R_CURLY@[78; 79) | ||
92 | WHITESPACE@[79; 80) | ||
93 | FN_DEF@[80; 134) | ||
94 | FN_KW@[80; 82) | ||
95 | WHITESPACE@[82; 83) | ||
96 | NAME@[83; 86) | ||
97 | IDENT@[83; 86) "bar" | ||
98 | TYPE_PARAM_LIST@[86; 89) | ||
99 | L_ANGLE@[86; 87) | ||
100 | TYPE_PARAM@[87; 88) | ||
101 | NAME@[87; 88) | ||
102 | IDENT@[87; 88) "T" | ||
103 | R_ANGLE@[88; 89) | ||
104 | PARAM_LIST@[89; 97) | ||
105 | L_PAREN@[89; 90) | ||
106 | PARAM@[90; 96) | ||
107 | BIND_PAT@[90; 92) | ||
108 | NAME@[90; 92) | ||
109 | IDENT@[90; 92) "_t" | ||
110 | COLON@[92; 93) | ||
111 | WHITESPACE@[93; 94) | ||
112 | REFERENCE_TYPE@[94; 96) | ||
113 | AMP@[94; 95) | ||
114 | PATH_TYPE@[95; 96) | ||
115 | PATH@[95; 96) | ||
116 | PATH_SEGMENT@[95; 96) | ||
117 | NAME_REF@[95; 96) | ||
118 | IDENT@[95; 96) "T" | ||
119 | R_PAREN@[96; 97) | ||
120 | WHITESPACE@[97; 98) | ||
121 | WHERE_CLAUSE@[98; 131) | ||
122 | WHERE_KW@[98; 103) | ||
123 | WHITESPACE@[103; 104) | ||
124 | WHERE_PRED@[104; 131) | ||
125 | FOR_TYPE@[104; 121) | ||
126 | FOR_KW@[104; 107) | ||
127 | TYPE_PARAM_LIST@[107; 111) | ||
128 | L_ANGLE@[107; 108) | ||
129 | LIFETIME_PARAM@[108; 110) | ||
130 | LIFETIME@[108; 110) "'a" | ||
131 | R_ANGLE@[110; 111) | ||
132 | WHITESPACE@[111; 112) | ||
133 | REFERENCE_TYPE@[112; 121) | ||
134 | AMP@[112; 113) | ||
135 | LIFETIME@[113; 115) "'a" | ||
136 | WHITESPACE@[115; 116) | ||
137 | MUT_KW@[116; 119) | ||
138 | WHITESPACE@[119; 120) | ||
139 | PATH_TYPE@[120; 121) | ||
140 | PATH@[120; 121) | ||
141 | PATH_SEGMENT@[120; 121) | ||
142 | NAME_REF@[120; 121) | ||
143 | IDENT@[120; 121) "T" | ||
144 | COLON@[121; 122) | ||
145 | WHITESPACE@[122; 123) | ||
146 | PATH_TYPE@[123; 131) | ||
147 | PATH@[123; 131) | ||
148 | PATH_SEGMENT@[123; 131) | ||
149 | NAME_REF@[123; 131) | ||
150 | IDENT@[123; 131) "Iterator" | ||
151 | WHITESPACE@[131; 132) | ||
152 | BLOCK@[132; 134) | ||
153 | L_CURLY@[132; 133) | ||
154 | R_CURLY@[133; 134) | ||
155 | WHITESPACE@[134; 135) | ||