use modify over getting a mutable reference

This commit is contained in:
Folkert 2022-05-20 21:01:50 +02:00
parent 8a361bb68a
commit 4489a308e4
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 27 additions and 27 deletions

View file

@ -391,14 +391,14 @@ fn deep_copy_type_vars<'a>(
// in one go (without looking at the UnificationTable) and clear the copy field
let mut result = Vec::with_capacity_in(copied.len(), arena);
for var in copied {
let descriptor = subs.get_ref_mut(var);
if let Some(copy) = descriptor.copy.into_variable() {
result.push((var, copy));
descriptor.copy = OptVariable::NONE;
} else {
debug_assert!(false, "{:?} marked as copied but it wasn't", var);
}
subs.modify(var, |descriptor| {
if let Some(copy) = descriptor.copy.into_variable() {
result.push((var, copy));
descriptor.copy = OptVariable::NONE;
} else {
debug_assert!(false, "{:?} marked as copied but it wasn't", var);
}
})
}
debug_assert!(result.contains(&(var, cloned_var)));