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:
commit
2a39cf560f
11 changed files with 31 additions and 14 deletions
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
bitflags = "1.2.1"
|
||||
tracing = "0.1"
|
||||
serde_json = "1.0.59"
|
||||
rustc_fs_util = { path = "../rustc_fs_util" }
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_feature = { path = "../rustc_feature" }
|
||||
|
|
|
@ -40,6 +40,7 @@ use crate::json::{Json, ToJson};
|
|||
use crate::spec::abi::{lookup as lookup_abi, Abi};
|
||||
use crate::spec::crt_objects::{CrtObjects, LinkSelfContainedDefault};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_fs_util::try_canonicalize;
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use serde_json::Value;
|
||||
|
@ -2949,7 +2950,7 @@ impl TargetTriple {
|
|||
|
||||
/// Creates a target triple from the passed target path.
|
||||
pub fn from_path(path: &Path) -> Result<Self, io::Error> {
|
||||
let canonicalized_path = path.canonicalize()?;
|
||||
let canonicalized_path = try_canonicalize(path)?;
|
||||
let contents = std::fs::read_to_string(&canonicalized_path).map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue