Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #17551 - Veykril:has-errors, r=Veykril
Also mark InferenceResult::has_errors flag when there are error types
Should work around https://github.com/rust-lang/rust-analyzer/issues/15090#issuecomment-2211647133
| -rw-r--r-- | crates/hir-ty/src/infer.rs | 5 | ||||
| -rw-r--r-- | crates/hir-ty/src/mir/lower.rs | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs index f3ad4e6869..66ee02d74d 100644 --- a/crates/hir-ty/src/infer.rs +++ b/crates/hir-ty/src/infer.rs @@ -701,18 +701,23 @@ impl<'a> InferenceContext<'a> { table.propagate_diverging_flag(); for ty in type_of_expr.values_mut() { *ty = table.resolve_completely(ty.clone()); + *has_errors = *has_errors || ty.contains_unknown(); } for ty in type_of_pat.values_mut() { *ty = table.resolve_completely(ty.clone()); + *has_errors = *has_errors || ty.contains_unknown(); } for ty in type_of_binding.values_mut() { *ty = table.resolve_completely(ty.clone()); + *has_errors = *has_errors || ty.contains_unknown(); } for ty in type_of_rpit.values_mut() { *ty = table.resolve_completely(ty.clone()); + *has_errors = *has_errors || ty.contains_unknown(); } for ty in type_of_for_iterator.values_mut() { *ty = table.resolve_completely(ty.clone()); + *has_errors = *has_errors || ty.contains_unknown(); } *has_errors = !type_mismatches.is_empty(); diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index f7119c303a..3402b761d3 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -2160,9 +2160,7 @@ pub fn lower_to_mir( root_expr: ExprId, ) -> Result<MirBody> { if infer.has_errors { - return Err(MirLowerError::TypeMismatch( - infer.type_mismatches().next().map(|(_, it)| it.clone()), - )); + return Err(MirLowerError::TypeMismatch(None)); } let mut ctx = MirLowerCtx::new(db, owner, body, infer); // 0 is return local |