Skip to content

Commit fee89d8

Browse files
wan9chiclaude
andcommitted
refactor(cache): convert PostRunMismatch via From instead of inline match
The cache-lookup path hand-rolled a 3-arm match to turn a `fingerprint::PostRunMismatch` into a `FingerprintMismatch` (identical variants/fields). Move it into `impl From<PostRunMismatch> for FingerprintMismatch` so the call site is just `mismatch.into()` and the mapping lives with the type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3f0420f commit fee89d8

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

  • crates/vite_task/src/session/cache

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ pub enum FingerprintMismatch {
171171
},
172172
}
173173

174+
impl From<crate::session::execute::fingerprint::PostRunMismatch> for FingerprintMismatch {
175+
fn from(mismatch: crate::session::execute::fingerprint::PostRunMismatch) -> Self {
176+
use crate::session::execute::fingerprint::PostRunMismatch;
177+
match mismatch {
178+
PostRunMismatch::InputChanged { kind, path } => Self::InputChanged { kind, path },
179+
PostRunMismatch::TrackedEnvChanged { name, old, new } => {
180+
Self::TrackedEnvChanged { name, old, new }
181+
}
182+
PostRunMismatch::TrackedEnvGlobChanged { pattern, diff } => {
183+
Self::TrackedEnvGlobChanged { pattern, diff }
184+
}
185+
}
186+
}
187+
}
188+
174189
impl Display for FingerprintMismatch {
175190
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
176191
match self {
@@ -315,22 +330,7 @@ impl ExecutionCache {
315330

316331
// Validate post-run fingerprint (inferred inputs + tracked envs)
317332
if let Some(mismatch) = cache_value.post_run_fingerprint.validate(workspace_root)? {
318-
let fingerprint_mismatch = match mismatch {
319-
crate::session::execute::fingerprint::PostRunMismatch::InputChanged {
320-
kind,
321-
path,
322-
} => FingerprintMismatch::InputChanged { kind, path },
323-
crate::session::execute::fingerprint::PostRunMismatch::TrackedEnvChanged {
324-
name,
325-
old,
326-
new,
327-
} => FingerprintMismatch::TrackedEnvChanged { name, old, new },
328-
crate::session::execute::fingerprint::PostRunMismatch::TrackedEnvGlobChanged {
329-
pattern,
330-
diff,
331-
} => FingerprintMismatch::TrackedEnvGlobChanged { pattern, diff },
332-
};
333-
return Ok(Err(CacheMiss::FingerprintMismatch(fingerprint_mismatch)));
333+
return Ok(Err(CacheMiss::FingerprintMismatch(mismatch.into())));
334334
}
335335
// Associate the execution key to the cache entry key if not already,
336336
// so that next time we can find it and report what changed

0 commit comments

Comments
 (0)