Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #21747 from ChayimFriedman2/never-upd-syn
fix: Allow never coercions in struct update syntax
Shoyu Vanilla (Flint) 7 weeks ago
parent e8b19c9 · parent 1a6d91e · commit 789ad51
-rw-r--r--crates/hir-ty/src/infer/expr.rs2
-rw-r--r--crates/hir-ty/src/tests/never_type.rs15
2 files changed, 16 insertions, 1 deletions
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs
index 16e7d51e87..45b181eff8 100644
--- a/crates/hir-ty/src/infer/expr.rs
+++ b/crates/hir-ty/src/infer/expr.rs
@@ -658,7 +658,7 @@ impl<'db> InferenceContext<'_, 'db> {
}
}
if let RecordSpread::Expr(expr) = *spread {
- self.infer_expr(expr, &Expectation::has_type(ty), ExprIsRead::Yes);
+ self.infer_expr_coerce_never(expr, &Expectation::has_type(ty), ExprIsRead::Yes);
}
ty
}
diff --git a/crates/hir-ty/src/tests/never_type.rs b/crates/hir-ty/src/tests/never_type.rs
index 1ff803ca42..993293bb56 100644
--- a/crates/hir-ty/src/tests/never_type.rs
+++ b/crates/hir-ty/src/tests/never_type.rs
@@ -886,3 +886,18 @@ fn foo() {
"#]],
);
}
+
+#[test]
+fn never_coercion_in_struct_update_syntax() {
+ check_no_mismatches(
+ r#"
+struct Struct {
+ field: i32,
+}
+
+fn example() -> Struct {
+ Struct { ..loop {} }
+}
+ "#,
+ );
+}