File tree 1 file changed +15
-6
lines changed
compiler/rustc_metadata/src
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -427,12 +427,21 @@ impl<'a> CrateLocator<'a> {
427
427
428
428
let ( rlibs, rmetas, dylibs) =
429
429
candidates. entry ( hash. to_string ( ) ) . or_default ( ) ;
430
- let path =
431
- try_canonicalize ( & spf. path ) . unwrap_or_else ( |_| spf. path . to_path_buf ( ) ) ;
432
- if seen_paths. contains ( & path) {
433
- continue ;
434
- } ;
435
- seen_paths. insert ( path. clone ( ) ) ;
430
+ {
431
+ // As a perforamnce optimisation we canonicalize the path and skip
432
+ // ones we've already seeen. This allows us to ignore crates
433
+ // we know are exactual equal to ones we've already found.
434
+ // Going to the same crate through different symlinks does not change the result.
435
+ let path = try_canonicalize ( & spf. path )
436
+ . unwrap_or_else ( |_| spf. path . to_path_buf ( ) ) ;
437
+ if seen_paths. contains ( & path) {
438
+ continue ;
439
+ } ;
440
+ seen_paths. insert ( path) ;
441
+ }
442
+ // Use the original path (potentially with unresolved symlinks),
443
+ // filesystem code should not care, but this is nicer for diagnostics.
444
+ let path = spf. path . to_path_buf ( ) ;
436
445
match kind {
437
446
CrateFlavor :: Rlib => rlibs. insert ( path, search_path. kind ) ,
438
447
CrateFlavor :: Rmeta => rmetas. insert ( path, search_path. kind ) ,
You can’t perform that action at this time.
0 commit comments