Auto merge of #13242 - Veykril:completion-alias, r=Veykril

Complete variants and assoc items in path pattern through type aliases
This commit is contained in:
bors 2022-09-16 14:12:26 +00:00
commit 870bfc7e3b
2 changed files with 28 additions and 0 deletions

View file

@ -145,6 +145,7 @@ pub(crate) fn complete_pattern_path(
u.ty(ctx.db)
}
hir::PathResolution::Def(hir::ModuleDef::BuiltinType(ty)) => ty.ty(ctx.db),
hir::PathResolution::Def(hir::ModuleDef::TypeAlias(ty)) => ty.ty(ctx.db),
_ => return,
};

View file

@ -714,3 +714,30 @@ impl Ty {
"#]],
);
}
#[test]
fn through_alias() {
check_empty(
r#"
enum Enum<T> {
Unit,
Tuple(T),
}
type EnumAlias<T> = Enum<T>;
fn f(x: EnumAlias<u8>) {
match x {
EnumAlias::$0 => (),
_ => (),
}
}
"#,
expect![[r#"
bn Tuple() Tuple($1)$0
bn Unit Unit$0
"#]],
);
}