Skip to content

Commit da7c176

Browse files
committed
implement most of feature(more_qualified_paths)
This handles ```rust let <T as Trait>::Assoc { a } = <T as Trait>::Assoc { a: 0 }; let (<E as Trait>::Assoc::ES { a } | <E as Trait>::Assoc::ET(a)) = <E as Trait>::Assoc::ES { a: 0 }; ```
1 parent bf6d445 commit da7c176

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

crates/hir-ty/src/infer.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,10 +1646,24 @@ impl<'db> InferenceContext<'db> {
16461646
let ty = self.insert_type_vars(ty.substitute(Interner, &substs));
16471647
forbid_unresolved_segments((ty, Some(var.into())), unresolved)
16481648
}
1649-
TypeNs::SelfType(impl_id) => {
1650-
let generics = crate::generics::generics(self.db, impl_id.into());
1651-
let substs = generics.placeholder_subst(self.db);
1652-
let mut ty = self.db.impl_self_ty(impl_id).substitute(Interner, &substs);
1649+
TypeNs::SelfType(_) | TypeNs::TraitId(_) => {
1650+
let mut ty = match resolution {
1651+
TypeNs::TraitId(_) => {
1652+
let args = path.generic_args().unwrap()[0].as_ref().unwrap();
1653+
assert!(args.has_self_type);
1654+
let hir_def::expr_store::path::GenericArg::Type(type_idx) = args.args[0]
1655+
else {
1656+
panic!()
1657+
};
1658+
path_ctx.ty_ctx().lower_ty(type_idx)
1659+
}
1660+
TypeNs::SelfType(impl_id) => {
1661+
let generics = crate::generics::generics(self.db, impl_id.into());
1662+
let substs = generics.placeholder_subst(self.db);
1663+
self.db.impl_self_ty(impl_id).substitute(Interner, &substs)
1664+
}
1665+
_ => unreachable!(),
1666+
};
16531667

16541668
let Some(remaining_idx) = unresolved else {
16551669
drop(ctx);
@@ -1741,7 +1755,6 @@ impl<'db> InferenceContext<'db> {
17411755
}
17421756
TypeNs::AdtId(AdtId::EnumId(_))
17431757
| TypeNs::BuiltinType(_)
1744-
| TypeNs::TraitId(_)
17451758
| TypeNs::TraitAliasId(_)
17461759
| TypeNs::ModuleId(_) => {
17471760
// FIXME diagnostic

0 commit comments

Comments
 (0)