mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
fix variant resolve for type alias
This commit is contained in:
parent
79ec2c584b
commit
2411f1383a
4 changed files with 62 additions and 14 deletions
|
@ -1152,20 +1152,15 @@ impl<'a> InferenceContext<'a> {
|
|||
(ty, variant)
|
||||
}
|
||||
TypeNs::TypeAliasId(it) => {
|
||||
let container = it.lookup(self.db.upcast()).container;
|
||||
let parent_subst = match container {
|
||||
ItemContainerId::TraitId(id) => {
|
||||
let subst = TyBuilder::subst_for_def(self.db, id, None)
|
||||
.fill_with_inference_vars(&mut self.table)
|
||||
.build();
|
||||
Some(subst)
|
||||
}
|
||||
// Type aliases do not exist in impls.
|
||||
_ => None,
|
||||
let resolved_seg = match unresolved {
|
||||
None => path.segments().last().unwrap(),
|
||||
Some(n) => path.segments().get(path.segments().len() - n - 1).unwrap(),
|
||||
};
|
||||
let ty = TyBuilder::def_ty(self.db, it.into(), parent_subst)
|
||||
.fill_with_inference_vars(&mut self.table)
|
||||
.build();
|
||||
let substs =
|
||||
ctx.substs_from_path_segment(resolved_seg, Some(it.into()), true, None);
|
||||
let ty = self.db.ty(it.into());
|
||||
let ty = self.insert_type_vars(ty.substitute(Interner, &substs));
|
||||
|
||||
self.resolve_variant_on_alias(ty, unresolved, mod_path)
|
||||
}
|
||||
TypeNs::AdtSelfType(_) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue