diff options
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 69c695cc8..9d09d93a7 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -136,6 +136,87 @@ fn main() { | |||
136 | } | 136 | } |
137 | 137 | ||
138 | #[test] | 138 | #[test] |
139 | fn expr_macro_expanded_in_various_places() { | ||
140 | assert_snapshot!( | ||
141 | infer(r#" | ||
142 | macro_rules! spam { | ||
143 | () => (1isize); | ||
144 | } | ||
145 | |||
146 | fn spam() { | ||
147 | spam!(); | ||
148 | (spam!()); | ||
149 | spam!().spam(spam!()); | ||
150 | for _ in spam!() {} | ||
151 | || spam!(); | ||
152 | while spam!() {} | ||
153 | break spam!(); | ||
154 | return spam!(); | ||
155 | match spam!() { | ||
156 | _ if spam!() => spam!(), | ||
157 | } | ||
158 | spam!()(spam!()); | ||
159 | Spam { spam: spam!() }; | ||
160 | spam!()[spam!()]; | ||
161 | await spam!(); | ||
162 | spam!() as usize; | ||
163 | &spam!(); | ||
164 | -spam!(); | ||
165 | spam!()..spam!(); | ||
166 | spam!() + spam!(); | ||
167 | } | ||
168 | "#), | ||
169 | @r###" | ||
170 | ![0; 6) '1isize': isize | ||
171 | ![0; 6) '1isize': isize | ||
172 | ![0; 6) '1isize': isize | ||
173 | ![0; 6) '1isize': isize | ||
174 | ![0; 6) '1isize': isize | ||
175 | ![0; 6) '1isize': isize | ||
176 | ![0; 6) '1isize': isize | ||
177 | ![0; 6) '1isize': isize | ||
178 | ![0; 6) '1isize': isize | ||
179 | ![0; 6) '1isize': isize | ||
180 | ![0; 6) '1isize': isize | ||
181 | ![0; 6) '1isize': isize | ||
182 | ![0; 6) '1isize': isize | ||
183 | ![0; 6) '1isize': isize | ||
184 | ![0; 6) '1isize': isize | ||
185 | ![0; 6) '1isize': isize | ||
186 | ![0; 6) '1isize': isize | ||
187 | ![0; 6) '1isize': isize | ||
188 | ![0; 6) '1isize': isize | ||
189 | ![0; 6) '1isize': isize | ||
190 | ![0; 6) '1isize': isize | ||
191 | ![0; 6) '1isize': isize | ||
192 | ![0; 6) '1isize': isize | ||
193 | ![0; 6) '1isize': isize | ||
194 | ![0; 6) '1isize': isize | ||
195 | [54; 457) '{ ...!(); }': ! | ||
196 | [88; 109) 'spam!(...am!())': {unknown} | ||
197 | [115; 134) 'for _ ...!() {}': () | ||
198 | [119; 120) '_': {unknown} | ||
199 | [132; 134) '{}': () | ||
200 | [139; 149) '|| spam!()': || -> isize | ||
201 | [155; 171) 'while ...!() {}': () | ||
202 | [169; 171) '{}': () | ||
203 | [176; 189) 'break spam!()': ! | ||
204 | [195; 209) 'return spam!()': ! | ||
205 | [215; 269) 'match ... }': isize | ||
206 | [239; 240) '_': isize | ||
207 | [274; 290) 'spam!(...am!())': {unknown} | ||
208 | [296; 318) 'Spam {...m!() }': {unknown} | ||
209 | [324; 340) 'spam!(...am!()]': {unknown} | ||
210 | [365; 381) 'spam!(... usize': usize | ||
211 | [387; 395) '&spam!()': &isize | ||
212 | [401; 409) '-spam!()': isize | ||
213 | [415; 431) 'spam!(...pam!()': {unknown} | ||
214 | [437; 454) 'spam!(...pam!()': isize | ||
215 | "### | ||
216 | ); | ||
217 | } | ||
218 | |||
219 | #[test] | ||
139 | fn infer_type_value_macro_having_same_name() { | 220 | fn infer_type_value_macro_having_same_name() { |
140 | assert_snapshot!( | 221 | assert_snapshot!( |
141 | infer(r#" | 222 | infer(r#" |