hir_ty: Expand macros at type position

This commit is contained in:
cynecx 2021-04-10 17:49:12 +02:00
parent fb2d284f28
commit cf3b4f1e20
17 changed files with 434 additions and 81 deletions

View file

@ -15,7 +15,7 @@ use hir_def::{
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 @@ impl<'a> TyLoweringContext<'a> {
}
}
}
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)