Skip to content

Commit

Permalink
Auto merge of #17551 - Veykril:has-errors, r=Veykril
Browse files Browse the repository at this point in the history
Also mark InferenceResult::has_errors flag when there are error types

Should work around #15090 (comment)
  • Loading branch information
bors committed Jul 6, 2024
2 parents 1adb52c + e0105c4 commit 058c88d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions crates/hir-ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions crates/hir-ty/src/mir/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 058c88d

Please sign in to comment.