diff --git a/crates/compiler/late_solve/src/storage.rs b/crates/compiler/late_solve/src/storage.rs index 5c501a40ee..3aa6b31595 100644 --- a/crates/compiler/late_solve/src/storage.rs +++ b/crates/compiler/late_solve/src/storage.rs @@ -20,7 +20,7 @@ impl ExternalModuleStorage { pub fn new(subs: Subs) -> Self { Self { storage: StorageSubs::new(subs), - variable_mapping_cache: VariableMapCache::new(), + variable_mapping_cache: VariableMapCache::default(), } } diff --git a/crates/compiler/types/src/subs.rs b/crates/compiler/types/src/subs.rs index c2b6b23170..607a98ba82 100644 --- a/crates/compiler/types/src/subs.rs +++ b/crates/compiler/types/src/subs.rs @@ -4017,11 +4017,13 @@ struct StorageSubsOffsets { #[derive(Clone, Debug)] pub struct VariableMapCache(pub Vec>); -impl VariableMapCache { - pub fn new() -> Self { +impl Default for VariableMapCache { + fn default() -> Self { Self(vec![Default::default()]) } +} +impl VariableMapCache { fn get(&self, v: &Variable) -> Option<&Variable> { self.0.iter().rev().find_map(|cache| cache.get(v)) } @@ -4050,7 +4052,7 @@ impl StorageSubs { pub fn extend_with_variable(&mut self, source: &Subs, variable: Variable) -> Variable { storage_copy_var_to( - &mut VariableMapCache::new(), + &mut VariableMapCache::default(), source, &mut self.subs, variable,