Complete variants and assoc items in path pattern through type aliases

This commit is contained in:
Lukas Wirth 2022-09-16 16:11:58 +02:00
parent 2b61be2975
commit ad17ba12d1
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 @@ fn foo(foo: u8, b$0)
"#]],
);
}
#[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
"#]],
);
}