diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-23 19:55:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-23 19:55:45 +0100 |
| commit | 2a39cf560f1e6d33a819a8d32827f03385996ace (patch) | |
| tree | 054b37ee0da10cebd62813cdb1db14ece7362a00 /compiler/rustc_session/src/utils.rs | |
| parent | fc5516b782e129c82de6df7ebaf2ce2bc9a3f44f (diff) | |
| parent | 4f7cd3d4591aefc4edec1039ac49bef94d65deb1 (diff) | |
| download | rust-2a39cf560f1e6d33a819a8d32827f03385996ace.tar.gz rust-2a39cf560f1e6d33a819a8d32827f03385996ace.zip | |
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.
Diffstat (limited to 'compiler/rustc_session/src/utils.rs')
| -rw-r--r-- | compiler/rustc_session/src/utils.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index 3b3d4ca5d6b..1d15e2c28d8 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -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 { |
