Merge pull request #21028 from A4-Tacks/comp-pattern-alias

Fix not complete type alias in pattern
This commit is contained in:
Shoyu Vanilla (Flint) 2025-11-27 06:06:53 +00:00 committed by GitHub
commit f5a46ef424
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -101,6 +101,7 @@ pub(crate) fn complete_pattern(
hir::ModuleDef::Const(..) => refutable,
hir::ModuleDef::Module(..) => true,
hir::ModuleDef::Macro(mac) => mac.is_fn_like(ctx.db),
hir::ModuleDef::TypeAlias(_) => true,
_ => false,
},
hir::ScopeDef::ImplSelfType(impl_) => match impl_.self_ty(ctx.db).as_adt() {

View file

@ -821,6 +821,37 @@ fn f(x: EnumAlias<u8>) {
);
}
#[test]
fn through_alias_it_self() {
check(
r#"
enum Enum<T> {
Unit,
Tuple(T),
}
type EnumAlias<T> = Enum<T>;
fn f(x: EnumAlias<u8>) {
match x {
$0 => (),
_ => (),
}
}
"#,
expect![[r#"
en Enum
ta EnumAlias
bn Enum::Tuple() Enum::Tuple($1)$0
bn Enum::Unit Enum::Unit$0
kw mut
kw ref
"#]],
);
}
#[test]
fn pat_no_unstable_item_on_stable() {
check(