Do a stable sort when splitting up impls by interface (#5423)

Keep the impls for each interface in the order that they were declared.
This ensures that the resulting diagnostics will be deterministic.
This commit is contained in:
Dana Jansens
2025-05-05 20:51:27 +00:00
committed by GitHub
parent f9e7564d37
commit 08065ee764
+1 -1
View File
@@ -575,7 +575,7 @@ auto CheckUnit::CheckOverlappingImpls() -> void {
// interface. We only need to compare impls within each such segment.
llvm::SmallVector<SemIR::Impl> impls_by_interface(
context_.impls().array_ref());
llvm::sort(
llvm::stable_sort(
impls_by_interface, [](const SemIR::Impl& a, const SemIR::Impl& b) {
return a.interface.interface_id.index < b.interface.interface_id.index;
});