From f1f45f9191d60c52dbedec717aee0de4a0580bcc Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 21 Feb 2020 16:56:34 +0100 Subject: Fix handling of const patterns E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the option variant), not a binding. To determine this, we need to try to resolve the name during lowering. This isn't too hard since we already need to resolve names for macro expansion anyway (though maybe a bit hacky). Fixes #1618. --- crates/ra_hir_ty/src/infer/pat.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/infer/pat.rs') diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index a495ecbfe..bf8ea192b 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs @@ -189,7 +189,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { }; // use a new type variable if we got Ty::Unknown here let ty = self.insert_type_vars_shallow(ty); - self.unify(&ty, expected); + if !self.unify(&ty, expected) { + // FIXME record mismatch, we need to change the type of self.type_mismatches for that + } let ty = self.resolve_ty_as_possible(ty); self.write_pat_ty(pat, ty.clone()); ty -- cgit v1.2.3