Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-ty/src/infer/expr.rs | 2 | ||||
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/type_mismatch.rs | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 8df6d9bee4..c7562567ef 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -306,7 +306,7 @@ impl<'db> InferenceContext<'_, 'db> { } } else { if let Some(expected_ty) = expected.only_has_type(&mut self.table) { - _ = self.demand_eqtype(expr.into(), ty, expected_ty); + _ = self.demand_eqtype(expr.into(), expected_ty, ty); } ty } diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs index 678e45e145..f1b597b44f 100644 --- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs +++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs @@ -1207,6 +1207,20 @@ fn f() { } #[test] + fn type_mismatch_in_condition() { + check_diagnostics( + r#" +fn f() { + if 1 {} + //^ error: expected bool, found i32 + match () { _ if 1 => (), _ => () } + //^ error: expected bool, found i32 +} +"#, + ); + } + + #[test] fn regression_14768() { check_diagnostics( r#" |