Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/pattern.rs')
| -rw-r--r-- | crates/ide-completion/src/tests/pattern.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/crates/ide-completion/src/tests/pattern.rs b/crates/ide-completion/src/tests/pattern.rs index 6eb0b818d6..b8728028bb 100644 --- a/crates/ide-completion/src/tests/pattern.rs +++ b/crates/ide-completion/src/tests/pattern.rs @@ -133,6 +133,44 @@ fn foo() { } #[test] +fn refutable_in_record_pat_field() { + check( + r#" +enum Bar { Value, Nil } +struct Foo { x: Bar } +fn foo(foo: Foo) { match foo { Foo { x: $0 } } } +"#, + expect![[r#" + en Bar + st Foo + bn Foo {…} Foo { x$1 }$0 + kw mut + kw ref + "#]], + ); + + check( + r#" +enum Bar { Value, Nil } +use Bar::*; +struct Foo { x: Bar } +fn foo(foo: Foo) { match foo { Foo { x: $0 } } } +"#, + expect![[r#" + en Bar + st Foo + ev Nil + ev Value + bn Foo {…} Foo { x$1 }$0 + bn Nil Nil$0 + bn Value Value$0 + kw mut + kw ref + "#]], + ); +} + +#[test] fn irrefutable() { check_with_base_items( r#" @@ -653,6 +691,7 @@ fn f(u: U) { check( r#" +//- /core.rs crate:core #![rustc_coherence_is_core] #[lang = "u32"] impl u32 { @@ -783,6 +822,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( r#" |