Skip to content

Commit

Permalink
Don't fail for non-canonical paths in test inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Feb 27, 2022
1 parent bb7b994 commit 0a34cd4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/flowistry/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,20 @@ impl Range {
&self,
files: &'a MappedReadGuard<'_, MonotonicVec<Lrc<SourceFile>>>,
) -> 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,
})
Expand Down

0 comments on commit 0a34cd4

Please sign in to comment.