1 //! Completion tests for pattern position.
2 use expect_test
::{expect, Expect}
;
4 use crate::tests
::{check_edit, completion_list, BASE_ITEMS_FIXTURE}
;
6 fn check_empty(ra_fixture
: &str, expect
: Expect
) {
7 let actual
= completion_list(ra_fixture
);
8 expect
.assert_eq(&actual
)
11 fn check(ra_fixture
: &str, expect
: Expect
) {
12 let actual
= completion_list(&format
!("{}\n{}", BASE_ITEMS_FIXTURE
, ra_fixture
));
13 expect
.assert_eq(&actual
)
29 fn ident_rebind_pat() {
68 fn ident_ref_mut_pat() {
130 ma makro!(…) macro_rules! makro
136 bn Record {…} Record { field$1 }$0
137 bn Tuple(…) Tuple($1)$0
138 bn TupleV(…) TupleV($1)$0
149 enum SingleVariantEnum {
152 use SingleVariantEnum::Variant;
159 ma makro!(…) macro_rules! makro
165 bn Record {…} Record { field$1 }$0
166 bn Tuple(…) Tuple($1)$0
182 ma makro!(…) macro_rules! makro
187 bn Record {…} Record { field$1 }: Record$0
188 bn Tuple(…) Tuple($1): Tuple$0
199 ma makro!(…) macro_rules! makro
204 bn Record {…} Record { field$1 }$0
205 bn Tuple(…) Tuple($1)$0
213 fn only_fn_like_macros() {
216 macro_rules! m { ($e:expr) => { $e } }
218 #[rustc_builtin_macro]
226 ma m!(…) macro_rules! m
234 fn in_simple_macro_call() {
237 macro_rules! m { ($e:expr) => { $e } }
241 m!(match E::X { a$0 })
246 ma m!(…) macro_rules! m
255 fn omits_private_fields_pat() {
259 pub struct Record { pub field: i32, _field: i32 }
260 pub struct Tuple(pub u32, u32);
261 pub struct Invisible(u32, u32);
274 bn Record {…} Record { field$1, .. }$0
275 bn Tuple(…) Tuple($1, ..)$0
283 fn completes_self_pats() {
299 bn Self(…) Self($1)$0
307 fn enum_qualified() {
312 const ASSOC_CONST: () = ();
316 if let Enum::$0 = unknown {}
320 ct ASSOC_CONST const ASSOC_CONST: ()
321 bn RecordV {…} RecordV { field$1 }$0
322 bn TupleV(…) TupleV($1)$0
329 fn completes_in_record_field_pat() {
332 struct Foo { bar: Bar }
334 fn outer(Foo { bar: $0 }: Foo) {}
340 bn Foo {…} Foo { bar$1 }$0
348 fn skips_in_record_field_pat_name() {
351 struct Foo { bar: Bar }
353 fn outer(Foo { bar$0 }: Foo) {}
363 fn completes_in_fn_param() {
366 struct Foo { bar: Bar }
373 bn Bar(…) Bar($1): Bar$0
374 bn Foo {…} Foo { bar$1 }: Foo$0
382 fn completes_in_closure_param() {
385 struct Foo { bar: Bar }
395 bn Foo {…} Foo { bar$1 }$0
403 fn completes_no_delims_if_existing() {
421 struct Foo { bar: u32 }
423 match (Foo { bar: 0 }) {
440 match Enum::TupleVariant(0) {
446 bn TupleVariant TupleVariant
452 RecordVariant { field: u32 }
455 match (Enum::RecordVariant { field: 0 }) {
456 Enum::RecordV$0 { field } => {}
461 bn RecordVariant RecordVariant
467 fn completes_enum_variant_pat() {
468 cov_mark
::check
!(enum_variant_pattern_path
);
473 RecordVariant { field: u32 }
476 match (Enum::RecordVariant { field: 0 }) {
483 RecordVariant { field: u32 }
486 match (Enum::RecordVariant { field: 0 }) {
487 Enum::RecordVariant { field$1 }$0
495 fn completes_enum_variant_pat_escape() {
496 cov_mark
::check
!(enum_variant_pattern_path
);
503 r#struct { r#type: i32 },
514 bn Enum::B {…} Enum::B { r#type$1 }$0
515 bn Enum::struct {…} Enum::r#struct { r#type$1 }$0
516 bn Enum::type Enum::r#type$0
528 r#struct { r#type: i32 },
538 bn B {…} B { r#type$1 }$0
539 bn struct {…} r#struct { r#type$1 }$0
546 fn completes_associated_const() {
549 #[derive(PartialEq, Eq)]
553 const ABC: Self = Self(0);
564 ct ABC const ABC: Self
573 pub const A: i32 = 123;
574 pub const B: i32 = 456;
585 ct A pub const A: i32
586 ct B pub const B: i32
598 pub const C: i32 = 123;
599 pub const D: i32 = 456;
610 ct C pub const C: i32
611 ct D pub const D: i32
619 pub const MIN: Self = 0;
629 ct MIN pub const MIN: Self
635 fn in_method_param() {
649 bn Self(…) Self($1): Self$0
650 bn Ty(…) Ty($1): Ty$0
670 bn Self(…) Self($1): Self$0
671 bn Ty(…) Ty($1): Ty$0
691 bn Self(…) Self($1): Self$0
692 bn Ty(…) Ty($1): Ty$0
710 bn Self(…) Self($1): Self$0
711 bn Ty(…) Ty($1): Ty$0
727 type EnumAlias<T> = Enum<T>;
729 fn f(x: EnumAlias<u8>) {
739 bn Tuple(…) Tuple($1)$0