From 0a34cd477142c8ec1d46587bc36f00e9453f4d18 Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Sun, 27 Feb 2022 15:27:55 -0800 Subject: [PATCH] Don't fail for non-canonical paths in test inputs --- crates/flowistry/src/range.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/flowistry/src/range.rs b/crates/flowistry/src/range.rs index 9a4fa6570..00663f04f 100644 --- a/crates/flowistry/src/range.rs +++ b/crates/flowistry/src/range.rs @@ -150,14 +150,20 @@ impl Range { &self, files: &'a MappedReadGuard<'_, MonotonicVec>>, ) -> Result<&'a SourceFile> { - let filename = Path::new(&self.filename).canonicalize()?; + let filename = Path::new(&self.filename); + let filename = filename + .canonicalize() + .unwrap_or_else(|_| filename.to_path_buf()); + files .iter() .find(|file| match &file.name { // rustc seems to store relative paths to files in the workspace, so if filename is absolute, // we can compare them using Path::ends_with FileName::Real(RealFileName::LocalPath(other)) => { - filename.ends_with(other.canonicalize().unwrap()) + let canonical = other.canonicalize(); + let other = canonical.as_ref().unwrap_or(other); + filename.ends_with(other) } _ => false, })