Skip to content

Commit f5a46ef

Browse files
authored
Merge pull request #21028 from A4-Tacks/comp-pattern-alias
Fix not complete type alias in pattern
2 parents 4b236c7 + 92d1c54 commit f5a46ef

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

crates/ide-completion/src/completions/pattern.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub(crate) fn complete_pattern(
101101
hir::ModuleDef::Const(..) => refutable,
102102
hir::ModuleDef::Module(..) => true,
103103
hir::ModuleDef::Macro(mac) => mac.is_fn_like(ctx.db),
104+
hir::ModuleDef::TypeAlias(_) => true,
104105
_ => false,
105106
},
106107
hir::ScopeDef::ImplSelfType(impl_) => match impl_.self_ty(ctx.db).as_adt() {

crates/ide-completion/src/tests/pattern.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,37 @@ fn f(x: EnumAlias<u8>) {
821821
);
822822
}
823823

824+
#[test]
825+
fn through_alias_it_self() {
826+
check(
827+
r#"
828+
enum Enum<T> {
829+
Unit,
830+
Tuple(T),
831+
}
832+
833+
type EnumAlias<T> = Enum<T>;
834+
835+
fn f(x: EnumAlias<u8>) {
836+
match x {
837+
$0 => (),
838+
_ => (),
839+
}
840+
841+
}
842+
843+
"#,
844+
expect![[r#"
845+
en Enum
846+
ta EnumAlias
847+
bn Enum::Tuple(…) Enum::Tuple($1)$0
848+
bn Enum::Unit Enum::Unit$0
849+
kw mut
850+
kw ref
851+
"#]],
852+
);
853+
}
854+
824855
#[test]
825856
fn pat_no_unstable_item_on_stable() {
826857
check(

0 commit comments

Comments
 (0)