From 472317c00870c007f552cde1f3c490e04f29919a Mon Sep 17 00:00:00 2001 From: Dawer <7803845+iDawer@users.noreply.github.com> Date: Wed, 19 May 2021 09:23:16 +0500 Subject: internal: Record mismatches of pattern types. --- crates/hir_ty/src/infer/pat.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/infer/pat.rs') diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 60b94a642..b15f4977d 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -10,7 +10,7 @@ use hir_def::{ }; use hir_expand::name::Name; -use super::{BindingMode, Expectation, InferenceContext}; +use super::{BindingMode, Expectation, InferenceContext, TypeMismatch}; use crate::{ lower::lower_to_chalk_mutability, static_lifetime, Interner, Substitution, Ty, TyBuilder, TyExt, TyKind, @@ -266,7 +266,10 @@ impl<'a> InferenceContext<'a> { // use a new type variable if we got error type here let ty = self.insert_type_vars_shallow(ty); if !self.unify(&ty, expected) { - // FIXME record mismatch, we need to change the type of self.type_mismatches for that + self.result.type_mismatches.insert( + pat.into(), + TypeMismatch { expected: expected.clone(), actual: ty.clone() }, + ); } let ty = self.resolve_ty_as_possible(ty); self.write_pat_ty(pat, ty.clone()); -- cgit v1.2.3