@@ -108,7 +108,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
108108use rustc_data_structures:: svh:: Svh ;
109109use rustc_data_structures:: { base_n, flock} ;
110110use rustc_errors:: ErrorGuaranteed ;
111- use rustc_fs_util:: { link_or_copy, LinkOrCopy } ;
111+ use rustc_fs_util:: { link_or_copy, try_canonicalize , LinkOrCopy } ;
112112use rustc_session:: { Session , StableCrateId } ;
113113use rustc_span:: Symbol ;
114114
@@ -223,7 +223,7 @@ pub fn prepare_session_directory(
223223 // because, on windows, long paths can cause problems;
224224 // canonicalization inserts this weird prefix that makes windows
225225 // tolerate long paths.
226- let crate_dir = match crate_dir . canonicalize ( ) {
226+ let crate_dir = match try_canonicalize ( & crate_dir ) {
227227 Ok ( v) => v,
228228 Err ( err) => {
229229 return Err ( sess. emit_err ( errors:: CanonicalizePath { path : crate_dir, err } ) ) ;
@@ -867,7 +867,7 @@ fn all_except_most_recent(
867867/// before passing it to std::fs::remove_dir_all(). This will convert the path
868868/// into the '\\?\' format, which supports much longer paths.
869869fn safe_remove_dir_all ( p : & Path ) -> io:: Result < ( ) > {
870- let canonicalized = match std_fs :: canonicalize ( p) {
870+ let canonicalized = match try_canonicalize ( p) {
871871 Ok ( canonicalized) => canonicalized,
872872 Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
873873 Err ( err) => return Err ( err) ,
@@ -877,7 +877,7 @@ fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
877877}
878878
879879fn safe_remove_file ( p : & Path ) -> io:: Result < ( ) > {
880- let canonicalized = match std_fs :: canonicalize ( p) {
880+ let canonicalized = match try_canonicalize ( p) {
881881 Ok ( canonicalized) => canonicalized,
882882 Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
883883 Err ( err) => return Err ( err) ,
0 commit comments