This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
compiler/rustc_metadata/src Expand file tree Collapse file tree 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> {
427427
428428 let ( rlibs, rmetas, dylibs) =
429429 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 ( ) ;
436445 match kind {
437446 CrateFlavor :: Rlib => rlibs. insert ( path, search_path. kind ) ,
438447 CrateFlavor :: Rmeta => rmetas. insert ( path, search_path. kind ) ,
You can’t perform that action at this time.
0 commit comments