@@ -224,6 +224,7 @@ use rustc_middle::middle::cstore::{CrateSource, MetadataLoader};
224
224
use rustc_session:: config:: { self , CrateType } ;
225
225
use rustc_session:: filesearch:: { FileDoesntMatch , FileMatches , FileSearch } ;
226
226
use rustc_session:: search_paths:: PathKind ;
227
+ use rustc_session:: utils:: CanonicalizedPath ;
227
228
use rustc_session:: { CrateDisambiguator , Session } ;
228
229
use rustc_span:: symbol:: { sym, Symbol } ;
229
230
use rustc_span:: Span ;
@@ -244,7 +245,7 @@ crate struct CrateLocator<'a> {
244
245
245
246
// Immutable per-search configuration.
246
247
crate_name : Symbol ,
247
- exact_paths : Vec < PathBuf > ,
248
+ exact_paths : Vec < CanonicalizedPath > ,
248
249
pub hash : Option < Svh > ,
249
250
pub host_hash : Option < Svh > ,
250
251
extra_filename : Option < & ' a str > ,
@@ -315,7 +316,7 @@ impl<'a> CrateLocator<'a> {
315
316
. into_iter ( )
316
317
. filter_map ( |entry| entry. files ( ) )
317
318
. flatten ( )
318
- . map ( PathBuf :: from )
319
+ . cloned ( )
319
320
. collect ( )
320
321
} else {
321
322
// SVH being specified means this is a transitive dependency,
@@ -664,13 +665,19 @@ impl<'a> CrateLocator<'a> {
664
665
let mut rmetas = FxHashMap :: default ( ) ;
665
666
let mut dylibs = FxHashMap :: default ( ) ;
666
667
for loc in & self . exact_paths {
667
- if !loc. exists ( ) {
668
- return Err ( CrateError :: ExternLocationNotExist ( self . crate_name , loc. clone ( ) ) ) ;
668
+ if !loc. canonicalized ( ) . exists ( ) {
669
+ return Err ( CrateError :: ExternLocationNotExist (
670
+ self . crate_name ,
671
+ loc. original ( ) . clone ( ) ,
672
+ ) ) ;
669
673
}
670
- let file = match loc. file_name ( ) . and_then ( |s| s. to_str ( ) ) {
674
+ let file = match loc. original ( ) . file_name ( ) . and_then ( |s| s. to_str ( ) ) {
671
675
Some ( file) => file,
672
676
None => {
673
- return Err ( CrateError :: ExternLocationNotFile ( self . crate_name , loc. clone ( ) ) ) ;
677
+ return Err ( CrateError :: ExternLocationNotFile (
678
+ self . crate_name ,
679
+ loc. original ( ) . clone ( ) ,
680
+ ) ) ;
674
681
}
675
682
} ;
676
683
@@ -685,7 +692,8 @@ impl<'a> CrateLocator<'a> {
685
692
// e.g. symbolic links. If we canonicalize too early, we resolve
686
693
// the symlink, the file type is lost and we might treat rlibs and
687
694
// rmetas as dylibs.
688
- let loc_canon = fs:: canonicalize ( & loc) . unwrap_or_else ( |_| loc. clone ( ) ) ;
695
+ let loc_canon = loc. canonicalized ( ) . clone ( ) ;
696
+ let loc = loc. original ( ) ;
689
697
if loc. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . ends_with ( ".rlib" ) {
690
698
rlibs. insert ( loc_canon, PathKind :: ExternFlag ) ;
691
699
} else if loc. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . ends_with ( ".rmeta" ) {
@@ -695,7 +703,7 @@ impl<'a> CrateLocator<'a> {
695
703
}
696
704
} else {
697
705
self . rejected_via_filename
698
- . push ( CrateMismatch { path : loc. clone ( ) , got : String :: new ( ) } ) ;
706
+ . push ( CrateMismatch { path : loc. original ( ) . clone ( ) , got : String :: new ( ) } ) ;
699
707
}
700
708
}
701
709
0 commit comments