Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion crates/compilers/src/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,24 @@ pub fn collect_ordered_deps<D: ParsedSource + MaybeSolData>(
paths_with_deps_count.push((path_deps.len(), path));
}

paths_with_deps_count.sort();
paths_with_deps_count.sort_by(|(count_0, path_0), (count_1, path_1)| {
// Compare dependency counts
match count_0.cmp(count_1) {
o if !o.is_eq() => return o,
_ => {}
};
Comment on lines +858 to +862
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this isn't quite the same as

if count_0 != count_1 {
  return 
}

because this handles all other variants


// Try comparing file names
if let Some((name_0, name_1)) = path_0.file_name().zip(path_1.file_name()) {
match name_0.cmp(name_1) {
o if !o.is_eq() => return o,
_ => {}
}
}

// If both filenames and dependecy counts are equal, fallback to comparing file paths
path_0.cmp(path_1)
});

let mut ordered_deps =
paths_with_deps_count.into_iter().map(|(_, path)| path).collect::<Vec<_>>();
Expand Down