Allow mutable borrows to coerce into immutable

This commit is contained in:
Sofia 2025-07-27 21:41:34 +03:00
parent 1c83ca44ab
commit cc367a38e7

View File

@ -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()))