From ccd64a600b10200fe923f5805751f73cb1fc50ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Jun 2026 14:07:52 +0000 Subject: [PATCH 1/2] Initial plan From 060c6abd471bc78abae0abe5438c007a40219dc8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Jun 2026 14:10:44 +0000 Subject: [PATCH 2/2] fix ord comparator second branch self argument --- cpp2rust/converter/converter.cpp | 2 +- tests/unit/out/unsafe/operator_less_than.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index c60e9527..dc51cc68 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -3678,7 +3678,7 @@ void Converter::ConvertOrdAndPartialOrdTraits(const clang::CXXRecordDecl *decl, case clang::OO_Less: if (clang::isa(op)) { first_branch = std::format("self.{}(other)", GetOverloadedOperator(op)); - second_branch = std::format("other.{}(other)", GetOverloadedOperator(op)); + second_branch = std::format("other.{}(self)", GetOverloadedOperator(op)); } else { first_branch = std::format("{}(self, other)", GetOverloadedOperator(op)); second_branch = std::format("{}(other, self)", GetOverloadedOperator(op)); diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index d9a3d838..ff4db55f 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -23,7 +23,7 @@ impl Ord for Pair { unsafe { if self.lt(other) { std::cmp::Ordering::Less - } else if other.lt(other) { + } else if other.lt(self) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -38,7 +38,7 @@ impl PartialOrd for Pair { } impl PartialEq for Pair { fn eq(&self, other: &Self) -> bool { - unsafe { !(self.lt(other)) && !(other.lt(other)) } + unsafe { !(self.lt(other)) && !(other.lt(self)) } } } impl Eq for Pair {}