aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/lower.rs8
-rw-r--r--crates/hir_ty/src/tests/macros.rs14
2 files changed, 14 insertions, 8 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index a883334af..7fd46becd 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -296,9 +296,11 @@ impl<'a> TyLoweringContext<'a> {
296 } 296 }
297 } 297 }
298 TypeRef::Macro(macro_call) => { 298 TypeRef::Macro(macro_call) => {
299 let (expander, recursion_start) = match self.expander.borrow_mut() { 299 let (expander, recursion_start) = {
300 expander if expander.is_some() => (Some(expander), false), 300 let mut expander = self.expander.borrow_mut();
301 mut expander => { 301 if expander.is_some() {
302 (Some(expander), false)
303 } else {
302 if let Some(module_id) = self.resolver.module() { 304 if let Some(module_id) = self.resolver.module() {
303 *expander = Some(Expander::new( 305 *expander = Some(Expander::new(
304 self.db.upcast(), 306 self.db.upcast(),
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index 8de1e229f..6588aa46c 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -1248,14 +1248,18 @@ fn macros_in_type_generics() {
1248fn infinitely_recursive_macro_type() { 1248fn infinitely_recursive_macro_type() {
1249 check_infer( 1249 check_infer(
1250 r#" 1250 r#"
1251 struct Bar<T>(T); 1251 struct Bar<T, X>(T, X);
1252 1252
1253 macro_rules! Foo { 1253 macro_rules! Foo {
1254 () => { Foo!() } 1254 () => { Foo!() }
1255 } 1255 }
1256 1256
1257 macro_rules! U32 {
1258 () => { u32 }
1259 }
1260
1257 type A = Foo!(); 1261 type A = Foo!();
1258 type B = Bar<Foo!()>; 1262 type B = Bar<Foo!(), U32!()>;
1259 1263
1260 fn main() { 1264 fn main() {
1261 let a: A; 1265 let a: A;
@@ -1263,9 +1267,9 @@ fn infinitely_recursive_macro_type() {
1263 } 1267 }
1264 "#, 1268 "#,
1265 expect![[r#" 1269 expect![[r#"
1266 112..143 '{ ...: B; }': () 1270 166..197 '{ ...: B; }': ()
1267 122..123 'a': {unknown} 1271 176..177 'a': {unknown}
1268 136..137 'b': Bar<{unknown}> 1272 190..191 'b': Bar<{unknown}, u32>
1269 "#]], 1273 "#]],
1270 ); 1274 );
1271} 1275}