@@ -429,6 +429,8 @@ pub struct InferenceResult {
429429 /// Type of the result of `.into_iter()` on the for. `ExprId` is the one of the whole for loop.
430430 pub type_of_for_iterator : FxHashMap < ExprId , Ty > ,
431431 type_mismatches : FxHashMap < ExprOrPatId , TypeMismatch > ,
432+ /// Whether there are any type-mismatching errors in the result.
433+ pub ( crate ) has_errors : bool ,
432434 /// Interned common types to return references to.
433435 standard_types : InternedStandardTypes ,
434436 /// Stores the types which were implicitly dereferenced in pattern binding modes.
@@ -654,6 +656,7 @@ impl<'a> InferenceContext<'a> {
654656 type_of_rpit,
655657 type_of_for_iterator,
656658 type_mismatches,
659+ has_errors,
657660 standard_types : _,
658661 pat_adjustments,
659662 binding_modes : _,
@@ -695,6 +698,9 @@ impl<'a> InferenceContext<'a> {
695698 for ty in type_of_for_iterator. values_mut ( ) {
696699 * ty = table. resolve_completely ( ty. clone ( ) ) ;
697700 }
701+
702+ * has_errors = !type_mismatches. is_empty ( ) ;
703+
698704 type_mismatches. retain ( |_, mismatch| {
699705 mismatch. expected = table. resolve_completely ( mismatch. expected . clone ( ) ) ;
700706 mismatch. actual = table. resolve_completely ( mismatch. actual . clone ( ) ) ;
@@ -1646,9 +1652,11 @@ impl std::ops::BitOrAssign for Diverges {
16461652 * self = * self | other;
16471653 }
16481654}
1649- /// A zipper that checks for unequal `{unknown}` occurrences in the two types. Used to filter out
1650- /// mismatch diagnostics that only differ in `{unknown}`. These mismatches are usually not helpful.
1651- /// As the cause is usually an underlying name resolution problem.
1655+
1656+ /// A zipper that checks for unequal occurrences of `{unknown}` and unresolved projections
1657+ /// in the two types. Used to filter out mismatch diagnostics that only differ in
1658+ /// `{unknown}` and unresolved projections. These mismatches are usually not helpful.
1659+ /// As the cause is usually an underlying name resolution problem
16521660struct UnknownMismatch < ' db > ( & ' db dyn HirDatabase ) ;
16531661impl chalk_ir:: zip:: Zipper < Interner > for UnknownMismatch < ' _ > {
16541662 fn zip_tys ( & mut self , variance : Variance , a : & Ty , b : & Ty ) -> chalk_ir:: Fallible < ( ) > {
@@ -1721,7 +1729,12 @@ impl chalk_ir::zip::Zipper<Interner> for UnknownMismatch<'_> {
17211729 zip_substs ( self , None , & fn_ptr_a. substitution . 0 , & fn_ptr_b. substitution . 0 ) ?
17221730 }
17231731 ( TyKind :: Error , TyKind :: Error ) => ( ) ,
1724- ( TyKind :: Error , _) | ( _, TyKind :: Error ) => return Err ( chalk_ir:: NoSolution ) ,
1732+ ( TyKind :: Error , _)
1733+ | ( _, TyKind :: Error )
1734+ | ( TyKind :: Alias ( AliasTy :: Projection ( _) ) | TyKind :: AssociatedType ( _, _) , _)
1735+ | ( _, TyKind :: Alias ( AliasTy :: Projection ( _) ) | TyKind :: AssociatedType ( _, _) ) => {
1736+ return Err ( chalk_ir:: NoSolution )
1737+ }
17251738 _ => ( ) ,
17261739 }
17271740
0 commit comments