aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs19
-rw-r--r--crates/hir_ty/src/diagnostics/pattern/usefulness.rs12
2 files changed, 15 insertions, 16 deletions
diff --git a/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
index 479e0dc73..ddf6b1198 100644
--- a/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
+++ b/crates/hir_ty/src/diagnostics/pattern/deconstruct_pat.rs
@@ -837,20 +837,19 @@ impl Fields {
837 pat: PatId, 837 pat: PatId,
838 cx: &MatchCheckCtx<'_>, 838 cx: &MatchCheckCtx<'_>,
839 ) -> Self { 839 ) -> Self {
840 // TODO: these alocations are so unfortunate (+1 for switching to references) 840 // TODO: these alocations and clones are so unfortunate (+1 for switching to references)
841 match cx.pattern_arena.borrow()[pat].kind.as_ref() { 841 let mut arena = cx.pattern_arena.borrow_mut();
842 match arena[pat].kind.as_ref() {
842 PatKind::Deref { subpattern } => { 843 PatKind::Deref { subpattern } => {
843 assert_eq!(self.len(), 1); 844 assert_eq!(self.len(), 1);
844 let subpattern = cx.pattern_arena.borrow_mut().alloc(subpattern.clone()); 845 let subpattern = subpattern.clone();
845 Fields::from_single_pattern(subpattern) 846 Fields::from_single_pattern(arena.alloc(subpattern))
846 } 847 }
847 PatKind::Leaf { subpatterns } | PatKind::Variant { subpatterns, .. } => { 848 PatKind::Leaf { subpatterns } | PatKind::Variant { subpatterns, .. } => {
848 let subpatterns = subpatterns.iter().map(|field_pat| { 849 let subpatterns = subpatterns.clone();
849 ( 850 let subpatterns = subpatterns
850 field_pat.field, 851 .iter()
851 cx.pattern_arena.borrow_mut().alloc(field_pat.pattern.clone()), 852 .map(|field_pat| (field_pat.field, arena.alloc(field_pat.pattern.clone())));
852 )
853 });
854 self.replace_with_fieldpats(subpatterns) 853 self.replace_with_fieldpats(subpatterns)
855 } 854 }
856 855
diff --git a/crates/hir_ty/src/diagnostics/pattern/usefulness.rs b/crates/hir_ty/src/diagnostics/pattern/usefulness.rs
index 28b9e71f8..3bfb7afed 100644
--- a/crates/hir_ty/src/diagnostics/pattern/usefulness.rs
+++ b/crates/hir_ty/src/diagnostics/pattern/usefulness.rs
@@ -94,12 +94,12 @@ impl PatIdExt for PatId {
94 fn expand_or_pat(self, cx: &MatchCheckCtx<'_>) -> Vec<Self> { 94 fn expand_or_pat(self, cx: &MatchCheckCtx<'_>) -> Vec<Self> {
95 fn expand(pat: PatId, vec: &mut Vec<PatId>, mut pat_arena: &mut PatternArena) { 95 fn expand(pat: PatId, vec: &mut Vec<PatId>, mut pat_arena: &mut PatternArena) {
96 if let PatKind::Or { pats } = pat_arena[pat].kind.as_ref() { 96 if let PatKind::Or { pats } = pat_arena[pat].kind.as_ref() {
97 // for pat in pats { 97 let pats = pats.clone();
98 // // TODO(iDawer): Ugh, I want to go back to references (PatId -> &Pat) 98 for pat in pats {
99 // let pat = pat_arena.alloc(pat.clone()); 99 // TODO(iDawer): Ugh, I want to go back to references (PatId -> &Pat)
100 // expand(pat, vec, pat_arena); 100 let pat = pat_arena.alloc(pat.clone());
101 // } 101 expand(pat, vec, pat_arena);
102 todo!() 102 }
103 } else { 103 } else {
104 vec.push(pat) 104 vec.push(pat)
105 } 105 }