mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
use modify over getting a mutable reference
This commit is contained in:
parent
8a361bb68a
commit
4489a308e4
4 changed files with 27 additions and 27 deletions
|
@ -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)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue