From 2e59fe654d1989f484887c03a8cdb5e8d0e771f6 Mon Sep 17 00:00:00 2001 From: Wenzhuo Liu Date: Sat, 28 Oct 2023 12:09:48 +0800 Subject: [PATCH] fix vfs panic when file not found (#380) --- compiler/src/vfs/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/src/vfs/mod.rs b/compiler/src/vfs/mod.rs index 88a8045c..83dd5f06 100644 --- a/compiler/src/vfs/mod.rs +++ b/compiler/src/vfs/mod.rs @@ -182,11 +182,15 @@ impl Vfs { f: &mut dyn FnMut(&'a ImmutPath, instant::SystemTime), ) { for slot in self.slots.iter() { - let dep_path = slot.sampled_path.get().unwrap(); - let dep_mtime = slot + let Some(dep_path) = slot.sampled_path.get() else { + continue; + }; + let Ok(dep_mtime) = slot .mtime .compute(|| Err(other_reason("vfs: uninitialized"))) - .unwrap(); + else { + continue; + }; f(dep_path, *dep_mtime) }