File tree 1 file changed +7
-1
lines changed
compiler/rustc_metadata/src
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -910,9 +910,15 @@ impl CrateError {
910
910
"multiple matching crates for `{}`" ,
911
911
crate_name
912
912
) ;
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 ( ) ) ;
913
919
let candidates = libraries
914
920
. iter ( )
915
- . filter_map ( |( _ , lib) | {
921
+ . filter_map ( |lib| {
916
922
let crate_name = & lib. metadata . get_root ( ) . name ( ) . as_str ( ) ;
917
923
match ( & lib. source . dylib , & lib. source . rlib ) {
918
924
( Some ( ( pd, _) ) , Some ( ( pr, _) ) ) => Some ( format ! (
You can’t perform that action at this time.
0 commit comments