mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Lower and handle trait aliases in HIR
This commit is contained in:
parent
e2ec3a6561
commit
29c957f973
47 changed files with 334 additions and 75 deletions
|
@ -178,6 +178,7 @@ impl<'a> DeclValidator<'a> {
|
|||
AttrDefId::StaticId(sid) => Some(sid.lookup(self.db.upcast()).container.into()),
|
||||
AttrDefId::ConstId(cid) => Some(cid.lookup(self.db.upcast()).container.into()),
|
||||
AttrDefId::TraitId(tid) => Some(tid.lookup(self.db.upcast()).container.into()),
|
||||
AttrDefId::TraitAliasId(taid) => Some(taid.lookup(self.db.upcast()).container.into()),
|
||||
AttrDefId::ImplId(iid) => Some(iid.lookup(self.db.upcast()).container.into()),
|
||||
AttrDefId::ExternBlockId(id) => Some(id.lookup(self.db.upcast()).container.into()),
|
||||
// These warnings should not explore macro definitions at all
|
||||
|
|
|
@ -868,7 +868,10 @@ impl<'a> InferenceContext<'a> {
|
|||
// FIXME potentially resolve assoc type
|
||||
(self.err_ty(), None)
|
||||
}
|
||||
TypeNs::AdtId(AdtId::EnumId(_)) | TypeNs::BuiltinType(_) | TypeNs::TraitId(_) => {
|
||||
TypeNs::AdtId(AdtId::EnumId(_))
|
||||
| TypeNs::BuiltinType(_)
|
||||
| TypeNs::TraitId(_)
|
||||
| TypeNs::TraitAliasId(_) => {
|
||||
// FIXME diagnostic
|
||||
(self.err_ty(), None)
|
||||
}
|
||||
|
|
|
@ -522,6 +522,10 @@ impl<'a> TyLoweringContext<'a> {
|
|||
};
|
||||
return (ty, None);
|
||||
}
|
||||
TypeNs::TraitAliasId(_) => {
|
||||
// FIXME(trait_alias): Implement trait alias.
|
||||
return (TyKind::Error.intern(Interner), None);
|
||||
}
|
||||
TypeNs::GenericParam(param_id) => {
|
||||
let generics = generics(
|
||||
self.db.upcast(),
|
||||
|
@ -877,6 +881,7 @@ impl<'a> TyLoweringContext<'a> {
|
|||
) -> Option<TraitRef> {
|
||||
let resolved =
|
||||
match self.resolver.resolve_path_in_type_ns_fully(self.db.upcast(), path.mod_path())? {
|
||||
// FIXME(trait_alias): We need to handle trait alias here.
|
||||
TypeNs::TraitId(tr) => tr,
|
||||
_ => return None,
|
||||
};
|
||||
|
@ -1442,6 +1447,7 @@ pub(crate) fn trait_environment_query(
|
|||
GenericDefId::FunctionId(f) => Some(f.lookup(db.upcast()).container),
|
||||
GenericDefId::AdtId(_) => None,
|
||||
GenericDefId::TraitId(_) => None,
|
||||
GenericDefId::TraitAliasId(_) => None,
|
||||
GenericDefId::TypeAliasId(t) => Some(t.lookup(db.upcast()).container),
|
||||
GenericDefId::ImplId(_) => None,
|
||||
GenericDefId::EnumVariantId(_) => None,
|
||||
|
|
|
@ -315,7 +315,10 @@ fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option<Generic
|
|||
GenericDefId::TypeAliasId(it) => it.lookup(db).container,
|
||||
GenericDefId::ConstId(it) => it.lookup(db).container,
|
||||
GenericDefId::EnumVariantId(it) => return Some(it.parent.into()),
|
||||
GenericDefId::AdtId(_) | GenericDefId::TraitId(_) | GenericDefId::ImplId(_) => return None,
|
||||
GenericDefId::AdtId(_)
|
||||
| GenericDefId::TraitId(_)
|
||||
| GenericDefId::ImplId(_)
|
||||
| GenericDefId::TraitAliasId(_) => return None,
|
||||
};
|
||||
|
||||
match container {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue