From cc367a38e7baaa132d4d7288b7b7094ccdea6729 Mon Sep 17 00:00:00 2001 From: sofia Date: Sun, 27 Jul 2025 21:41:34 +0300 Subject: [PATCH] Allow mutable borrows to coerce into immutable --- reid/src/mir/typecheck/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reid/src/mir/typecheck/mod.rs b/reid/src/mir/typecheck/mod.rs index ed524c0..14607cf 100644 --- a/reid/src/mir/typecheck/mod.rs +++ b/reid/src/mir/typecheck/mod.rs @@ -152,7 +152,7 @@ impl TypeKind { (TypeKind::Borrow(val1, mut1), TypeKind::Borrow(val2, mut2)) => { // Extracted to give priority for other collapse-error let collapsed = val1.narrow_into(val2)?; - if mut1 == mut2 { + if mut1 == mut2 || (*mut1 && !mut2) { Ok(TypeKind::Borrow(Box::new(collapsed), *mut1 && *mut2)) } else { Err(ErrorKind::TypesDifferMutability(self.clone(), other.clone()))