From 08065ee76452ccd9ed5cf14bbe4d4a699ed2c907 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 5 May 2025 16:51:27 -0400 Subject: [PATCH] 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. --- toolchain/check/check_unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/check/check_unit.cpp b/toolchain/check/check_unit.cpp index d515a17ec326..f3cc33bb881f 100644 --- a/toolchain/check/check_unit.cpp +++ b/toolchain/check/check_unit.cpp @@ -575,7 +575,7 @@ auto CheckUnit::CheckOverlappingImpls() -> void { // interface. We only need to compare impls within each such segment. llvm::SmallVector 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; });