mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-23 08:48:08 +00:00
Merge pull request #21028 from A4-Tacks/comp-pattern-alias
Fix not complete type alias in pattern
This commit is contained in:
commit
f5a46ef424
2 changed files with 32 additions and 0 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue