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 {}