]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/lower.rs
hir_ty: Expand macros at type position
[rust.git] / crates / hir_ty / src / lower.rs
index a035686bc9e1c80f67dcf78e4be3cd0f109ccd6f..95ca5bdb0971d5a7427e9b14480dc08712cc576b 100644 (file)
@@ -15,7 +15,7 @@
     generics::{TypeParamProvenance, WherePredicate, WherePredicateTypeTarget},
     path::{GenericArg, Path, PathSegment, PathSegments},
     resolver::{HasResolver, Resolver, TypeNs},
-    type_ref::{TraitRef as HirTraitRef, TypeBound, TypeRef},
+    type_ref::{expand_type_ref, TraitRef as HirTraitRef, TypeBound, TypeRef},
     AdtId, AssocContainerId, AssocItemId, ConstId, ConstParamId, EnumId, EnumVariantId, FunctionId,
     GenericDefId, HasModule, ImplId, LocalFieldId, Lookup, StaticId, StructId, TraitId,
     TypeAliasId, TypeParamId, UnionId, VariantId,
@@ -287,6 +287,16 @@ pub fn lower_ty_ext(&self, type_ref: &TypeRef) -> (Ty, Option<TypeNs>) {
                     }
                 }
             }
+            mt @ TypeRef::Macro(_) => {
+                if let Some(module_id) = self.resolver.module() {
+                    match expand_type_ref(self.db.upcast(), module_id, mt) {
+                        Some(type_ref) => self.lower_ty(type_ref.as_ref()),
+                        None => TyKind::Error.intern(&Interner),
+                    }
+                } else {
+                    TyKind::Error.intern(&Interner)
+                }
+            }
             TypeRef::Error => TyKind::Error.intern(&Interner),
         };
         (ty, res)