Skip to content

Commit a73e276

Browse files
committed
fix: silence mismatches involving unresolved projections
1 parent 899db83 commit a73e276

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/hir-ty/src/chalk_ext.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub trait TyExt {
2929
fn contains_unknown(&self) -> bool;
3030
fn is_ty_var(&self) -> bool;
3131
fn is_union(&self) -> bool;
32+
fn is_projection(&self) -> bool;
3233

3334
fn as_adt(&self) -> Option<(hir_def::AdtId, &Substitution)>;
3435
fn as_builtin(&self) -> Option<BuiltinType>;
@@ -93,6 +94,11 @@ impl TyExt for Ty {
9394
self.data(Interner).flags.contains(TypeFlags::HAS_ERROR)
9495
}
9596

97+
fn is_projection(&self) -> bool {
98+
matches!(self.kind(Interner), TyKind::Alias(AliasTy::Projection(_))) ||
99+
matches!(self.kind(Interner), TyKind::AssociatedType(_, _))
100+
}
101+
96102
fn is_ty_var(&self) -> bool {
97103
matches!(self.kind(Interner), TyKind::InferenceVar(_, _))
98104
}

crates/hir/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,12 @@ impl DefWithBody {
16791679
acc.extend(AnyDiagnostic::inference_diagnostic(db, self.into(), d, &source_map));
16801680
}
16811681
for (pat_or_expr, mismatch) in infer.type_mismatches() {
1682+
// Silence mismatches involving unresolved projections
1683+
let is_unknown_proj = |ty: &Ty| ty.contains_unknown() && ty.is_projection();
1684+
if is_unknown_proj(&mismatch.expected) || is_unknown_proj(&mismatch.actual) {
1685+
continue;
1686+
}
1687+
16821688
let expr_or_pat = match pat_or_expr {
16831689
ExprOrPatId::ExprId(expr) => source_map.expr_syntax(expr).map(Either::Left),
16841690
ExprOrPatId::PatId(pat) => source_map.pat_syntax(pat).map(Either::Right),

0 commit comments

Comments
 (0)