File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -854,7 +854,24 @@ pub fn collect_ordered_deps<D: ParsedSource + MaybeSolData>(
854854 paths_with_deps_count. push ( ( path_deps. len ( ) , path) ) ;
855855 }
856856
857- paths_with_deps_count. sort ( ) ;
857+ paths_with_deps_count. sort_by ( |( count_0, path_0) , ( count_1, path_1) | {
858+ // Compare dependency counts
859+ match count_0. cmp ( count_1) {
860+ o if !o. is_eq ( ) => return o,
861+ _ => { }
862+ } ;
863+
864+ // Try comparing file names
865+ if let Some ( ( name_0, name_1) ) = path_0. file_name ( ) . zip ( path_1. file_name ( ) ) {
866+ match name_0. cmp ( name_1) {
867+ o if !o. is_eq ( ) => return o,
868+ _ => { }
869+ }
870+ }
871+
872+ // If both filenames and dependecy counts are equal, fallback to comparing file paths
873+ path_0. cmp ( path_1)
874+ } ) ;
858875
859876 let mut ordered_deps =
860877 paths_with_deps_count. into_iter ( ) . map ( |( _, path) | path) . collect :: < Vec < _ > > ( ) ;
You can’t perform that action at this time.
0 commit comments