aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/tests/macros.rs83
1 files changed, 82 insertions, 1 deletions
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index 01935ec99..3eb01dbd0 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -135,7 +135,88 @@ fn infer_path_qualified_macros_expanded() {
135} 135}
136 136
137#[test] 137#[test]
138fn expr_macro_expanded_in_various_places() { 138fn expr_macro_def_expanded_in_various_places() {
139 check_infer(
140 r#"
141 macro spam() {
142 1isize
143 }
144
145 fn spam() {
146 spam!();
147 (spam!());
148 spam!().spam(spam!());
149 for _ in spam!() {}
150 || spam!();
151 while spam!() {}
152 break spam!();
153 return spam!();
154 match spam!() {
155 _ if spam!() => spam!(),
156 }
157 spam!()(spam!());
158 Spam { spam: spam!() };
159 spam!()[spam!()];
160 await spam!();
161 spam!() as usize;
162 &spam!();
163 -spam!();
164 spam!()..spam!();
165 spam!() + spam!();
166 }
167 "#,
168 expect![[r#"
169 !0..6 '1isize': isize
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 39..442 '{ ...!(); }': ()
195 73..94 'spam!(...am!())': {unknown}
196 100..119 'for _ ...!() {}': ()
197 104..105 '_': {unknown}
198 117..119 '{}': ()
199 124..134 '|| spam!()': || -> isize
200 140..156 'while ...!() {}': ()
201 154..156 '{}': ()
202 161..174 'break spam!()': !
203 180..194 'return spam!()': !
204 200..254 'match ... }': isize
205 224..225 '_': isize
206 259..275 'spam!(...am!())': {unknown}
207 281..303 'Spam {...m!() }': {unknown}
208 309..325 'spam!(...am!()]': {unknown}
209 350..366 'spam!(... usize': usize
210 372..380 '&spam!()': &isize
211 386..394 '-spam!()': isize
212 400..416 'spam!(...pam!()': {unknown}
213 422..439 'spam!(...pam!()': isize
214 "#]],
215 );
216}
217
218#[test]
219fn expr_macro_rules_expanded_in_various_places() {
139 check_infer( 220 check_infer(
140 r#" 221 r#"
141 macro_rules! spam { 222 macro_rules! spam {