Fix error messages on Windows

This commit is contained in:
Laurenz 2022-06-14 18:18:18 +02:00
parent 20b990d297
commit 0dacb2d151
2 changed files with 7 additions and 4 deletions

View File

@ -121,10 +121,9 @@ impl Loader for FsLoader {
}
fn resolve(&self, path: &Path) -> io::Result<FileHash> {
let file = File::open(path)?;
let meta = file.metadata()?;
let meta = fs::metadata(path)?;
if meta.is_file() {
let handle = Handle::from_file(file)?;
let handle = Handle::from_path(path)?;
Ok(FileHash(fxhash::hash64(&handle)))
} else {
Err(io::ErrorKind::NotFound.into())

View File

@ -316,7 +316,11 @@ fn test_part(
let mut errors: Vec<_> = errors
.into_iter()
.filter(|error| error.span.source() == id)
.map(|error| (ctx.sources.range(error.span), error.message))
.map(|error| {
let range = ctx.sources.range(error.span);
let msg = error.message.replace("\\", "/");
(range, msg)
})
.collect();
errors.sort_by_key(|error| error.0.start);