Skip to content

Commit 8ce4762

Browse files
branchseerclaude
andcommitted
refactor(cache): destructure CacheEntryKey in mismatch detection
Use struct field matching so adding a new field to CacheEntryKey causes a compile error here, forcing the developer to handle it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2c8bd52 commit 8ce4762

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • crates/vite_task/src/session/cache

crates/vite_task/src/session/cache/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,18 @@ impl ExecutionCache {
238238
if let Some(old_cache_key) =
239239
self.get_cache_key_by_execution_key(execution_cache_key).await?
240240
{
241-
// Determine what changed: spawn fingerprint or config (input_config / glob_base)
242-
let mismatch = if old_cache_key.spawn_fingerprint == *spawn_fingerprint {
241+
// Destructure to ensure we handle all fields when new ones are added
242+
let CacheEntryKey {
243+
spawn_fingerprint: old_spawn_fingerprint,
244+
input_config: _,
245+
glob_base: _,
246+
} = old_cache_key;
247+
let mismatch = if old_spawn_fingerprint == *spawn_fingerprint {
243248
// spawn fingerprint is the same but input_config or glob_base changed
244249
FingerprintMismatch::InputConfig
245250
} else {
246251
FingerprintMismatch::SpawnFingerprint {
247-
old: old_cache_key.spawn_fingerprint,
252+
old: old_spawn_fingerprint,
248253
new: spawn_fingerprint.clone(),
249254
}
250255
};

0 commit comments

Comments
 (0)