Rollup merge of #109231 - Zoxc:fs-non-canon, r=eholk
Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize` This adds `try_canonicalize` which tries to call `fs::canonicalize`, but falls back to `std::path::absolute` if it fails. Existing `canonicalize` calls are replaced with it. `fs::canonicalize` is not guaranteed to work on Windows.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::session::Session;
|
||||
use rustc_data_structures::profiling::VerboseTimingGuard;
|
||||
use rustc_fs_util::try_canonicalize;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
impl Session {
|
||||
@@ -98,7 +99,7 @@ pub struct CanonicalizedPath {
|
||||
|
||||
impl CanonicalizedPath {
|
||||
pub fn new(path: &Path) -> Self {
|
||||
Self { original: path.to_owned(), canonicalized: std::fs::canonicalize(path).ok() }
|
||||
Self { original: path.to_owned(), canonicalized: try_canonicalize(path).ok() }
|
||||
}
|
||||
|
||||
pub fn canonicalized(&self) -> &PathBuf {
|
||||
|
||||
Reference in New Issue
Block a user