diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-10 14:52:25 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-10 14:52:25 +0100 |
commit | 38e0d0f3348900bb4078deb09d48c5b6483d43d6 (patch) | |
tree | 6076dca34f94c198541850c8a3ce39c2e5173c89 /crates/ra_hir_ty/src/tests.rs | |
parent | 0a891d19ae6740c13ddbf8dfaf8b4703d5ca821b (diff) | |
parent | e63315b8f189396cf556f21d4ca27ae4281d17d7 (diff) |
Merge #3905
3905: add ellipsis field to hir pat record r=matklad a=JoshMcguigan
This PR corrects a `fixme`, adding an `ellipsis` field to the hir `Pat::Record` type. It will also be unlock some useful follow on work for #3894.
Additionally it adds a diagnostic for missing fields in record patterns.
~~Marking as a draft because I don't have any tests, and a small amount of manual testing on my branch from #3894 suggests it might *not* be working. Any thoughts on how I can best test this, or else pointers on where I might be going wrong?~~
Co-authored-by: Josh Mcguigan <[email protected]>
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 | } | ||