Skip to content

Commit 870bfc7

Browse files
committed
Auto merge of #13242 - Veykril:completion-alias, r=Veykril
Complete variants and assoc items in path pattern through type aliases
2 parents 6b163c3 + ad17ba1 commit 870bfc7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ pub(crate) fn complete_pattern_path(
145145
u.ty(ctx.db)
146146
}
147147
hir::PathResolution::Def(hir::ModuleDef::BuiltinType(ty)) => ty.ty(ctx.db),
148+
hir::PathResolution::Def(hir::ModuleDef::TypeAlias(ty)) => ty.ty(ctx.db),
148149
_ => return,
149150
};
150151

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

+27
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,30 @@ impl Ty {
714714
"#]],
715715
);
716716
}
717+
718+
#[test]
719+
fn through_alias() {
720+
check_empty(
721+
r#"
722+
enum Enum<T> {
723+
Unit,
724+
Tuple(T),
725+
}
726+
727+
type EnumAlias<T> = Enum<T>;
728+
729+
fn f(x: EnumAlias<u8>) {
730+
match x {
731+
EnumAlias::$0 => (),
732+
_ => (),
733+
}
734+
735+
}
736+
737+
"#,
738+
expect![[r#"
739+
bn Tuple(…) Tuple($1)$0
740+
bn Unit Unit$0
741+
"#]],
742+
);
743+
}

0 commit comments

Comments
 (0)