aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics
diff options
context:
space:
mode:
authorDawer <[email protected]>2021-04-30 09:33:07 +0100
committerDawer <[email protected]>2021-05-31 20:03:46 +0100
commitb4f41973326a684844ffe23c5816e17d485b4203 (patch)
treeb0537c97119fb24c189d98055b29477110c0bf36 /crates/hir_ty/src/diagnostics
parent678d85ca7e4d7e631a450b8c050fe7696da0cac3 (diff)
Build wildcard witnesses instead of panicking
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r--crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
index 7bd02a502..60323aea3 100644
--- a/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
+++ b/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
@@ -496,6 +496,8 @@ impl Fields {
496 pub(super) fn apply(self, pcx: PatCtxt<'_>, ctor: &Constructor) -> Pat { 496 pub(super) fn apply(self, pcx: PatCtxt<'_>, ctor: &Constructor) -> Pat {
497 let subpatterns_and_indices = self.patterns_and_indices(); 497 let subpatterns_and_indices = self.patterns_and_indices();
498 let mut subpatterns = subpatterns_and_indices.iter().map(|&(_, p)| p); 498 let mut subpatterns = subpatterns_and_indices.iter().map(|&(_, p)| p);
499 // TODO witnesses are not yet used
500 const TODO: Pat = Pat::Wild;
499 501
500 match ctor { 502 match ctor {
501 Single | Variant(_) => match pcx.ty.kind(&Interner) { 503 Single | Variant(_) => match pcx.ty.kind(&Interner) {
@@ -509,7 +511,7 @@ impl Fields {
509 let path = find_path(pcx.cx.db.upcast(), item, pcx.cx.module) 511 let path = find_path(pcx.cx.db.upcast(), item, pcx.cx.module)
510 .map(|mpath| Path::from_known_path(mpath, Vec::new()).into()); 512 .map(|mpath| Path::from_known_path(mpath, Vec::new()).into());
511 match adt { 513 match adt {
512 hir_def::AdtId::EnumId(_) => todo!(), 514 hir_def::AdtId::EnumId(id) => TODO,
513 hir_def::AdtId::StructId(id) => { 515 hir_def::AdtId::StructId(id) => {
514 let variant_data = &pcx.cx.db.struct_data(id).variant_data; 516 let variant_data = &pcx.cx.db.struct_data(id).variant_data;
515 let args = subpatterns_and_indices 517 let args = subpatterns_and_indices
@@ -522,7 +524,7 @@ impl Fields {
522 .collect(); 524 .collect();
523 Pat::Record { path, args, ellipsis: false } 525 Pat::Record { path, args, ellipsis: false }
524 } 526 }
525 hir_def::AdtId::UnionId(_) => todo!(), 527 hir_def::AdtId::UnionId(_) => Pat::Wild,
526 } 528 }
527 } else { 529 } else {
528 Pat::Tuple { args: subpatterns, ellipsis: None } 530 Pat::Tuple { args: subpatterns, ellipsis: None }
@@ -540,12 +542,10 @@ impl Fields {
540 } 542 }
541 _ => Pat::Wild, 543 _ => Pat::Wild,
542 }, 544 },
543 Constructor::Slice(slice) => { 545 Constructor::Slice(slice) => TODO,
544 todo!() 546 Str(_) => TODO,
545 } 547 FloatRange(..) => TODO,
546 Str(_) => todo!(), 548 Constructor::IntRange(_) => TODO,
547 FloatRange(..) => todo!(),
548 Constructor::IntRange(_) => todo!(),
549 NonExhaustive => Pat::Wild, 549 NonExhaustive => Pat::Wild,
550 Wildcard => Pat::Wild, 550 Wildcard => Pat::Wild,
551 Opaque => panic!("bug: we should not try to apply an opaque constructor"), 551 Opaque => panic!("bug: we should not try to apply an opaque constructor"),