Skip to content

Commit 9194c7a

Browse files
committed
Auto merge of rust-lang#17551 - Veykril:has-errors, r=Veykril
Also mark InferenceResult::has_errors flag when there are error types Should work around rust-lang/rust-analyzer#15090 (comment)
2 parents e907f81 + 725e15f commit 9194c7a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/infer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,23 @@ impl<'a> InferenceContext<'a> {
701701
table.propagate_diverging_flag();
702702
for ty in type_of_expr.values_mut() {
703703
*ty = table.resolve_completely(ty.clone());
704+
*has_errors = *has_errors || ty.contains_unknown();
704705
}
705706
for ty in type_of_pat.values_mut() {
706707
*ty = table.resolve_completely(ty.clone());
708+
*has_errors = *has_errors || ty.contains_unknown();
707709
}
708710
for ty in type_of_binding.values_mut() {
709711
*ty = table.resolve_completely(ty.clone());
712+
*has_errors = *has_errors || ty.contains_unknown();
710713
}
711714
for ty in type_of_rpit.values_mut() {
712715
*ty = table.resolve_completely(ty.clone());
716+
*has_errors = *has_errors || ty.contains_unknown();
713717
}
714718
for ty in type_of_for_iterator.values_mut() {
715719
*ty = table.resolve_completely(ty.clone());
720+
*has_errors = *has_errors || ty.contains_unknown();
716721
}
717722

718723
*has_errors = !type_mismatches.is_empty();

src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,9 +2160,7 @@ pub fn lower_to_mir(
21602160
root_expr: ExprId,
21612161
) -> Result<MirBody> {
21622162
if infer.has_errors {
2163-
return Err(MirLowerError::TypeMismatch(
2164-
infer.type_mismatches().next().map(|(_, it)| it.clone()),
2165-
));
2163+
return Err(MirLowerError::TypeMismatch(None));
21662164
}
21672165
let mut ctx = MirLowerCtx::new(db, owner, body, infer);
21682166
// 0 is return local

0 commit comments

Comments
 (0)