Fix the wrong path resolution

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2022-03-16 20:54:01 +08:00
parent a9aae250ed
commit c6ef4e830e
2 changed files with 9 additions and 2 deletions

View file

@ -143,10 +143,15 @@ fn pattern_path_completion(
.into_iter()
.for_each(|variant| acc.add_enum_variant(ctx, variant, None));
}
res @ (hir::PathResolution::TypeParam(_) | hir::PathResolution::SelfType(_)) => {
res @ (hir::PathResolution::TypeParam(_)
| hir::PathResolution::SelfType(_)
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(_)))) => {
let ty = match res {
hir::PathResolution::TypeParam(param) => param.ty(ctx.db),
hir::PathResolution::SelfType(impl_def) => impl_def.self_ty(ctx.db),
hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(s))) => {
s.ty(ctx.db)
}
_ => return,
};

View file

@ -463,6 +463,8 @@ fn f(t: Ty) {
}
}
"#,
expect![[""]],
expect![[r#"
ct ABC const ABC: Self
"#]],
)
}