aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/diagnostics/pattern.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir_ty/src/diagnostics/pattern.rs b/crates/hir_ty/src/diagnostics/pattern.rs
index 6646826b3..5c9419d2c 100644
--- a/crates/hir_ty/src/diagnostics/pattern.rs
+++ b/crates/hir_ty/src/diagnostics/pattern.rs
@@ -99,6 +99,10 @@ impl<'a> PatCtxt<'a> {
99 let kind = match self.body[pat] { 99 let kind = match self.body[pat] {
100 hir_def::expr::Pat::Wild => PatKind::Wild, 100 hir_def::expr::Pat::Wild => PatKind::Wild,
101 101
102 hir_def::expr::Pat::Path(ref path) => {
103 return self.lower_path(pat, path);
104 }
105
102 hir_def::expr::Pat::Tuple { ref args, ellipsis } => { 106 hir_def::expr::Pat::Tuple { ref args, ellipsis } => {
103 let arity = match *ty.kind(&Interner) { 107 let arity = match *ty.kind(&Interner) {
104 TyKind::Tuple(arity, _) => arity, 108 TyKind::Tuple(arity, _) => arity,
@@ -193,6 +197,20 @@ impl<'a> PatCtxt<'a> {
193 // TODO: do we need PatKind::AscribeUserType ? 197 // TODO: do we need PatKind::AscribeUserType ?
194 kind 198 kind
195 } 199 }
200
201 fn lower_path(&mut self, pat: hir_def::expr::PatId, path: &hir_def::path::Path) -> Pat {
202 let ty = &self.infer[pat];
203
204 let pat_from_kind = |kind| Pat { ty: ty.clone(), kind: Box::new(kind) };
205
206 match self.infer.variant_resolution_for_pat(pat) {
207 Some(_) => pat_from_kind(self.lower_variant_or_leaf(pat, ty, Vec::new())),
208 None => {
209 self.errors.push(PatternError::Unimplemented);
210 pat_from_kind(PatKind::Wild)
211 }
212 }
213 }
196} 214}
197 215
198#[cfg(test)] 216#[cfg(test)]