File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
compiler/rustc_metadata/src Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -910,9 +910,15 @@ impl CrateError {
910910 "multiple matching crates for `{}`" ,
911911 crate_name
912912 ) ;
913+ let mut libraries: Vec < _ > = libraries. into_values ( ) . collect ( ) ;
914+ // Make ordering of candidates deterministic.
915+ // This has to `clone()` to work around lifetime restrictions with `sort_by_key()`.
916+ // `sort_by()` could be used instead, but this is in the error path,
917+ // so the performance shouldn't matter.
918+ libraries. sort_by_cached_key ( |lib| lib. source . paths ( ) . next ( ) . unwrap ( ) . clone ( ) ) ;
913919 let candidates = libraries
914920 . iter ( )
915- . filter_map ( |( _ , lib) | {
921+ . filter_map ( |lib| {
916922 let crate_name = & lib. metadata . get_root ( ) . name ( ) . as_str ( ) ;
917923 match ( & lib. source . dylib , & lib. source . rlib ) {
918924 ( Some ( ( pd, _) ) , Some ( ( pr, _) ) ) => Some ( format ! (
You can’t perform that action at this time.
0 commit comments