diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 002cffba6..47a7b9ffd 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -409,3 +409,43 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_fields() { | |||
409 | 409 | ||
410 | assert_snapshot!(diagnostics, @r###""###); | 410 | assert_snapshot!(diagnostics, @r###""###); |
411 | } | 411 | } |
412 | |||
413 | #[test] | ||
414 | fn missing_record_pat_field_diagnostic() { | ||
415 | let diagnostics = TestDB::with_files( | ||
416 | r" | ||
417 | //- /lib.rs | ||
418 | struct S { foo: i32, bar: () } | ||
419 | fn baz(s: S) { | ||
420 | let S { foo: _ } = s; | ||
421 | } | ||
422 | ", | ||
423 | ) | ||
424 | .diagnostics() | ||
425 | .0; | ||
426 | |||
427 | assert_snapshot!(diagnostics, @r###" | ||
428 | "{ foo: _ }": Missing structure fields: | ||
429 | - bar | ||
430 | "### | ||
431 | ); | ||
432 | } | ||
433 | |||
434 | #[test] | ||
435 | fn missing_record_pat_field_no_diagnostic_if_not_exhaustive() { | ||
436 | let diagnostics = TestDB::with_files( | ||
437 | r" | ||
438 | //- /lib.rs | ||
439 | struct S { foo: i32, bar: () } | ||
440 | fn baz(s: S) -> i32 { | ||
441 | match s { | ||
442 | S { foo, .. } => foo, | ||
443 | } | ||
444 | } | ||
445 | ", | ||
446 | ) | ||
447 | .diagnostics() | ||
448 | .0; | ||
449 | |||
450 | assert_snapshot!(diagnostics, @""); | ||
451 | } | ||