From 57fa172acfc3e13fe6fa27d039a72b25c433dc6e Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:59:28 +0000 Subject: [PATCH 01/17] Update tests --- .../out/refcount/class.spaceship.rs | 30 +----- .../out/unsafe/class.spaceship.rs | 28 +----- .../out/refcount/concept.totallyordered.rs | 24 ++--- .../out/unsafe/concept.totallyordered.rs | 17 +--- .../out/refcount/utility.arg.requirements.rs | 14 +-- .../out/unsafe/utility.arg.requirements.rs | 13 +-- .../support/cmp/out/refcount/cmp.concept.rs | 27 +----- .../std/support/cmp/out/unsafe/cmp.concept.rs | 26 +---- .../refcount/operator_comparison_defaulted.rs | 40 ++------ .../out/refcount/operator_comparison_free.rs | 27 ++---- .../refcount/operator_comparison_nonbool.rs | 97 ++++--------------- tests/unit/out/refcount/operator_friend.rs | 6 +- tests/unit/out/refcount/operator_less_than.rs | 5 - tests/unit/out/refcount/operator_three_way.rs | 6 +- tests/unit/out/refcount/operator_traits.rs | 6 +- .../unsafe/operator_comparison_defaulted.rs | 36 ++----- .../out/unsafe/operator_comparison_free.rs | 27 ++---- .../out/unsafe/operator_comparison_nonbool.rs | 97 ++++--------------- tests/unit/out/unsafe/operator_friend.rs | 6 +- tests/unit/out/unsafe/operator_less_than.rs | 5 - tests/unit/out/unsafe/operator_three_way.rs | 6 +- tests/unit/out/unsafe/operator_traits.rs | 6 +- 22 files changed, 98 insertions(+), 451 deletions(-) diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 222558373f..8d14e1f93a 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -17,6 +17,7 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -67,11 +68,6 @@ impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for p1_memberwise_in_declaration_order_Date { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} pub fn test_0() { let earlier: Value = Rc::new(RefCell::new(p1_memberwise_in_declaration_order_Date { @@ -128,6 +124,7 @@ pub fn test_0() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -174,11 +171,6 @@ impl ThreeWayComparable for p2_common_comparison_category_Reading { ); } } -impl LessThanComparable for p2_common_comparison_category_Reading { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} pub fn test_1() { let low: Value = Rc::new(RefCell::new(p2_common_comparison_category_Reading { @@ -218,6 +210,7 @@ pub fn test_1() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] @@ -241,14 +234,6 @@ impl weak_ordering_from_user_operator_Fraction { ))); } } -impl LessThanComparable for weak_ordering_from_user_operator_Fraction { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(weak_ordering_from_user_operator_Fraction::operator_cmp( - this.clone(), - other.clone(), - )) - } -} pub fn test_2() { let half: Value = Rc::new(RefCell::new(weak_ordering_from_user_operator_Fraction { @@ -343,6 +328,7 @@ pub fn test_2() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] @@ -374,14 +360,6 @@ impl partial_ordering_from_user_operator_Interval { return (*libcc2rs::partial_ordering_unordered().upgrade().deref()); } } -impl LessThanComparable for partial_ordering_from_user_operator_Interval { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(partial_ordering_from_user_operator_Interval::operator_cmp( - this.clone(), - other.clone(), - )) - } -} pub fn test_3() { let early: Value = Rc::new(RefCell::new(partial_ordering_from_user_operator_Interval { diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 38362beb7f..9eeab57e06 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -16,6 +16,7 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -57,11 +58,6 @@ impl ThreeWayComparableUnsafe for p1_memberwise_in_declaration_order_Date { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} pub unsafe fn test_0() { let mut earlier: p1_memberwise_in_declaration_order_Date = p1_memberwise_in_declaration_order_Date { @@ -128,6 +124,7 @@ pub unsafe fn test_0() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -163,11 +160,6 @@ impl ThreeWayComparableUnsafe for p2_common_comparison_category_Reading { return libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_EQUAL); } } -impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} pub unsafe fn test_1() { let mut low: p2_common_comparison_category_Reading = p2_common_comparison_category_Reading { sensor: 1, @@ -206,6 +198,7 @@ pub unsafe fn test_1() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] @@ -226,13 +219,6 @@ impl weak_ordering_from_user_operator_Fraction { ))); } } -impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(weak_ordering_from_user_operator_Fraction::operator_cmp( - this, other, - )) - } -} pub unsafe fn test_2() { let mut half: weak_ordering_from_user_operator_Fraction = weak_ordering_from_user_operator_Fraction { @@ -316,6 +302,7 @@ pub unsafe fn test_2() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] @@ -342,13 +329,6 @@ impl partial_ordering_from_user_operator_Interval { return libcc2rs::PARTIAL_ORDERING_UNORDERED; } } -impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(partial_ordering_from_user_operator_Interval::operator_cmp( - this, other, - )) - } -} pub unsafe fn test_3() { let mut early: partial_ordering_from_user_operator_Interval = partial_ordering_from_user_operator_Interval { low: 1, high: 3 }; diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index ac877077aa..9321a13393 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -69,6 +69,7 @@ pub fn test_3() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -91,11 +92,6 @@ impl ThreeWayComparable for p1_relations_from_three_way_Level { )); } } -impl LessThanComparable for p1_relations_from_three_way_Level { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), other.clone())) - } -} pub fn test_4() { let shallow: Value = Rc::new(RefCell::new(p1_relations_from_three_way_Level { depth: 1 })); @@ -136,8 +132,10 @@ thread_local!( TriviallyDefaultConstructible, TriviallyCopyable, Default, - Conversions, + LessThanComparable, )] +#[three_way(p1_operator_preferred_over_three_way_Level::operator_cmp)] +#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct p1_operator_preferred_over_three_way_Level { @@ -155,14 +153,6 @@ impl p1_operator_preferred_over_three_way_Level { )); } } -impl LessThanComparable for p1_operator_preferred_over_three_way_Level { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(p1_operator_preferred_over_three_way_Level::operator_cmp( - this.clone(), - other.clone(), - )) - } -} pub fn test_6() { let shallow: Value = Rc::new(RefCell::new(p1_operator_preferred_over_three_way_Level { @@ -229,14 +219,12 @@ impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { } fn less_equal(lhs: Ptr, rhs: Ptr) -> bool { libcc2rs::is_lteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs.clone(), - rhs.clone(), + lhs, rhs, )) } fn greater_equal(lhs: Ptr, rhs: Ptr) -> bool { libcc2rs::is_gteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs.clone(), - rhs.clone(), + lhs, rhs, )) } } diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index 4afcb87738..01557f4739 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -63,6 +63,7 @@ pub unsafe fn test_3() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -83,11 +84,6 @@ impl ThreeWayComparableUnsafe for p1_relations_from_three_way_Level { )); } } -impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, other)) - } -} pub unsafe fn test_4() { let mut shallow: p1_relations_from_three_way_Level = p1_relations_from_three_way_Level { depth: 1 }; @@ -129,8 +125,10 @@ pub static mut greater_calls_5: std::cell::LazyCell = TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - ConversionsUnsafe, + LessThanComparableUnsafe, )] +#[three_way(p1_operator_preferred_over_three_way_Level::operator_cmp)] +#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_operator_preferred_over_three_way_Level { pub depth: i32, @@ -146,13 +144,6 @@ impl p1_operator_preferred_over_three_way_Level { )); } } -impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(p1_operator_preferred_over_three_way_Level::operator_cmp( - this, other, - )) - } -} pub unsafe fn test_6() { let mut shallow: p1_operator_preferred_over_three_way_Level = p1_operator_preferred_over_three_way_Level { depth: 1 }; diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index b59ba33b07..0cf9911565 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -194,11 +194,6 @@ impl table29_other_operator_shapes_Weight { return (this.with(|__s| __s.grams) < other.grams); } } -impl LessThanComparable for table29_other_operator_shapes_Weight { - fn less(this: Ptr, other: Ptr) -> bool { - table29_other_operator_shapes_Weight::operator_lt(this.clone(), other.read()) - } -} #[derive( Copy, Clone, @@ -237,6 +232,7 @@ impl LessThanComparable for table29_other_operator_shapes_Height { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(table29_other_operator_shapes_Depth::operator_cmp)] @@ -258,14 +254,6 @@ impl table29_other_operator_shapes_Depth { )); } } -impl LessThanComparable for table29_other_operator_shapes_Depth { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(table29_other_operator_shapes_Depth::operator_cmp( - this.clone(), - other.clone(), - )) - } -} pub fn test_2() { assert!( ({ diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index e20798e882..fbfd021336 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -153,11 +153,6 @@ impl table29_other_operator_shapes_Weight { return (((*this).grams) < (other.grams)); } } -impl LessThanComparableUnsafe for table29_other_operator_shapes_Weight { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - table29_other_operator_shapes_Weight::operator_lt(this, (*other).clone()) - } -} #[repr(C)] #[derive( Copy, @@ -192,6 +187,7 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(table29_other_operator_shapes_Depth::operator_cmp)] @@ -211,13 +207,6 @@ impl table29_other_operator_shapes_Depth { )); } } -impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(table29_other_operator_shapes_Depth::operator_cmp( - this, other, - )) - } -} pub unsafe fn test_2() { assert!( (({ diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index c974b14ce7..c9a75b3c89 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -17,6 +17,7 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -56,11 +57,6 @@ impl ThreeWayComparable for p1_defaulted_three_way_Version { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for p1_defaulted_three_way_Version { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( true, @@ -113,6 +109,7 @@ thread_local!( TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -136,11 +133,6 @@ impl ThreeWayComparable for p1_user_written_three_way_Money { )); } } -impl LessThanComparable for p1_user_written_three_way_Money { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), other.clone())) - } -} const _: () = assert!(true, "std::three_way_comparable"); pub fn test_2() { let small: Value = @@ -177,6 +169,7 @@ pub fn test_2() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -199,11 +192,6 @@ impl ThreeWayComparable for p1_weaker_category_Temperature { )); } } -impl LessThanComparable for p1_weaker_category_Temperature { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), other.clone())) - } -} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( !(false), @@ -240,6 +228,7 @@ pub fn test_3() { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(p1_three_way_without_equality_Rank::operator_cmp)] @@ -261,14 +250,6 @@ impl p1_three_way_without_equality_Rank { )); } } -impl LessThanComparable for p1_three_way_without_equality_Rank { - fn less(this: Ptr, other: Ptr) -> bool { - libcc2rs::is_lt(p1_three_way_without_equality_Rank::operator_cmp( - this.clone(), - other.clone(), - )) - } -} const _: () = assert!(!(false), "!std::three_way_comparable"); pub fn test_4() { let low: Value = diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index 126c5aa0a9..3efb3e9381 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -16,6 +16,7 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -50,11 +51,6 @@ impl ThreeWayComparableUnsafe for p1_defaulted_three_way_Version { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( true, @@ -102,6 +98,7 @@ pub static mut three_way_calls_1: std::cell::LazyCell = TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -123,11 +120,6 @@ impl ThreeWayComparableUnsafe for p1_user_written_three_way_Money { )); } } -impl LessThanComparableUnsafe for p1_user_written_three_way_Money { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, other)) - } -} const _: () = assert!(true, "std::three_way_comparable"); pub unsafe fn test_2() { let mut small: p1_user_written_three_way_Money = p1_user_written_three_way_Money { cents: 150 }; @@ -169,6 +161,7 @@ pub unsafe fn test_2() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -189,11 +182,6 @@ impl ThreeWayComparableUnsafe for p1_weaker_category_Temperature { )); } } -impl LessThanComparableUnsafe for p1_weaker_category_Temperature { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, other)) - } -} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( !(false), @@ -224,6 +212,7 @@ pub unsafe fn test_3() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(p1_three_way_without_equality_Rank::operator_cmp)] @@ -243,13 +232,6 @@ impl p1_three_way_without_equality_Rank { )); } } -impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - libcc2rs::is_lt(p1_three_way_without_equality_Rank::operator_cmp( - this, other, - )) - } -} const _: () = assert!(!(false), "!std::three_way_comparable"); pub unsafe fn test_4() { let mut low: p1_three_way_without_equality_Rank = diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 5a2c77a088..e954888897 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -38,6 +38,7 @@ pub struct Eq { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -74,11 +75,6 @@ impl ThreeWayComparable for Cmp { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for Cmp { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} #[derive( Copy, Clone, @@ -90,6 +86,7 @@ impl LessThanComparable for Cmp { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -115,11 +112,6 @@ impl ThreeWayComparable for Both { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for Both { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} #[derive( Copy, Clone, @@ -131,6 +123,7 @@ impl LessThanComparable for Both { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(OrdOnly::operator_cmp)] @@ -155,11 +148,6 @@ impl OrdOnly { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for OrdOnly { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(OrdOnly::operator_cmp(this.clone(), _a0.clone())) - } -} #[derive( Copy, Clone, @@ -171,6 +159,7 @@ impl LessThanComparable for OrdOnly { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -196,11 +185,6 @@ impl ThreeWayComparable for Inner { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for Inner { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} #[derive( Copy, Clone, @@ -212,6 +196,7 @@ impl LessThanComparable for Inner { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -248,11 +233,6 @@ impl ThreeWayComparable for Outer { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for Outer { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} #[derive( Copy, Clone, @@ -302,6 +282,7 @@ impl LessThanComparable for Secondary { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -330,11 +311,6 @@ impl ThreeWayComparable for PtrMember { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for PtrMember { - fn less(this: Ptr, _a0: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), _a0.clone())) - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -455,10 +431,10 @@ impl PartiallyOrderedWith for Secondary { ::less(lhs, rhs) } fn greater(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_gt(ThreeWayComparable::three_way(lhs.clone(), rhs.clone())) + libcc2rs::is_gt(ThreeWayComparable::three_way(lhs, rhs)) } fn less_equal(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_lteq(ThreeWayComparable::three_way(lhs.clone(), rhs.clone())) + libcc2rs::is_lteq(ThreeWayComparable::three_way(lhs, rhs)) } } impl WeaklyEqualityComparableWith for Both { diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 8601f21645..33a83e3d88 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -55,18 +55,13 @@ pub struct V { #[offset(0)] pub v: i32, } -impl LessThanComparable for V { - fn less(a: Ptr, b: Ptr) -> bool { - operator_lt_3(a.read(), b.read()) - } -} -pub fn operator_eq_4(mut a: V, mut b: V) -> bool { +pub fn operator_eq_2(mut a: V, mut b: V) -> bool { return (a.v == b.v); } -pub fn operator_ne_2(mut a: V, mut b: V) -> bool { +pub fn operator_ne_3(mut a: V, mut b: V) -> bool { return (a.v != b.v); } -pub fn operator_lt_3(mut a: V, mut b: V) -> bool { +pub fn operator_lt_4(mut a: V, mut b: V) -> bool { return (a.v < b.v); } pub fn operator_gt_5(mut a: V, mut b: V) -> bool { @@ -80,11 +75,11 @@ fn main_0() -> i32 { let mut x: V = V { v: 1 }; let mut y: V = V { v: 2 }; let mut z: V = V { v: 1 }; - assert!(({ operator_eq_4(x, z,) })); - assert!(({ operator_ne_2(x, y,) })); - assert!(({ operator_lt_3(x, y,) })); + assert!(({ operator_eq_2(x, z,) })); + assert!(({ operator_ne_3(x, y,) })); + assert!(({ operator_lt_4(x, y,) })); assert!(({ operator_gt_5(y, x,) })); - assert!(!({ operator_lt_3(y, x,) })); + assert!(!({ operator_lt_4(y, x,) })); let a: Value = Rc::new(RefCell::new(S { v: 1 })); let b: Value = Rc::new(RefCell::new(S { v: 2 })); let c: Value = Rc::new(RefCell::new(S { v: 1 })); @@ -121,12 +116,4 @@ impl WeaklyEqualityComparableWith for S { return ({ a.with(|__s| __s.v) } != { b.with(|__s| __s.v) }); } } -impl WeaklyEqualityComparableWith for V { - fn not_equal(a: Ptr, b: Ptr) -> bool { - operator_ne_2(a.read(), b.read()) - } - fn equal(a: Ptr, b: Ptr) -> bool { - operator_eq_4(a.read(), b.read()) - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index fe5d82ba36..c6d3748252 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -25,27 +25,22 @@ pub struct X { #[offset(0)] pub v: i32, } -impl LessThanComparable for X { - fn less(a: Ptr, b: Ptr) -> bool { - ((operator_lt_4(a.read(), b.read())) != 0) - } -} -pub fn operator_eq_5(mut a: X, mut b: X) -> i32 { +pub fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if (a.v == b.v) { 2 } else { 0 }; } -pub fn operator_ne_0(mut a: X, mut b: X) -> i32 { +pub fn operator_ne_1(mut a: X, mut b: X) -> i32 { return if (a.v != b.v) { 3 } else { 0 }; } -pub fn operator_lt_4(mut a: X, mut b: X) -> i32 { +pub fn operator_lt_2(mut a: X, mut b: X) -> i32 { return if (a.v < b.v) { 4 } else { 0 }; } -pub fn operator_gt_1(mut a: X, mut b: X) -> i32 { +pub fn operator_gt_3(mut a: X, mut b: X) -> i32 { return if (a.v > b.v) { 5 } else { 0 }; } -pub fn operator_le_2(mut a: X, mut b: X) -> i32 { +pub fn operator_le_4(mut a: X, mut b: X) -> i32 { return if (a.v <= b.v) { 6 } else { 0 }; } -pub fn operator_ge_3(mut a: X, mut b: X) -> i32 { +pub fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if (a.v >= b.v) { 7 } else { 0 }; } #[derive( @@ -133,11 +128,6 @@ impl Mixed { }; } } -impl LessThanComparable for Mixed { - fn less(this: Ptr, o: Ptr) -> bool { - ((Mixed::operator_lt(this.clone(), o.clone())) != 0) - } -} #[derive( Copy, Clone, @@ -186,22 +176,14 @@ pub struct Boolish { #[offset(0)] pub v: i32, } -impl LessThanComparable for Boolish { - fn less(a: Ptr, b: Ptr) -> bool { - { - let __cmp = operator_lt_6(a.read(), b.read()); - MyBool::to_bool(Rc::new(RefCell::new(__cmp)).as_pointer()) - } - } -} -pub fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v == b.v)); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } -pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { +pub fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v < b.v)); @@ -274,13 +256,13 @@ fn main_0() -> i32 { let mut a: X = X { v: 1 }; let mut b: X = X { v: 2 }; let mut c: X = X { v: 1 }; - assert!((({ operator_eq_5(a, c,) }) == 2)); - assert!((({ operator_eq_5(a, b,) }) == 0)); - assert!((({ operator_ne_0(a, b,) }) == 3)); - assert!((({ operator_lt_4(a, b,) }) == 4)); - assert!((({ operator_gt_1(b, a,) }) == 5)); - assert!((({ operator_le_2(a, c,) }) == 6)); - assert!((({ operator_ge_3(a, c,) }) == 7)); + assert!((({ operator_eq_0(a, c,) }) == 2)); + assert!((({ operator_eq_0(a, b,) }) == 0)); + assert!((({ operator_ne_1(a, b,) }) == 3)); + assert!((({ operator_lt_2(a, b,) }) == 4)); + assert!((({ operator_gt_3(b, a,) }) == 5)); + assert!((({ operator_le_4(a, c,) }) == 6)); + assert!((({ operator_ge_5(a, c,) }) == 7)); let xs: Value> = Rc::new(RefCell::new(Box::new([X { v: 3 }, X { v: 1 }, X { v: 2 }]))); { let mut __tmp_0 = { xs.decay() }; @@ -323,14 +305,14 @@ fn main_0() -> i32 { assert!( ({ MyBool::to_bool( - Rc::new(RefCell::new(({ operator_eq_7(b1, Boolish { v: 1 }) }))).as_pointer(), + Rc::new(RefCell::new(({ operator_eq_6(b1, Boolish { v: 1 }) }))).as_pointer(), ) }) ); assert!( - !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_6(b2, b1,) }))).as_pointer(),) }) + !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_7(b2, b1,) }))).as_pointer(),) }) ); - let mut lt: MyBool = ({ operator_lt_6(b1, b2) }); + let mut lt: MyBool = ({ operator_lt_7(b1, b2) }); assert!(lt.value); let bs: Value> = Rc::new(RefCell::new(Box::new([ Boolish { v: 3 }, @@ -373,49 +355,6 @@ fn main_0() -> i32 { ); return 0; } -impl PartiallyOrderedWith for X { - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } - fn greater(lhs: Ptr, rhs: Ptr) -> bool { - ((operator_gt_1(lhs.read(), rhs.read())) != 0) - } - fn less_equal(lhs: Ptr, rhs: Ptr) -> bool { - ((operator_le_2(lhs.read(), rhs.read())) != 0) - } - fn greater_equal(lhs: Ptr, rhs: Ptr) -> bool { - ((operator_ge_3(lhs.read(), rhs.read())) != 0) - } -} -impl WeaklyEqualityComparableWith for Boolish { - fn equal(a: Ptr, b: Ptr) -> bool { - { - let __cmp = operator_eq_7(a.read(), b.read()); - MyBool::to_bool(Rc::new(RefCell::new(__cmp)).as_pointer()) - } - } -} -impl WeaklyEqualityComparableWith for Mixed { - fn equal(this: Ptr, o: Ptr) -> bool { - ((Mixed::operator_eq(this.clone(), o.clone())) != 0) - } -} -impl WeaklyEqualityComparableWith for RefInt { - fn equal(this: Ptr, _a0: Ptr) -> bool { - { - let __cmp = RefInt::operator_eq(this.clone(), _a0.clone()); - RefBool::to_bool(__cmp.clone()) - } - } -} -impl WeaklyEqualityComparableWith for X { - fn not_equal(a: Ptr, b: Ptr) -> bool { - ((operator_ne_0(a.read(), b.read())) != 0) - } - fn equal(a: Ptr, b: Ptr) -> bool { - ((operator_eq_5(a.read(), b.read())) != 0) - } -} pub fn __cpp2rust_init_globals() { let _ = ref_true_8.with(|_| ()); } diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 73a37d4914..161dd73e09 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -53,6 +53,7 @@ impl ThreeWayComparable for DefaultedOrd { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -63,11 +64,6 @@ pub struct DefaultedOrd { #[offset(0)] pub a: i32, } -impl LessThanComparable for DefaultedOrd { - fn less(_a0: Ptr, _a1: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(_a0, _a1.clone())) - } -} impl LessThanComparable for Inline { fn less(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.a) } < { y.with(|__s| __s.a) }); diff --git a/tests/unit/out/refcount/operator_less_than.rs b/tests/unit/out/refcount/operator_less_than.rs index 92681a1bd6..353661b487 100644 --- a/tests/unit/out/refcount/operator_less_than.rs +++ b/tests/unit/out/refcount/operator_less_than.rs @@ -34,11 +34,6 @@ impl Pair { && ({ this.with(|__s| __s.y) } < { other.with(|__s| __s.y) })); } } -impl LessThanComparable for Pair { - fn less(this: Ptr, other: Ptr) -> bool { - Pair::operator_lt(this.clone(), other.clone()) - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 3174e5eb07..e6a1160505 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -17,6 +17,7 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -39,11 +40,6 @@ impl ThreeWayComparable for S { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } -impl LessThanComparable for S { - fn less(this: Ptr, o: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), o.clone())) - } -} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 1d662beb1d..d826279b55 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -60,6 +60,7 @@ pub struct Eq { TriviallyDefaultConstructible, TriviallyCopyable, Default, + LessThanComparable, PartiallyOrderedWith, )] #[three_way(ThreeWayComparable::three_way)] @@ -79,11 +80,6 @@ impl ThreeWayComparable for Cmp { )); } } -impl LessThanComparable for Cmp { - fn less(this: Ptr, o: Ptr) -> bool { - libcc2rs::is_lt(ThreeWayComparable::three_way(this.clone(), o.clone())) - } -} #[derive( Copy, Clone, diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index 94ba85e9ea..960e505af4 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -33,6 +33,7 @@ pub struct Eq { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -62,11 +63,6 @@ impl ThreeWayComparableUnsafe for Cmp { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for Cmp { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} #[repr(C)] #[derive( Copy, @@ -77,6 +73,7 @@ impl LessThanComparableUnsafe for Cmp { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -98,11 +95,6 @@ impl ThreeWayComparableUnsafe for Both { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for Both { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} #[repr(C)] #[derive( Copy, @@ -113,6 +105,7 @@ impl LessThanComparableUnsafe for Both { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(OrdOnly::operator_cmp)] @@ -133,11 +126,6 @@ impl OrdOnly { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for OrdOnly { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(OrdOnly::operator_cmp(this, _a0)) - } -} #[repr(C)] #[derive( Copy, @@ -148,6 +136,7 @@ impl LessThanComparableUnsafe for OrdOnly { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -169,11 +158,6 @@ impl ThreeWayComparableUnsafe for Inner { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for Inner { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} #[repr(C)] #[derive( Copy, @@ -184,6 +168,7 @@ impl LessThanComparableUnsafe for Inner { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -215,11 +200,6 @@ impl ThreeWayComparableUnsafe for Outer { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for Outer { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} #[repr(C)] #[derive( Copy, @@ -266,6 +246,7 @@ impl LessThanComparableUnsafe for Secondary { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -287,11 +268,6 @@ impl ThreeWayComparableUnsafe for PtrMember { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for PtrMember { - unsafe fn less(this: *const Self, _a0: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, _a0)) - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 3f29909619..d7e4e1e2f9 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -49,18 +49,13 @@ pub unsafe fn operator_lt_1(mut a: i32, b: *const S) -> bool { pub struct V { pub v: i32, } -impl LessThanComparableUnsafe for V { - unsafe fn less(a: *const Self, b: *const Self) -> bool { - operator_lt_3((*a).clone(), (*b).clone()) - } -} -pub unsafe fn operator_eq_4(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_eq_2(mut a: V, mut b: V) -> bool { return ((a.v) == (b.v)); } -pub unsafe fn operator_ne_2(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_ne_3(mut a: V, mut b: V) -> bool { return ((a.v) != (b.v)); } -pub unsafe fn operator_lt_3(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_lt_4(mut a: V, mut b: V) -> bool { return ((a.v) < (b.v)); } pub unsafe fn operator_gt_5(mut a: V, mut b: V) -> bool { @@ -79,19 +74,19 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _a: V = x; - operator_eq_4(_a, z) + operator_eq_2(_a, z) }) ); assert!( (unsafe { let _a: V = x; - operator_ne_2(_a, y) + operator_ne_3(_a, y) }) ); assert!( (unsafe { let _a: V = x; - operator_lt_3(_a, y) + operator_lt_4(_a, y) }) ); assert!( @@ -103,7 +98,7 @@ unsafe fn main_0() -> i32 { assert!( !(unsafe { let _a: V = y; - operator_lt_3(_a, x) + operator_lt_4(_a, x) }) ); let mut a: S = S { v: 1 }; @@ -182,12 +177,4 @@ impl WeaklyEqualityComparableWithUnsafe for S { return (((*a).v) != ((*b).v)); } } -impl WeaklyEqualityComparableWithUnsafe for V { - unsafe fn not_equal(a: *const Self, b: *const Self) -> bool { - operator_ne_2((*a).clone(), (*b).clone()) - } - unsafe fn equal(a: *const Self, b: *const Self) -> bool { - operator_eq_4((*a).clone(), (*b).clone()) - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index d267606bf5..0f7eec1823 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -22,27 +22,22 @@ use std::rc::Rc; pub struct X { pub v: i32, } -impl LessThanComparableUnsafe for X { - unsafe fn less(a: *const Self, b: *const Self) -> bool { - ((operator_lt_4((*a).clone(), (*b).clone())) != 0) - } -} -pub unsafe fn operator_eq_5(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if ((a.v) == (b.v)) { 2 } else { 0 }; } -pub unsafe fn operator_ne_0(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_ne_1(mut a: X, mut b: X) -> i32 { return if ((a.v) != (b.v)) { 3 } else { 0 }; } -pub unsafe fn operator_lt_4(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_lt_2(mut a: X, mut b: X) -> i32 { return if ((a.v) < (b.v)) { 4 } else { 0 }; } -pub unsafe fn operator_gt_1(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_gt_3(mut a: X, mut b: X) -> i32 { return if ((a.v) > (b.v)) { 5 } else { 0 }; } -pub unsafe fn operator_le_2(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_le_4(mut a: X, mut b: X) -> i32 { return if ((a.v) <= (b.v)) { 6 } else { 0 }; } -pub unsafe fn operator_ge_3(mut a: X, mut b: X) -> i32 { +pub unsafe fn operator_ge_5(mut a: X, mut b: X) -> i32 { return if ((a.v) >= (b.v)) { 7 } else { 0 }; } #[repr(C)] @@ -113,11 +108,6 @@ impl Mixed { return if (((*this).v) == ((*o).v)) { 9 } else { 0 }; } } -impl LessThanComparableUnsafe for Mixed { - unsafe fn less(this: *const Self, o: *const Self) -> bool { - ((Mixed::operator_lt(this, o)) != 0) - } -} #[repr(C)] #[derive( Copy, @@ -160,22 +150,14 @@ impl MyBool { pub struct Boolish { pub v: i32, } -impl LessThanComparableUnsafe for Boolish { - unsafe fn less(a: *const Self, b: *const Self) -> bool { - { - let __cmp = operator_lt_6((*a).clone(), (*b).clone()); - MyBool::to_bool((&raw const __cmp)) - } - } -} -pub unsafe fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub unsafe fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) == (b.v))); __v }; } -pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { +pub unsafe fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) < (b.v))); @@ -247,43 +229,43 @@ unsafe fn main_0() -> i32 { assert!( ((unsafe { let _a: X = a; - operator_eq_5(_a, c) + operator_eq_0(_a, c) }) == (2)) ); assert!( ((unsafe { let _a: X = a; - operator_eq_5(_a, b) + operator_eq_0(_a, b) }) == (0)) ); assert!( ((unsafe { let _a: X = a; - operator_ne_0(_a, b) + operator_ne_1(_a, b) }) == (3)) ); assert!( ((unsafe { let _a: X = a; - operator_lt_4(_a, b) + operator_lt_2(_a, b) }) == (4)) ); assert!( ((unsafe { let _a: X = b; - operator_gt_1(_a, a) + operator_gt_3(_a, a) }) == (5)) ); assert!( ((unsafe { let _a: X = a; - operator_le_2(_a, c) + operator_le_4(_a, c) }) == (6)) ); assert!( ((unsafe { let _a: X = a; - operator_ge_3(_a, c) + operator_ge_5(_a, c) }) == (7)) ); let mut xs: [X; 3] = [X { v: 3 }, X { v: 1 }, X { v: 2 }]; @@ -363,7 +345,7 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b1; - operator_eq_7(_a, Boolish { v: 1 }) + operator_eq_6(_a, Boolish { v: 1 }) }), ) }) @@ -373,14 +355,14 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b2; - operator_lt_6(_a, b1) + operator_lt_7(_a, b1) }), ) }) ); let mut lt: MyBool = (unsafe { let _a: Boolish = b1; - operator_lt_6(_a, b2) + operator_lt_7(_a, b2) }); assert!(lt.value); let mut bs: [Boolish; 3] = [Boolish { v: 3 }, Boolish { v: 1 }, Boolish { v: 2 }]; @@ -433,49 +415,6 @@ unsafe fn main_0() -> i32 { ); return 0; } -impl PartiallyOrderedWithUnsafe for X { - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } - unsafe fn greater(lhs: *const Self, rhs: *const Self) -> bool { - ((operator_gt_1((*lhs).clone(), (*rhs).clone())) != 0) - } - unsafe fn less_equal(lhs: *const Self, rhs: *const Self) -> bool { - ((operator_le_2((*lhs).clone(), (*rhs).clone())) != 0) - } - unsafe fn greater_equal(lhs: *const Self, rhs: *const Self) -> bool { - ((operator_ge_3((*lhs).clone(), (*rhs).clone())) != 0) - } -} -impl WeaklyEqualityComparableWithUnsafe for Boolish { - unsafe fn equal(a: *const Self, b: *const Self) -> bool { - { - let __cmp = operator_eq_7((*a).clone(), (*b).clone()); - MyBool::to_bool((&raw const __cmp)) - } - } -} -impl WeaklyEqualityComparableWithUnsafe for Mixed { - unsafe fn equal(this: *const Self, o: *const Self) -> bool { - ((Mixed::operator_eq(this, o)) != 0) - } -} -impl WeaklyEqualityComparableWithUnsafe for RefInt { - unsafe fn equal(this: *const Self, _a0: *const Self) -> bool { - { - let __cmp = RefInt::operator_eq(this, _a0); - RefBool::to_bool((__cmp as *const _)) - } - } -} -impl WeaklyEqualityComparableWithUnsafe for X { - unsafe fn not_equal(a: *const Self, b: *const Self) -> bool { - ((operator_ne_0((*a).clone(), (*b).clone())) != 0) - } - unsafe fn equal(a: *const Self, b: *const Self) -> bool { - ((operator_eq_5((*a).clone(), (*b).clone())) != 0) - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const ref_true_8); } diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 1d43aabf16..2aed80036c 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -49,6 +49,7 @@ impl ThreeWayComparableUnsafe for DefaultedOrd { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -57,11 +58,6 @@ impl ThreeWayComparableUnsafe for DefaultedOrd { pub struct DefaultedOrd { pub a: i32, } -impl LessThanComparableUnsafe for DefaultedOrd { - unsafe fn less(_a0: *const Self, _a1: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(_a0, _a1)) - } -} impl LessThanComparableUnsafe for Inline { unsafe fn less(x: *const Inline, y: *const Inline) -> bool { return (((*x).a) < ((*y).a)); diff --git a/tests/unit/out/unsafe/operator_less_than.rs b/tests/unit/out/unsafe/operator_less_than.rs index a80f6bd106..21228414ef 100644 --- a/tests/unit/out/unsafe/operator_less_than.rs +++ b/tests/unit/out/unsafe/operator_less_than.rs @@ -29,11 +29,6 @@ impl Pair { || ((((*this).x) == ((*other).x)) && (((*this).y) < ((*other).y))); } } -impl LessThanComparableUnsafe for Pair { - unsafe fn less(this: *const Self, other: *const Self) -> bool { - Pair::operator_lt(this.cast_mut(), other) - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index adab99e390..ac8c89c5b3 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -16,6 +16,7 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -36,11 +37,6 @@ impl ThreeWayComparableUnsafe for S { return libcc2rs::STRONG_ORDERING_EQUAL; } } -impl LessThanComparableUnsafe for S { - unsafe fn less(this: *const Self, o: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, o)) - } -} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index befbfad472..b3d094d2a2 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -53,6 +53,7 @@ pub struct Eq { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, + LessThanComparableUnsafe, PartiallyOrderedWithUnsafe, )] #[three_way(ThreeWayComparableUnsafe::three_way)] @@ -67,11 +68,6 @@ impl ThreeWayComparableUnsafe for Cmp { return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).v), &((*o).v))); } } -impl LessThanComparableUnsafe for Cmp { - unsafe fn less(this: *const Self, o: *const Self) -> bool { - libcc2rs::is_lt(ThreeWayComparableUnsafe::three_way(this, o)) - } -} #[repr(C)] #[derive( Copy, From c9c771837636e4c98f4df4c1371bdb76466127f3 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 20:59:53 +0000 Subject: [PATCH 02/17] Remove ord trait --- cpp2rust/converter/converter.cpp | 261 +++--------------- cpp2rust/converter/converter.h | 36 +-- cpp2rust/converter/converter_lib.cpp | 15 +- cpp2rust/converter/converter_lib.h | 4 + .../converter/models/converter_refcount.cpp | 33 --- .../converter/models/converter_refcount.h | 11 - libcc2rs-macros/src/lib.rs | 10 + libcc2rs-macros/src/partially_ordered.rs | 41 ++- libcc2rs/src/lib.rs | 13 +- 9 files changed, 114 insertions(+), 310 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index fa688b9c02..6d2db8ceba 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -1161,7 +1161,7 @@ void Converter::EmitRustStructOrUnion(clang::RecordDecl *decl) { if (auto *cxx = clang::dyn_cast(decl)) { ConvertCXXRecordMethods(cxx); ConvertVirtualMethods(cxx); - AddOrdTrait(cxx); + ConvertPartiallyOrderedWithImpl(cxx); DeclareRecordTraits(cxx); AddAssignmentTraits(cxx); } @@ -1300,24 +1300,26 @@ std::string Converter::DestroyMembers(const clang::CXXRecordDecl *decl) { void Converter::EmitDerives(const clang::RecordDecl *decl) { auto *cxx = clang::dyn_cast(decl); auto *three_way = cxx ? GetDerivingThreeWayOperator(ctx_, cxx) : nullptr; + const clang::FunctionDecl *less_three_way = nullptr; + if (cxx) { + clang::QualType type = ctx_.getCanonicalTagType(cxx); + if (!FindComparisonOperator(ctx_, type, type, clang::OO_Less)) { + less_three_way = GetThreeWayOperator(ctx_, cxx); + } + } StrCat("#[derive("); for (auto *attr : GetStructAttributes(decl)) { StrCat(attr, ','); } + if (less_three_way) { + StrCat(GetCopyOrMoveTraitName(kLessThanComparable), ','); + } if (three_way) { StrCat(GetCopyOrMoveTraitName(kPartiallyOrderedWith), ','); } StrCat(")]"); - if (auto *method = clang::dyn_cast_or_null(three_way)) { - StrCat(std::format("#[three_way({}::{})]", GetUFCSName(method), - GetMethodName(method))); - } else if (auto *trait = - three_way ? GetComparisonTrait(three_way) : nullptr) { - StrCat(std::format("#[three_way({}::{})]", GetCopyOrMoveTraitName(*trait), - trait->method)); - } else if (three_way) { - StrCat(std::format("#[three_way({})]", - GetNamedDeclAsString(three_way->getCanonicalDecl()))); + if (auto *cmp = three_way ? three_way : less_three_way) { + StrCat(std::format("#[three_way({})]", GetThreeWayPath(cmp))); } if (auto methods = GetDerivedCopyOrMoves(decl); !methods.empty()) { StrCat("#[memberwise("); @@ -1328,6 +1330,17 @@ void Converter::EmitDerives(const clang::RecordDecl *decl) { } } +std::string Converter::GetThreeWayPath(const clang::FunctionDecl *cmp) { + if (auto *method = clang::dyn_cast(cmp)) { + return std::format("{}::{}", GetUFCSName(method), GetMethodName(method)); + } + if (auto *trait = GetComparisonTrait(cmp)) { + return std::format("{}::{}", GetCopyOrMoveTraitName(*trait), + trait->method); + } + return GetNamedDeclAsString(cmp->getCanonicalDecl()); +} + void Converter::EmitReprC(clang::RecordDecl *decl) { if (decl->hasAttr()) { StrCat(std::format("#[repr(C, align({}))]", @@ -5998,110 +6011,6 @@ bool Converter::ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl) { return emitted; } -std::string Converter::GetComparisonCall(const clang::FunctionDecl *op, - const clang::CXXRecordDecl *decl, - std::string_view lhs, - std::string_view rhs) { - if (const auto *method = clang::dyn_cast(op)) { - return std::format("{}::{}({}, {})", GetUFCSName(method), - GetMethodName(method), - GetComparisonReceiver(method, lhs), - GetComparisonArg(op->getParamDecl(0), decl, rhs)); - } - if (auto *trait = GetComparisonTrait(op)) { - return std::format("{}::{}({}, {})", GetCopyOrMoveTraitName(*trait), - trait->method, lhs, - GetComparisonArg(op->getParamDecl(1), decl, rhs)); - } - return std::format("{}({}, {})", GetNamedDeclAsString(op->getCanonicalDecl()), - GetComparisonArg(op->getParamDecl(0), decl, lhs), - GetComparisonArg(op->getParamDecl(1), decl, rhs)); -} - -std::string Converter::GetComparisonBool(const clang::FunctionDecl *op, - const clang::CXXRecordDecl *decl, - std::string_view lhs, - std::string_view rhs) { - auto call = GetComparisonCall(op, decl, lhs, rhs); - auto ret = op->getReturnType(); - if (ret->isBooleanType()) { - return call; - } - if (ret->isIntegerType()) { - return std::format("(({}) != 0)", call); - } - bool returns_ref = ret->isReferenceType(); - const auto *record = ret.getNonReferenceType()->getAsCXXRecordDecl(); - assert(record && "unsupported comparison operator return type"); - for (const auto *found : record->getVisibleConversionFunctions()) { - const auto *conversion = clang::dyn_cast(found); - if (conversion && conversion->getConversionType()->isBooleanType()) { - return std::format( - "{{ let __cmp = {}; {}::{}({}) }}", call, GetUFCSName(conversion), - GetMethodName(conversion), - GetComparisonResultReceiver(conversion, returns_ref, "__cmp")); - } - } - assert(0 && "comparison operator result has no conversion to bool"); - return call; -} - -std::string Converter::GetComparisonArg(const clang::ParmVarDecl *param, - const clang::CXXRecordDecl *, - std::string_view value) { - auto type = param->getType(); - if (!type->isReferenceType()) { - return std::format("(*{}).clone()", value); - } - if (type.getNonReferenceType().isConstQualified()) { - return std::string(value); - } - return std::format("{}.cast_mut()", value); -} - -std::string -Converter::GetComparisonResultReceiver(const clang::CXXMethodDecl *method, - bool returns_ref, - std::string_view result) { - return GetComparisonReceiver( - method, returns_ref ? std::format("({} as *const _)", result) - : std::format("(&raw const {})", result)); -} - -std::string Converter::GetComparisonReceiver(const clang::CXXMethodDecl *method, - std::string_view lhs) { - bool is_mut = MethodNeedsMutableReceiver(method); - if (!IsMethodOnPtr(method)) { - return is_mut ? std::format("&mut *{}.cast_mut()", lhs) - : std::format("&*{}", lhs); - } - return is_mut ? std::format("{}.cast_mut()", lhs) : std::string(lhs); -} - -void Converter::ConvertComparisonTraitWrappers(const clang::CXXRecordDecl *decl, - const clang::FunctionDecl *eq, - const clang::FunctionDecl *lt, - const clang::FunctionDecl *cmp) { - if (auto *op = lt ? lt : cmp; op && !(lt && GetComparisonTrait(lt))) { - const auto &trait = kLessThanComparable; - auto [lhs, rhs] = GetComparisonOperandNames(op); - StrCat(keyword::kImpl, GetRecordTraitSpelling(trait).name, "for", - GetRecordName(decl)); - PushBrace impl_brace(*this); - StrCat(GetComparisonTraitSignature(trait, lhs, rhs, "Self")); - PushBrace body(*this); - if (lt) { - StrCat(GetComparisonBool(lt, decl, lhs, rhs)); - } else { - StrCat(std::format("libcc2rs::is_lt({})", - GetComparisonCall(cmp, decl, lhs, rhs))); - } - } - if (eq && !GetComparisonTrait(eq)) { - ConvertEqualityComparableImpl(decl, eq); - } -} - void Converter::ConvertPartiallyOrderedWithImpl( const clang::CXXRecordDecl *decl) { if (!IsPartiallyOrdered(ctx_, decl) || @@ -6109,7 +6018,21 @@ void Converter::ConvertPartiallyOrderedWithImpl( return; } clang::QualType type = ctx_.getCanonicalTagType(decl); - auto *cmp = FindComparisonOperator(ctx_, type, type, clang::OO_Spaceship); + auto *cmp = GetThreeWayOperator(ctx_, decl); + auto *lt = FindComparisonOperator(ctx_, type, type, clang::OO_Less); + if (lt ? !GetComparisonTrait(lt) : !cmp) { + return; + } + const std::pair relations[] = { + {clang::OO_Greater, "is_gt"}, + {clang::OO_LessEqual, "is_lteq"}, + {clang::OO_GreaterEqual, "is_gteq"}}; + for (const auto &relation : relations) { + auto *op = FindComparisonOperator(ctx_, type, type, relation.first); + if (op ? !GetComparisonTrait(op) : !cmp) { + return; + } + } auto add = [&](const RecordTrait &trait, const std::string &body) { ComparisonTraitImpl(trait, GetRecordName(decl), "").body += std::format( "{} {{ {} }}\n", @@ -6119,44 +6042,15 @@ void Converter::ConvertPartiallyOrderedWithImpl( std::format("::{}(lhs, rhs)", GetRecordTraitSpelling(kLessThanComparable).name, kLessThanComparable.method)); - const std::pair relations[] = { - {clang::OO_Greater, "is_gt"}, - {clang::OO_LessEqual, "is_lteq"}, - {clang::OO_GreaterEqual, "is_gteq"}}; for (auto [kind, from_three_way] : relations) { - const auto &trait = GetPartiallyOrderedWithTrait(kind); - auto *op = FindComparisonOperator(ctx_, type, type, kind); - if (!op) { - add(trait, std::format("libcc2rs::{}({})", from_three_way, - GetComparisonCall(cmp, decl, "lhs", "rhs"))); - } else if (!GetComparisonTrait(op)) { - add(trait, GetComparisonBool(op, decl, "lhs", "rhs")); + if (!FindComparisonOperator(ctx_, type, type, kind)) { + add(GetPartiallyOrderedWithTrait(kind), + std::format("libcc2rs::{}({}(lhs, rhs))", from_three_way, + GetThreeWayPath(cmp))); } } } -std::pair -Converter::GetComparisonOperandNames(const clang::FunctionDecl *op) { - auto params = DefinitionParameters(op); - return {clang::isa(op) - ? "this" - : GetNamedDeclAsString(params.front()), - GetNamedDeclAsString(params.back())}; -} - -void Converter::ConvertEqualityComparableImpl(const clang::CXXRecordDecl *decl, - const clang::FunctionDecl *op) { - const auto &trait = op->getOverloadedOperator() == clang::OO_ExclaimEqual - ? kWeaklyEqualityComparableWithNotEqual - : kWeaklyEqualityComparableWith; - auto [lhs, rhs] = GetComparisonOperandNames(op); - AddComparisonTraitMethod( - op, trait, - std::format("{} {{ {} }}\n", - GetComparisonTraitSignature(trait, lhs, rhs, "Self"), - GetComparisonBool(op, decl, lhs, rhs))); -} - std::string Converter::GetComparisonTraitSignature( const RecordTrait &trait, std::string_view lhs, std::string_view rhs, std::string_view rhs_type) const { @@ -6164,75 +6058,6 @@ std::string Converter::GetComparisonTraitSignature( trait.method, lhs, rhs, rhs_type); } -void Converter::AddOrdTrait(const clang::CXXRecordDecl *decl) { - const clang::FunctionDecl *eq = nullptr; - const clang::FunctionDecl *ne = nullptr; - const clang::FunctionDecl *lt = nullptr; - const clang::FunctionDecl *cmp = nullptr; - auto consider = [&](const clang::FunctionDecl *fn) { - if (!fn || fn->isImplicit() || fn->isDeleted() || !fn->hasBody() || - fn->getDescribedFunctionTemplate() || !IsSameTypeComparison(fn, decl)) { - return; - } - if (fn->getOverloadedOperator() == clang::OO_Spaceship && - !ctx_.CompCategories.lookupInfoForType(fn->getReturnType())) { - return; - } - switch (fn->getOverloadedOperator()) { - case clang::OO_EqualEqual: - eq = fn; - break; - case clang::OO_ExclaimEqual: - ne = fn; - break; - case clang::OO_Less: - lt = fn; - break; - case clang::OO_Spaceship: - cmp = fn; - break; - default: - break; - } - }; - auto consider_decl = [&](const clang::NamedDecl *found) { - if (const auto *tmpl = - clang::dyn_cast(found)) { - for (const auto *spec : tmpl->specializations()) { - consider(spec); - } - return; - } - consider(clang::dyn_cast(found)); - }; - for (const auto *method : decl->methods()) { - consider(method); - } - for (auto op : {clang::OO_EqualEqual, clang::OO_ExclaimEqual, clang::OO_Less, - clang::OO_Spaceship}) { - auto name = ctx_.DeclarationNames.getCXXOperatorName(op); - for (const auto *found : decl->getDeclContext()->lookup(name)) { - consider_decl(found); - } - } - for (const auto *friend_decl : decl->friends()) { - if (const auto *found = friend_decl->getFriendDecl()) { - consider_decl(found); - } - } - - if (eq && ne && !GetComparisonTrait(ne)) { - ConvertEqualityComparableImpl(decl, ne); - } - ConvertPartiallyOrderedWithImpl(decl); - - if (!eq && !lt && !cmp) { - return; - } - - ConvertComparisonTraitWrappers(decl, eq, lt, cmp); -} - void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, std::vector &attrs) { auto implements = [&](const RecordTrait *trait) { diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 44dbc79de1..7203c1bfc4 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -213,6 +213,8 @@ class Converter : public clang::RecursiveASTVisitor { void EmitReprC(clang::RecordDecl *decl); void EmitDerives(const clang::RecordDecl *decl); + std::string GetThreeWayPath(const clang::FunctionDecl *cmp); + virtual void EmitRustUnion(clang::RecordDecl *decl); virtual bool EmitsReprCForRecords() const { return true; } @@ -514,12 +516,6 @@ class Converter : public clang::RecursiveASTVisitor { std::string_view rhs, std::string_view rhs_type) const; - std::pair - GetComparisonOperandNames(const clang::FunctionDecl *op); - - void ConvertEqualityComparableImpl(const clang::CXXRecordDecl *decl, - const clang::FunctionDecl *op); - void ConvertPartiallyOrderedWithImpl(const clang::CXXRecordDecl *decl); std::string GetComparisonCategory(const clang::FunctionDecl *op); @@ -989,34 +985,6 @@ class Converter : public clang::RecursiveASTVisitor { bool ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl); - void AddOrdTrait(const clang::CXXRecordDecl *decl); - - void ConvertComparisonTraitWrappers(const clang::CXXRecordDecl *decl, - const clang::FunctionDecl *eq, - const clang::FunctionDecl *lt, - const clang::FunctionDecl *cmp); - - std::string GetComparisonCall(const clang::FunctionDecl *op, - const clang::CXXRecordDecl *decl, - std::string_view lhs, std::string_view rhs); - - std::string GetComparisonBool(const clang::FunctionDecl *op, - const clang::CXXRecordDecl *decl, - std::string_view lhs, std::string_view rhs); - - // The argument for param of a comparison operator of decl, from an operand - // of the comparison. - virtual std::string GetComparisonArg(const clang::ParmVarDecl *param, - const clang::CXXRecordDecl *decl, - std::string_view value); - - virtual std::string - GetComparisonResultReceiver(const clang::CXXMethodDecl *method, - bool returns_ref, std::string_view result); - - virtual std::string GetComparisonReceiver(const clang::CXXMethodDecl *method, - std::string_view lhs); - virtual bool RecordImplementsClone(const clang::RecordDecl *decl); bool RecordDerivesTriviallyCopyable(const clang::RecordDecl *decl); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 88fc850a5f..73719f6146 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -788,14 +788,25 @@ static bool TakesConstReferenceOperands(const clang::FunctionDecl *fn) { } const clang::FunctionDecl * -GetDerivingThreeWayOperator(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record) { +GetThreeWayOperator(clang::ASTContext &ctx, + const clang::CXXRecordDecl *record) { clang::QualType type = ctx.getCanonicalTagType(record); auto *cmp = FindComparisonOperator(ctx, type, type, clang::OO_Spaceship); if (!cmp || !ctx.CompCategories.lookupInfoForType(cmp->getReturnType()) || !TakesConstReferenceOperands(cmp)) { return nullptr; } + return cmp; +} + +const clang::FunctionDecl * +GetDerivingThreeWayOperator(clang::ASTContext &ctx, + const clang::CXXRecordDecl *record) { + auto *cmp = GetThreeWayOperator(ctx, record); + if (!cmp) { + return nullptr; + } + clang::QualType type = ctx.getCanonicalTagType(record); for (auto op : {clang::OO_Greater, clang::OO_LessEqual, clang::OO_GreaterEqual}) { if (FindComparisonOperator(ctx, type, type, op)) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 51b08bcb1c..04bb545d5d 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -258,6 +258,10 @@ GetPartiallyOrderedWithTrait(clang::OverloadedOperatorKind op); bool IsPartiallyOrdered(clang::ASTContext &ctx, const clang::CXXRecordDecl *record); +const clang::FunctionDecl * +GetThreeWayOperator(clang::ASTContext &ctx, + const clang::CXXRecordDecl *record); + const clang::FunctionDecl * GetDerivingThreeWayOperator(clang::ASTContext &ctx, const clang::CXXRecordDecl *record); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 3435b57a9b..0e313bc7f1 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -646,39 +646,6 @@ bool ConverterRefCount::VisitOffsetOfExpr(clang::OffsetOfExpr *expr) { return false; } -// The operands of comparison operators are pointers to the values (&Ptr). -std::string -ConverterRefCount::GetComparisonArg(const clang::ParmVarDecl *param, - const clang::CXXRecordDecl *decl, - std::string_view value) { - if (param->getType()->isReferenceType()) { - return std::format("{}.clone()", value); - } - if (IsTriviallyCopyable(decl)) { - return std::format("{}.read()", value); - } - auto record = GetRecordName(decl); - return std::format("{{ {} <{} as CopyConstructible>::copy_constructor({}, " - "LvalueRef::bind({}.clone())); {} }}", - CreatePlacementStorage(record), record, - GetPlacementReceiver(), value, TakePlacementValue()); -} - -std::string ConverterRefCount::GetComparisonResultReceiver( - const clang::CXXMethodDecl *, bool returns_ref, std::string_view result) { - if (returns_ref) { - return std::format("{}.clone()", result); - } - PushConversionKind push(*this, ConversionKind::FullRefCount); - return std::format("{}.as_pointer()", BoxValue(std::string(result))); -} - -std::string -ConverterRefCount::GetComparisonReceiver(const clang::CXXMethodDecl *, - std::string_view lhs) { - return std::format("{}.clone()", lhs); -} - std::string ConverterRefCount::GetComparisonTraitSignature( const RecordTrait &trait, std::string_view lhs, std::string_view rhs, std::string_view rhs_type) const { diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index b65cd7cfbd..06524716dc 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -52,17 +52,6 @@ class ConverterRefCount final : public Converter { const char *CharRustType() const override { return "i8"; } - std::string GetComparisonArg(const clang::ParmVarDecl *param, - const clang::CXXRecordDecl *decl, - std::string_view value) override; - - std::string GetComparisonResultReceiver(const clang::CXXMethodDecl *method, - bool returns_ref, - std::string_view result) override; - - std::string GetComparisonReceiver(const clang::CXXMethodDecl *method, - std::string_view lhs) override; - std::string GetComparisonTraitSignature(const RecordTrait &trait, std::string_view lhs, std::string_view rhs, diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 4c2bebaf7f..36fb266af7 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -361,6 +361,16 @@ pub fn derive_destructible_unsafe(input: TokenStream) -> TokenStream { destructor::expand(input, true) } +#[proc_macro_derive(LessThanComparable, attributes(three_way))] +pub fn derive_less_than_comparable(input: TokenStream) -> TokenStream { + partially_ordered::expand_less_than_comparable(input, false) +} + +#[proc_macro_derive(LessThanComparableUnsafe, attributes(three_way))] +pub fn derive_less_than_comparable_unsafe(input: TokenStream) -> TokenStream { + partially_ordered::expand_less_than_comparable(input, true) +} + #[proc_macro_derive(PartiallyOrderedWith, attributes(three_way))] pub fn derive_partially_ordered_with(input: TokenStream) -> TokenStream { partially_ordered::expand(input, false) diff --git a/libcc2rs-macros/src/partially_ordered.rs b/libcc2rs-macros/src/partially_ordered.rs index 0028da1311..98fb9c3181 100644 --- a/libcc2rs-macros/src/partially_ordered.rs +++ b/libcc2rs-macros/src/partially_ordered.rs @@ -5,17 +5,46 @@ use proc_macro::TokenStream; use quote::quote; use syn::{DeriveInput, parse_macro_input}; -pub fn expand(input: TokenStream, is_unsafe: bool) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let three_way: syn::Path = input +fn three_way_path(input: &DeriveInput) -> syn::Path { + input .attrs .iter() .find(|attr| attr.path().is_ident("three_way")) .expect("three_way(path) names the operator<=> of the type") .parse_args() - .expect("three_way(path)"); + .expect("three_way(path)") +} + +pub fn expand_less_than_comparable(input: TokenStream, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let name = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + let three_way = three_way_path(&input); + if is_unsafe { + return quote! { + impl #impl_generics ::libcc2rs::LessThanComparableUnsafe for #name #ty_generics #where_clause { + unsafe fn less(this: *const Self, rhs: *const Self) -> bool { + ::libcc2rs::is_lt(unsafe { #three_way(this, rhs) }) + } + } + } + .into(); + } + quote! { + impl #impl_generics ::libcc2rs::LessThanComparable for #name #ty_generics #where_clause { + fn less(this: ::libcc2rs::Ptr, rhs: ::libcc2rs::Ptr) -> bool { + ::libcc2rs::is_lt(#three_way(this, rhs)) + } + } + } + .into() +} + +pub fn expand(input: TokenStream, is_unsafe: bool) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let name = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + let three_way = three_way_path(&input); let relations = [ (quote!(greater), quote!(is_gt)), (quote!(less_equal), quote!(is_lteq)), diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index 171a021a11..a2b4d2757c 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -140,10 +140,11 @@ pub use libcc2rs_macros::{ ByteRepr, Conversions, ConversionsUnsafe, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, CopyableUnsafe, DefaultConstructible, DefaultConstructibleUnsafe, DefaultInitializable, DefaultInitializableUnsafe, Destructible, - DestructibleUnsafe, FnPtrArg, Memberwise, MemberwiseUnsafe, Movable, MovableUnsafe, - MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, - PartiallyOrderedWith, PartiallyOrderedWithUnsafe, Record, Swappable, SwappableUnsafe, - TriviallyCopyable, TriviallyCopyableUnsafe, TriviallyDefaultConstructible, - TriviallyDefaultConstructibleUnsafe, VaArg, ZeroInitialization, ZeroInitializationUnsafe, - assign, assign_unsafe, goto, goto_block, lambda, lambda_unsafe, switch, + DestructibleUnsafe, FnPtrArg, LessThanComparable, LessThanComparableUnsafe, Memberwise, + MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, + MoveConstructible, MoveConstructibleUnsafe, PartiallyOrderedWith, PartiallyOrderedWithUnsafe, + Record, Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, + TriviallyDefaultConstructible, TriviallyDefaultConstructibleUnsafe, VaArg, ZeroInitialization, + ZeroInitializationUnsafe, assign, assign_unsafe, goto, goto_block, lambda, lambda_unsafe, + switch, }; From 3efbc7df79b897fe74d3cecdc784b1a61d4ee439 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 21:50:13 +0000 Subject: [PATCH 03/17] Return BooleanTestable from comparison traits --- cpp2rust/converter/converter.cpp | 314 +++++------ cpp2rust/converter/converter.h | 37 +- cpp2rust/converter/converter_lib.cpp | 275 +++------- cpp2rust/converter/converter_lib.h | 122 ++--- .../converter/models/converter_refcount.cpp | 7 - .../converter/models/converter_refcount.h | 5 - libcc2rs-macros/src/lib.rs | 20 - libcc2rs-macros/src/partially_ordered.rs | 87 --- libcc2rs/src/cmp.rs | 507 +++++++++++++----- libcc2rs/src/fn_ptr.rs | 34 +- libcc2rs/src/lib.rs | 7 +- libcc2rs/src/overload.rs | 73 ++- libcc2rs/src/reference.rs | 110 +++- libcc2rs/src/void.rs | 17 +- rules/algorithm/tgt_refcount.rs | 76 ++- rules/algorithm/tgt_unsafe.rs | 102 +++- rules/iterator_category/shim.rs | 180 +++++-- rules/iterator_category/tgt_refcount.rs | 35 +- rules/iterator_category/tgt_unsafe.rs | 35 +- rules/map/shim.rs | 18 +- rules/pair/tgt_refcount.rs | 38 +- rules/pair/tgt_unsafe.rs | 42 +- rules/vector/tgt_refcount.rs | 10 +- rules/vector/tgt_unsafe.rs | 14 +- .../out/refcount/friend_operator.rs | 70 ++- .../class.conv/out/refcount/class.conv.fct.rs | 83 +++ .../out/refcount/concept.totallyordered.rs | 425 ++++++++++++--- 27 files changed, 1747 insertions(+), 996 deletions(-) delete mode 100644 libcc2rs-macros/src/partially_ordered.rs diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 6d2db8ceba..0ec64dabd8 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -75,42 +75,6 @@ Converter::DeferredBlock &Converter::DeferredImpl(std::string header) { return it->second; } -void Converter::AddComparisonTraitMethod(const clang::FunctionDecl *op, - const RecordTrait &trait, - std::string_view method) { - auto *record = GetComparisonRecord(op); - auto name = GetRecordName(record); - clang::QualType lhs = ctx_.getCanonicalTagType(record); - auto rhs = GetComparisonRhsType(op); - if (lhs == rhs) { - ComparisonTraitImpl(trait, name, "").body += method; - if (&trait == &kWeaklyEqualityComparableWith) { - converted_record_traits_.emplace(name, trait.refcount.name); - } - return; - } - auto other = GetUnboxedTypeAsString(rhs); - ComparisonTraitImpl(trait, name, other).body += method; - if (&trait != &kWeaklyEqualityComparableWith || - FindComparisonOperator(ctx_, rhs, lhs, clang::OO_EqualEqual)) { - return; - } - ComparisonTraitImpl(trait, other, name).body += - std::format("{} {{ <{} as {}<{}>>::{}(rhs, lhs) }}\n", - GetComparisonTraitSignature(trait, "lhs", "rhs", name), name, - GetRecordTraitSpelling(trait).name, other, trait.method); -} - -Converter::DeferredBlock & -Converter::ComparisonTraitImpl(const RecordTrait &trait, std::string_view self, - std::string_view other) { - const char *name = GetRecordTraitSpelling(trait).name; - if (other.empty()) { - return DeferredImpl(std::format("impl {} for {}", name, self)); - } - return DeferredImpl(std::format("impl {}<{}> for {}", name, other, self)); -} - void Converter::EmitUndefinedRecordTraits(Model model, std::string &out) { bool is_unsafe = model == Model::kUnsafe; for (const auto &[record, traits] : declared_record_traits_) { @@ -119,13 +83,6 @@ void Converter::EmitUndefinedRecordTraits(Model model, std::string &out) { continue; } const auto &spelling = is_unsafe ? trait->unsafe : trait->refcount; - if (trait == &kWeaklyEqualityComparableWith) { - DeferredImpl(std::format("impl {} for {}", spelling.name, record)) - .body += - std::format("{} {{ unreachable!(\"{}::{} is never defined\") }}\n", - spelling.signature, record, trait->method); - continue; - } out += std::format( "impl {} for {} {{ {} {{ unreachable!(\"{}::{} is never defined\") " "}} }}\n", @@ -138,16 +95,8 @@ void Converter::EmitUndefinedRecordTraits(Model model, std::string &out) { void Converter::DeclareRecordTraits(const clang::CXXRecordDecl *decl) { auto &traits = declared_record_traits_[GetRecordName(decl)]; for (auto *method : decl->methods()) { - if (auto *comparison = GetComparisonTrait(method); - comparison && HasDeferredComparisonImpl(*comparison)) { - if (IsEqualityComparableTrait(*comparison) && - IsSameTypeComparison(method, decl)) { - traits.emplace(kWeaklyEqualityComparableWith.refcount.name, - &kWeaklyEqualityComparableWith); - } - } else if (auto *trait = GetRecordTrait(method); - trait && trait != &kThreeWayComparable && - !IsDerivedCopyOrMove(method)) { + if (auto *trait = GetRecordTrait(method); + trait && !IsDerivedCopyOrMove(method)) { traits.emplace(trait->refcount.name, trait); } } @@ -557,10 +506,6 @@ bool Converter::VisitFunctionDecl(clang::FunctionDecl *decl) { } DumpVerbose(decl); ScopedValue push_fn(curr_function_, decl); - if (auto *trait = GetComparisonTrait(decl)) { - ConvertComparisonTraitImpl(decl, *trait); - return false; - } std::string function_name; if (decl->isMain()) { // main_0 is private. @@ -584,44 +529,6 @@ bool Converter::VisitFunctionDecl(clang::FunctionDecl *decl) { return false; } -void Converter::ConvertComparisonTraitImpl(clang::FunctionDecl *decl, - const RecordTrait &trait) { - std::string method; - { - Buffer buf(*this); - StrCat(keyword_unsafe_, keyword::kFn, trait.method); - { - PushParen paren(*this); - ConvertFunctionParameters(decl); - } - ConvertFunctionReturnType(decl); - { - PushBrace body(*this); - EmitFunctionPreamble(decl); - ConvertFunctionBody(decl); - } - method = std::move(buf).str(); - } - if (HasDeferredComparisonImpl(trait)) { - AddComparisonTraitMethod(decl, trait, method); - return; - } - auto record_name = GetRecordName(GetComparisonRecord(decl)); - converted_record_traits_.emplace(record_name, trait.refcount.name); - StrCat(keyword::kImpl, GetRecordTraitSpelling(trait).name, "for", - record_name); - PushBrace impl_brace(*this); - if (&trait == &kThreeWayComparable) { - StrCat(GetComparisonCategory(decl)); - } - StrCat(method); -} - -std::string Converter::GetComparisonCategory(const clang::FunctionDecl *op) { - return std::format("type Category = {};", - GetUnboxedTypeAsString(op->getReturnType())); -} - void Converter::EmitHoistedDecls(clang::CompoundStmt *body) { for (auto *child : body->body()) { if (auto *decl_stmt = clang::dyn_cast(child)) { @@ -1161,7 +1068,7 @@ void Converter::EmitRustStructOrUnion(clang::RecordDecl *decl) { if (auto *cxx = clang::dyn_cast(decl)) { ConvertCXXRecordMethods(cxx); ConvertVirtualMethods(cxx); - ConvertPartiallyOrderedWithImpl(cxx); + EmitComparisonTraits(cxx); DeclareRecordTraits(cxx); AddAssignmentTraits(cxx); } @@ -1265,18 +1172,11 @@ void Converter::ConvertCopyOrMoveTraitImpl(clang::CXXMethodDecl *method, if (body.empty()) { return; } - if (HasDeferredComparisonImpl(trait)) { - AddComparisonTraitMethod(method, trait, body); - return; - } converted_record_traits_.emplace(GetRecordName(method->getParent()), trait.refcount.name); StrCat(keyword::kImpl, GetCopyOrMoveTraitName(trait), "for", GetRecordName(method->getParent())); PushBrace brace(*this); - if (&trait == &kThreeWayComparable) { - StrCat(GetComparisonCategory(method)); - } StrCat(body); } @@ -1298,29 +1198,11 @@ std::string Converter::DestroyMembers(const clang::CXXRecordDecl *decl) { } void Converter::EmitDerives(const clang::RecordDecl *decl) { - auto *cxx = clang::dyn_cast(decl); - auto *three_way = cxx ? GetDerivingThreeWayOperator(ctx_, cxx) : nullptr; - const clang::FunctionDecl *less_three_way = nullptr; - if (cxx) { - clang::QualType type = ctx_.getCanonicalTagType(cxx); - if (!FindComparisonOperator(ctx_, type, type, clang::OO_Less)) { - less_three_way = GetThreeWayOperator(ctx_, cxx); - } - } StrCat("#[derive("); for (auto *attr : GetStructAttributes(decl)) { StrCat(attr, ','); } - if (less_three_way) { - StrCat(GetCopyOrMoveTraitName(kLessThanComparable), ','); - } - if (three_way) { - StrCat(GetCopyOrMoveTraitName(kPartiallyOrderedWith), ','); - } StrCat(")]"); - if (auto *cmp = three_way ? three_way : less_three_way) { - StrCat(std::format("#[three_way({})]", GetThreeWayPath(cmp))); - } if (auto methods = GetDerivedCopyOrMoves(decl); !methods.empty()) { StrCat("#[memberwise("); for (auto *method : methods) { @@ -1330,17 +1212,6 @@ void Converter::EmitDerives(const clang::RecordDecl *decl) { } } -std::string Converter::GetThreeWayPath(const clang::FunctionDecl *cmp) { - if (auto *method = clang::dyn_cast(cmp)) { - return std::format("{}::{}", GetUFCSName(method), GetMethodName(method)); - } - if (auto *trait = GetComparisonTrait(cmp)) { - return std::format("{}::{}", GetCopyOrMoveTraitName(*trait), - trait->method); - } - return GetNamedDeclAsString(cmp->getCanonicalDecl()); -} - void Converter::EmitReprC(clang::RecordDecl *decl) { if (decl->hasAttr()) { StrCat(std::format("#[repr(C, align({}))]", @@ -2817,7 +2688,7 @@ void Converter::EmitCall(CallInfo &&info) { auto *direct_callee = info.expr->getDirectCallee(); assert(direct_callee); StrCat("libc::", direct_callee->getName()); - } else if (!EmitComparisonTraitCallee(info)) { + } else { PushExprKind push(*this, ExprKind::Callee); Convert(GetCallee(info.expr)); } @@ -2825,19 +2696,6 @@ void Converter::EmitCall(CallInfo &&info) { EmitArgList(info); } -bool Converter::EmitComparisonTraitCallee(const CallInfo &info) { - auto *callee = info.expr->getDirectCallee(); - if (!callee || clang::isa(callee)) { - return false; - } - auto *trait = GetComparisonTrait(callee); - if (!trait) { - return false; - } - StrCat(GetCopyOrMoveTraitName(*trait), token::kDoubleColon, trait->method); - return true; -} - void Converter::ConvertGenericCallExpr(clang::CallExpr *expr) { PushParen outer(*this); StrCat(keyword_unsafe_); @@ -2881,7 +2739,7 @@ void Converter::ConvertUserOperatorCall(clang::CXXOperatorCallExpr *expr) { SetUFCSReceiver(expr->getArg(0), false, method); } StrCat(GetUFCSName(method), token::kDoubleColon, GetMethodName(method)); - } else if (!EmitComparisonTraitCallee(info)) { + } else { StrCat(GetNamedDeclAsString(callee->getCanonicalDecl())); } EmitArgList(info); @@ -6011,51 +5869,137 @@ bool Converter::ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl) { return emitted; } -void Converter::ConvertPartiallyOrderedWithImpl( - const clang::CXXRecordDecl *decl) { - if (!IsPartiallyOrdered(ctx_, decl) || - GetDerivingThreeWayOperator(ctx_, decl)) { - return; - } - clang::QualType type = ctx_.getCanonicalTagType(decl); - auto *cmp = GetThreeWayOperator(ctx_, decl); - auto *lt = FindComparisonOperator(ctx_, type, type, clang::OO_Less); - if (lt ? !GetComparisonTrait(lt) : !cmp) { - return; - } - const std::pair relations[] = { - {clang::OO_Greater, "is_gt"}, - {clang::OO_LessEqual, "is_lteq"}, - {clang::OO_GreaterEqual, "is_gteq"}}; - for (const auto &relation : relations) { - auto *op = FindComparisonOperator(ctx_, type, type, relation.first); - if (op ? !GetComparisonTrait(op) : !cmp) { - return; +void Converter::EmitComparisonTraits(const clang::CXXRecordDecl *decl) { + ScopedValue no_function(curr_function_, nullptr); + auto *context = clang::BlockDecl::Create( + ctx_, ctx_.getTranslationUnitDecl(), decl->getLocation()); + clang::QualType self = ctx_.getCanonicalTagType(decl); + auto comparisons = + BuildComparisons(context, self, self, + {&kWeaklyEqualityComparableWith, &kLessThanComparable, + &kPartiallyOrderedWith, &kThreeWayComparable}); + for (const auto *trait : {&kWeaklyEqualityComparableWith, + &kLessThanComparable, &kPartiallyOrderedWith}) { + if (comparisons.Has(*trait)) { + EmitComparisonTrait(*trait, comparisons); + } + } + if (auto *three_way = comparisons.exprs.at(clang::BO_Cmp); + three_way && three_way->isPRValue() && + ctx_.CompCategories.lookupInfoForType(three_way->getType()) && + comparisons.Has(kWeaklyEqualityComparableWith) && + comparisons.Has(kPartiallyOrderedWith)) { + EmitComparisonTrait(kThreeWayComparable, comparisons); + } + std::initializer_list symmetric = { + &kWeaklyEqualityComparableWith, &kPartiallyOrderedWith}; + for (auto other : GetComparisonOperandTypes(decl)) { + auto *other_record = other->getAsCXXRecordDecl(); + bool other_emits_reverse = + other_record && IsUserDefinedDecl(other_record) && + llvm::is_contained(GetComparisonOperandTypes(other_record), self); + auto forward = BuildComparisons(context, self, other, symmetric); + auto reverse = BuildComparisons(context, other, self, symmetric); + for (const auto *trait : symmetric) { + if (forward.Has(*trait) && reverse.Has(*trait)) { + EmitComparisonTrait(*trait, forward); + if (!other_emits_reverse) { + EmitComparisonTrait(*trait, reverse); + } + } } } - auto add = [&](const RecordTrait &trait, const std::string &body) { - ComparisonTraitImpl(trait, GetRecordName(decl), "").body += std::format( - "{} {{ {} }}\n", - GetComparisonTraitSignature(trait, "lhs", "rhs", "Self"), body); +} + +bool Converter::Comparisons::Has(const ComparisonTrait &trait) const { + return llvm::all_of(trait.relations, [&](const ComparisonRelation &relation) { + return exprs.at(relation.op) != nullptr; + }); +} + +Converter::Comparisons Converter::BuildComparisons( + clang::BlockDecl *context, clang::QualType lhs, clang::QualType rhs, + std::initializer_list traits) { + auto loc = context->getCaretLocation(); + auto operand = [&](llvm::StringRef name, clang::QualType type) { + auto reference = ctx_.getLValueReferenceType(type.withConst()); + return clang::VarDecl::Create( + ctx_, context, loc, loc, &ctx_.Idents.get(name), reference, + ctx_.getTrivialTypeSourceInfo(reference, loc), clang::SC_None); + }; + Comparisons comparisons{lhs, rhs, operand("__lhs", lhs), + operand("__rhs", rhs), {}}; + auto refer = [&](clang::VarDecl *var) -> clang::Expr * { + return clang::DeclRefExpr::Create(ctx_, {}, {}, var, false, loc, + var->getType().getNonReferenceType(), + clang::VK_LValue); }; - add(kPartiallyOrderedWith, - std::format("::{}(lhs, rhs)", - GetRecordTraitSpelling(kLessThanComparable).name, - kLessThanComparable.method)); - for (auto [kind, from_three_way] : relations) { - if (!FindComparisonOperator(ctx_, type, type, kind)) { - add(GetPartiallyOrderedWithTrait(kind), - std::format("libcc2rs::{}({}(lhs, rhs))", from_three_way, - GetThreeWayPath(cmp))); + for (const auto *trait : traits) { + for (const auto &relation : trait->relations) { + if (!comparisons.exprs.contains(relation.op)) { + comparisons.exprs.emplace( + relation.op, + BuildComparison(GetSema(), relation.op, refer(comparisons.lhs), + refer(comparisons.rhs))); + } } } + return comparisons; } -std::string Converter::GetComparisonTraitSignature( - const RecordTrait &trait, std::string_view lhs, std::string_view rhs, - std::string_view rhs_type) const { - return std::format("unsafe fn {}({}: *const Self, {}: *const {}) -> bool", - trait.method, lhs, rhs, rhs_type); +void Converter::EmitComparisonTrait(const ComparisonTrait &trait, + const Comparisons &comparisons) { + std::string name = GetRecordTraitSpelling(trait.trait).name; + if (comparisons.rhs_type != comparisons.lhs_type) { + name += std::format("<{}>", GetUnboxedTypeAsString(comparisons.rhs_type)); + } + StrCat(std::format("impl {} for {}", name, + GetUnboxedTypeAsString(comparisons.lhs_type))); + PushBrace impl_brace(*this); + for (const auto &relation : trait.relations) { + EmitComparisonMethod(relation, comparisons); + } +} + +void Converter::EmitComparisonMethod(const ComparisonRelation &relation, + const Comparisons &comparisons) { + auto *expr = comparisons.exprs.at(relation.op); + auto type = ctx_.getReferenceQualifiedType(expr); + bool is_reference = type->isReferenceType(); + if (!is_reference && UsesReturnSlot(type)) { + llvm::report_fatal_error( + "comparison results returned in a return slot are not supported"); + } + StrCat(std::format("type {} = {};", relation.result, + is_reference + ? GetReferenceMarkerAsString(type) + : GetUnboxedTypeAsString(type.getUnqualifiedType()))); + StrCat(keyword_unsafe_, keyword::kFn, relation.method); + { + PushParen params(*this); + for (auto *operand : {comparisons.lhs, comparisons.rhs}) { + StrCat(GetNamedDeclAsString(operand), token::kColon, + GetReferenceMarkerAsString(operand->getType()), token::kComma); + } + } + StrCat(token::kArrow, std::format("Self::{}", relation.result)); + PushBrace body(*this); + for (auto *operand : {comparisons.lhs, comparisons.rhs}) { + auto name = GetNamedDeclAsString(operand); + StrCat(std::format("let {} = {};", name, + GetReferredObjectPointer(name, operand->getType()))); + } + PushExprKind push(*this, ExprKind::Void); + ConvertFullExpression([&] { + HoistMaterializedTempBindings hoist_temps(*this); + StrCat(keyword::kReturn); + if (is_reference) { + StrCat(GetReferenceMarker(type->isRValueReferenceType()), "::bind"); + } + PushParen bind(*this, is_reference); + ConvertVarInit(type, expr); + }); + StrCat(token::kSemiColon); } void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 7203c1bfc4..81c1d0dba1 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -213,8 +214,6 @@ class Converter : public clang::RecursiveASTVisitor { void EmitReprC(clang::RecordDecl *decl); void EmitDerives(const clang::RecordDecl *decl); - std::string GetThreeWayPath(const clang::FunctionDecl *cmp); - virtual void EmitRustUnion(clang::RecordDecl *decl); virtual bool EmitsReprCForRecords() const { return true; } @@ -506,19 +505,28 @@ class Converter : public clang::RecursiveASTVisitor { CallInfo CollectCallInfo(clang::CallExpr *expr); - bool EmitComparisonTraitCallee(const CallInfo &info); + struct Comparisons { + clang::QualType lhs_type; + clang::QualType rhs_type; + clang::VarDecl *lhs; + clang::VarDecl *rhs; + std::unordered_map exprs; - void ConvertComparisonTraitImpl(clang::FunctionDecl *decl, - const RecordTrait &trait); + bool Has(const ComparisonTrait &trait) const; + }; - virtual std::string - GetComparisonTraitSignature(const RecordTrait &trait, std::string_view lhs, - std::string_view rhs, - std::string_view rhs_type) const; + void EmitComparisonTraits(const clang::CXXRecordDecl *decl); + + Comparisons + BuildComparisons(clang::BlockDecl *context, clang::QualType lhs, + clang::QualType rhs, + std::initializer_list traits); - void ConvertPartiallyOrderedWithImpl(const clang::CXXRecordDecl *decl); + void EmitComparisonTrait(const ComparisonTrait &trait, + const Comparisons &comparisons); - std::string GetComparisonCategory(const clang::FunctionDecl *op); + void EmitComparisonMethod(const ComparisonRelation &relation, + const Comparisons &comparisons); void ConvertParamTy(clang::QualType param_type, clang::Expr *expr); @@ -1379,13 +1387,6 @@ class Converter : public clang::RecursiveASTVisitor { static DeferredBlock &DeferredImpl(std::string header); - DeferredBlock &ComparisonTraitImpl(const RecordTrait &trait, - std::string_view self, - std::string_view other); - - void AddComparisonTraitMethod(const clang::FunctionDecl *op, - const RecordTrait &trait, - std::string_view method); static std::map> declared_record_traits_; static std::set> converted_record_traits_; diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 73719f6146..1eacd3ad0a 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -681,201 +681,44 @@ clang::QualType GetComparisonRhsType(const clang::FunctionDecl *fn) { .getCanonicalType(); } -const clang::FunctionDecl * -FindComparisonOperator(clang::ASTContext &ctx, clang::QualType lhs, - clang::QualType rhs, clang::OverloadedOperatorKind op) { - auto same = [](clang::QualType type, clang::QualType expected) { - return type.getNonReferenceType().getUnqualifiedType().getCanonicalType() == - expected; - }; - auto as_operator = - [&](const clang::NamedDecl *found) -> const clang::FunctionDecl * { +std::vector +GetComparisonOperandTypes(const clang::CXXRecordDecl *decl) { + auto &ctx = decl->getASTContext(); + clang::QualType self = ctx.getCanonicalTagType(decl); + std::vector types; + auto add = [&](const clang::NamedDecl *found) { auto *fn = clang::dyn_cast_or_null(found); - if (!fn || fn->getOverloadedOperator() != op || fn->isDeleted()) { - return nullptr; - } - if (auto *method = clang::dyn_cast(fn)) { - return method->isInstance() && method->getNumParams() == 1 && - same(ctx.getCanonicalTagType(method->getParent()), lhs) && - same(method->getParamDecl(0)->getType(), rhs) - ? fn - : nullptr; - } - return fn->getNumParams() == 2 && - same(fn->getParamDecl(0)->getType(), lhs) && - same(fn->getParamDecl(1)->getType(), rhs) - ? fn - : nullptr; - }; - auto name = ctx.DeclarationNames.getCXXOperatorName(op); - for (auto type : {lhs, rhs}) { - auto *record = type->getAsCXXRecordDecl(); - if (!record || !record->hasDefinition()) { - continue; - } - for (auto *method : record->methods()) { - if (auto *fn = as_operator(method)) { - return fn; - } + if (!fn || !IsComparisonOperator(fn) || fn->isDeleted()) { + return; } - for (auto *found : record->getDeclContext()->lookup(name)) { - if (auto *fn = as_operator(found)) { - return fn; - } + auto *record = GetComparisonRecord(fn); + if (!record || record->getCanonicalDecl() != decl->getCanonicalDecl()) { + return; } - for (auto *friend_decl : record->friends()) { - if (auto *fn = as_operator(friend_decl->getFriendDecl())) { - return fn; - } + if (auto rhs = GetComparisonRhsType(fn); + rhs != self && !llvm::is_contained(types, rhs)) { + types.push_back(rhs); } + }; + for (auto *method : decl->methods()) { + add(method); } - return nullptr; -} - -const RecordTrait & -GetPartiallyOrderedWithTrait(clang::OverloadedOperatorKind op) { - switch (op) { - case clang::OO_Less: - return kPartiallyOrderedWith; - case clang::OO_Greater: - return kPartiallyOrderedWithGreater; - case clang::OO_LessEqual: - return kPartiallyOrderedWithLessEqual; - case clang::OO_GreaterEqual: - return kPartiallyOrderedWithGreaterEqual; - default: - llvm_unreachable("not a relational operator"); - } -} - -bool IsPartiallyOrderedWithTrait(const RecordTrait &trait) { - return &trait == &kPartiallyOrderedWith || - &trait == &kPartiallyOrderedWithGreater || - &trait == &kPartiallyOrderedWithLessEqual || - &trait == &kPartiallyOrderedWithGreaterEqual; -} - -bool HasDeferredComparisonImpl(const RecordTrait &trait) { - return IsEqualityComparableTrait(trait) || IsPartiallyOrderedWithTrait(trait); -} - -bool IsPartiallyOrdered(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record) { - clang::QualType type = ctx.getCanonicalTagType(record); - auto *cmp = FindComparisonOperator(ctx, type, type, clang::OO_Spaceship); - if (cmp && ctx.CompCategories.lookupInfoForType(cmp->getReturnType())) { - return true; - } - return llvm::all_of(std::array{clang::OO_Less, clang::OO_Greater, - clang::OO_LessEqual, clang::OO_GreaterEqual}, - [&](clang::OverloadedOperatorKind op) { - return FindComparisonOperator(ctx, type, type, op); - }); -} - -static bool TakesConstReferenceOperands(const clang::FunctionDecl *fn) { - if (auto *method = clang::dyn_cast(fn); - method && (method->isVirtual() || !method->isConst() || - !method->isImplicitObjectMemberFunction() || - method->getRefQualifier() == clang::RQ_RValue)) { - return false; - } - return llvm::all_of(fn->parameters(), [](const clang::ParmVarDecl *param) { - auto type = param->getType(); - return type->isLValueReferenceType() && - type.getNonReferenceType().isConstQualified(); - }); -} - -const clang::FunctionDecl * -GetThreeWayOperator(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record) { - clang::QualType type = ctx.getCanonicalTagType(record); - auto *cmp = FindComparisonOperator(ctx, type, type, clang::OO_Spaceship); - if (!cmp || !ctx.CompCategories.lookupInfoForType(cmp->getReturnType()) || - !TakesConstReferenceOperands(cmp)) { - return nullptr; - } - return cmp; -} - -const clang::FunctionDecl * -GetDerivingThreeWayOperator(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record) { - auto *cmp = GetThreeWayOperator(ctx, record); - if (!cmp) { - return nullptr; + for (auto *friend_decl : decl->friends()) { + add(friend_decl->getFriendDecl()); } - clang::QualType type = ctx.getCanonicalTagType(record); - for (auto op : - {clang::OO_Greater, clang::OO_LessEqual, clang::OO_GreaterEqual}) { - if (FindComparisonOperator(ctx, type, type, op)) { - return nullptr; + for (auto op : {clang::OO_EqualEqual, clang::OO_ExclaimEqual, clang::OO_Less, + clang::OO_Greater, clang::OO_LessEqual, + clang::OO_GreaterEqual, clang::OO_Spaceship}) { + for (auto *found : decl->getEnclosingNamespaceContext()->lookup( + ctx.DeclarationNames.getCXXOperatorName(op))) { + add(found); } } - return cmp; -} - -const RecordTrait *GetComparisonTrait(const clang::FunctionDecl *fn) { - auto op = fn->getOverloadedOperator(); - bool is_relational = op == clang::OO_Greater || op == clang::OO_LessEqual || - op == clang::OO_GreaterEqual; - bool is_three_way = op == clang::OO_Spaceship; - if (op != clang::OO_EqualEqual && op != clang::OO_ExclaimEqual && - op != clang::OO_Less && !is_relational && !is_three_way) { - return nullptr; - } - auto *record = GetComparisonRecord(fn); - if (!record || !IsUserDefinedDecl(record) || fn->isDeleted() || - fn->getDescribedFunctionTemplate()) { - return nullptr; - } - auto &ctx = fn->getASTContext(); - if (is_three_way ? !ctx.CompCategories.lookupInfoForType(fn->getReturnType()) - : !fn->getReturnType()->isBooleanType()) { - return nullptr; - } - if (auto *method = clang::dyn_cast(fn); - method ? method->getNumParams() != 1 : fn->getNumParams() != 2) { - return nullptr; - } - if (!TakesConstReferenceOperands(fn)) { - return nullptr; - } - if (op == clang::OO_Less) { - return IsSameTypeComparison(fn, record) ? &kLessThanComparable : nullptr; - } - if (is_three_way) { - clang::QualType type = ctx.getCanonicalTagType(record); - return IsSameTypeComparison(fn, record) && - FindComparisonOperator(ctx, type, type, clang::OO_EqualEqual) - ? &kThreeWayComparable - : nullptr; - } - if (is_relational) { - return IsSameTypeComparison(fn, record) && IsPartiallyOrdered(ctx, record) - ? &GetPartiallyOrderedWithTrait(op) - : nullptr; - } - if (op == clang::OO_EqualEqual) { - return &kWeaklyEqualityComparableWith; - } - return FindComparisonOperator(ctx, ctx.getCanonicalTagType(record), - GetComparisonRhsType(fn), clang::OO_EqualEqual) - ? &kWeaklyEqualityComparableWithNotEqual - : nullptr; -} - -bool IsEqualityComparableTrait(const RecordTrait &trait) { - return &trait == &kWeaklyEqualityComparableWith || - &trait == &kWeaklyEqualityComparableWithNotEqual; + return types; } const RecordTrait *GetRecordTrait(const clang::CXXMethodDecl *method) { method = method->getCanonicalDecl(); - if (auto *trait = GetComparisonTrait(method)) { - return trait; - } if (auto *dtor = clang::dyn_cast(method)) { return IsConvertedDestructor(dtor) && !dtor->getParent()->isAbstract() ? &kDestructible @@ -934,8 +777,7 @@ bool IsDerivedCopyOrMove(const clang::CXXMethodDecl *method) { ctor && ctor->isDefaultConstructor()) { return false; } - return !method->isUserProvided() && !GetComparisonTrait(method) && - GetRecordTrait(method); + return !method->isUserProvided() && GetRecordTrait(method); } std::vector GetDerivedCopyOrMoves(const clang::RecordDecl *decl) { @@ -2099,21 +1941,6 @@ const char *GetOverloadedOperator(const clang::FunctionDecl *decl) { } } -bool IsSameTypeComparison(const clang::FunctionDecl *fn, - const clang::CXXRecordDecl *record) { - auto record_type = fn->getASTContext().getCanonicalTagType(record); - auto is_record = [&](clang::QualType type) { - return type.getNonReferenceType().getUnqualifiedType().getCanonicalType() == - record_type; - }; - if (const auto *method = clang::dyn_cast(fn)) { - return method->isInstance() && method->getNumParams() == 1 && - is_record(method->getParamDecl(0)->getType()); - } - return fn->getNumParams() == 2 && is_record(fn->getParamDecl(0)->getType()) && - is_record(fn->getParamDecl(1)->getType()); -} - bool IsImplicitAssignmentCall(const clang::CallExpr *expr) { const auto *call = clang::dyn_cast(expr); if (!call) { @@ -2469,11 +2296,50 @@ bool IsComparisonOperator(const clang::FunctionDecl *fn) { } } +namespace { +class TranslationUnitScope { +public: + explicit TranslationUnitScope(clang::Sema &sema) + : sema_(sema), + scope_(nullptr, clang::Scope::DeclScope, sema.getDiagnostics()) { + scope_.setEntity(sema.Context.getTranslationUnitDecl()); + saved_ = std::exchange(sema.TUScope, &scope_); + } + + ~TranslationUnitScope() { sema_.TUScope = saved_; } + + TranslationUnitScope(const TranslationUnitScope &) = delete; + + TranslationUnitScope &operator=(const TranslationUnitScope &) = delete; + + clang::Scope *get() { return &scope_; } + +private: + clang::Sema &sema_; + clang::Scope scope_; + clang::Scope *saved_; +}; +} // namespace + +clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, + clang::Expr *lhs, clang::Expr *rhs) { + TranslationUnitScope tu_scope(sema); + RuleDecls::Trial trial(sema); + clang::ExprResult result; + { + clang::Sema::GlobalEagerInstantiationScope instantiations( + sema, /*Enabled=*/true, /*AtEndOfTU=*/false); + result = sema.BuildBinOp(tu_scope.get(), lhs->getExprLoc(), op, lhs, rhs); + if (result.isUsable()) { + result = sema.ActOnFinishFullExpr(result.get(), /*DiscardedValue=*/false); + } + instantiations.perform(); + } + return result.isUsable() && !trial.failed() ? result.get() : nullptr; +} + void DefineImplicitMembers(clang::Sema &sema, clang::CXXRecordDecl *decl) { - clang::Scope tu_scope(nullptr, clang::Scope::DeclScope, - sema.getDiagnostics()); - tu_scope.setEntity(sema.Context.getTranslationUnitDecl()); - auto *saved_tu_scope = std::exchange(sema.TUScope, &tu_scope); + TranslationUnitScope tu_scope(sema); sema.ForceDeclarationOfImplicitMembers(decl); for (auto *field : decl->fields()) { if (field->hasInClassInitializer() && !field->getInClassInitializer()) { @@ -2560,7 +2426,6 @@ void DefineImplicitMembers(clang::Sema &sema, clang::CXXRecordDecl *decl) { define_defaulted_comparison(clang::dyn_cast_or_null( friend_decl->getFriendDecl())); } - sema.TUScope = saved_tu_scope; } bool IsEmittableMethod(clang::CXXMethodDecl *method) { diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 04bb545d5d..4104b26a21 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -169,59 +170,6 @@ inline constexpr RecordTrait kDestructible{ "destroy", {"Destructible", "fn destroy(this: Ptr)", "this.clone()"}, {"DestructibleUnsafe", "unsafe fn destroy(this: *mut Self)", "this"}}; -inline constexpr RecordTrait kWeaklyEqualityComparableWith{ - "equal", - {"WeaklyEqualityComparableWith", - "fn equal(this: Ptr, _: Ptr) -> bool", "this.clone()"}, - {"WeaklyEqualityComparableWithUnsafe", - "unsafe fn equal(this: *const Self, _: *const Self) -> bool", "this"}}; -inline constexpr RecordTrait kWeaklyEqualityComparableWithNotEqual{ - "not_equal", - {"WeaklyEqualityComparableWith", - "fn not_equal(this: Ptr, _: Ptr) -> bool", "this.clone()"}, - {"WeaklyEqualityComparableWithUnsafe", - "unsafe fn not_equal(this: *const Self, _: *const Self) -> bool", "this"}}; -inline constexpr RecordTrait kLessThanComparable{ - "less", - {"LessThanComparable", "fn less(this: Ptr, _: Ptr) -> bool", - "this.clone()"}, - {"LessThanComparableUnsafe", - "unsafe fn less(this: *const Self, _: *const Self) -> bool", "this"}}; -inline constexpr RecordTrait kPartiallyOrderedWith{ - "less", - {"PartiallyOrderedWith", "fn less(this: Ptr, _: Ptr) -> bool", - "this.clone()"}, - {"PartiallyOrderedWithUnsafe", - "unsafe fn less(this: *const Self, _: *const Self) -> bool", "this"}}; -inline constexpr RecordTrait kPartiallyOrderedWithGreater{ - "greater", - {"PartiallyOrderedWith", - "fn greater(this: Ptr, _: Ptr) -> bool", "this.clone()"}, - {"PartiallyOrderedWithUnsafe", - "unsafe fn greater(this: *const Self, _: *const Self) -> bool", "this"}}; -inline constexpr RecordTrait kPartiallyOrderedWithLessEqual{ - "less_equal", - {"PartiallyOrderedWith", - "fn less_equal(this: Ptr, _: Ptr) -> bool", "this.clone()"}, - {"PartiallyOrderedWithUnsafe", - "unsafe fn less_equal(this: *const Self, _: *const Self) -> bool", - "this"}}; -inline constexpr RecordTrait kPartiallyOrderedWithGreaterEqual{ - "greater_equal", - {"PartiallyOrderedWith", - "fn greater_equal(this: Ptr, _: Ptr) -> bool", "this.clone()"}, - {"PartiallyOrderedWithUnsafe", - "unsafe fn greater_equal(this: *const Self, _: *const Self) -> bool", - "this"}}; -inline constexpr RecordTrait kThreeWayComparable{ - "three_way", - {"ThreeWayComparable", - "fn three_way(this: Ptr, _: Ptr) -> Self::Category", - "this.clone()"}, - {"ThreeWayComparableUnsafe", - "unsafe fn three_way(this: *const Self, _: *const Self) -> " - "Self::Category", - "this"}}; inline constexpr RecordTrait kTriviallyDefaultConstructible{ nullptr, {"TriviallyDefaultConstructible"}, @@ -244,36 +192,55 @@ bool IsConstructibleFromConstructor(const clang::FunctionDecl *decl); const clang::ParmVarDecl *GetCopyOrMoveSource(const clang::FunctionDecl *decl); -const RecordTrait *GetComparisonTrait(const clang::FunctionDecl *fn); - -bool IsEqualityComparableTrait(const RecordTrait &trait); - -bool IsPartiallyOrderedWithTrait(const RecordTrait &trait); - -bool HasDeferredComparisonImpl(const RecordTrait &trait); - -const RecordTrait & -GetPartiallyOrderedWithTrait(clang::OverloadedOperatorKind op); - -bool IsPartiallyOrdered(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record); +struct ComparisonRelation { + clang::BinaryOperatorKind op; + const char *method; + const char *result; +}; -const clang::FunctionDecl * -GetThreeWayOperator(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record); +struct ComparisonTrait { + RecordTrait trait; + std::span relations; +}; -const clang::FunctionDecl * -GetDerivingThreeWayOperator(clang::ASTContext &ctx, - const clang::CXXRecordDecl *record); +inline constexpr ComparisonRelation kEqualityRelations[] = { + {clang::BO_EQ, "equal", "EqualResult"}, + {clang::BO_NE, "not_equal", "NotEqualResult"}}; +inline constexpr ComparisonRelation kLessThanRelations[] = { + {clang::BO_LT, "less", "Result"}}; +inline constexpr ComparisonRelation kOrderingRelations[] = { + {clang::BO_LT, "less", "LessResult"}, + {clang::BO_GT, "greater", "GreaterResult"}, + {clang::BO_LE, "less_equal", "LessEqualResult"}, + {clang::BO_GE, "greater_equal", "GreaterEqualResult"}}; +inline constexpr ComparisonRelation kThreeWayRelations[] = { + {clang::BO_Cmp, "three_way", "Category"}}; + +inline constexpr ComparisonTrait kWeaklyEqualityComparableWith{ + {nullptr, + {"WeaklyEqualityComparableWith"}, + {"WeaklyEqualityComparableWithUnsafe"}}, + kEqualityRelations}; +inline constexpr ComparisonTrait kLessThanComparable{ + {nullptr, {"LessThanComparable"}, {"LessThanComparableUnsafe"}}, + kLessThanRelations}; +inline constexpr ComparisonTrait kPartiallyOrderedWith{ + {nullptr, {"PartiallyOrderedWith"}, {"PartiallyOrderedWithUnsafe"}}, + kOrderingRelations}; +inline constexpr ComparisonTrait kThreeWayComparable{ + {nullptr, {"ThreeWayComparable"}, {"ThreeWayComparableUnsafe"}}, + kThreeWayRelations}; clang::QualType GetComparisonRhsType(const clang::FunctionDecl *fn); -const clang::FunctionDecl * -FindComparisonOperator(clang::ASTContext &ctx, clang::QualType lhs, - clang::QualType rhs, clang::OverloadedOperatorKind op); - const clang::CXXRecordDecl *GetComparisonRecord(const clang::FunctionDecl *fn); +std::vector +GetComparisonOperandTypes(const clang::CXXRecordDecl *decl); + +clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, + clang::Expr *lhs, clang::Expr *rhs); + // Whether method is a C++ defaulted copy or move member that is translated as // a memberwise derive of its trait, rather than from its body. bool IsDerivedCopyOrMove(const clang::CXXMethodDecl *method); @@ -511,9 +478,6 @@ clang::QualType GetDeclRefType(const clang::FunctionDecl *fn, const clang::Expr *expr, const clang::ValueDecl *decl); -bool IsSameTypeComparison(const clang::FunctionDecl *fn, - const clang::CXXRecordDecl *record); - clang::CXXDestructorDecl * GetUserDefinedDestructor(const clang::CXXRecordDecl *decl); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 0e313bc7f1..4349f387cc 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -646,13 +646,6 @@ bool ConverterRefCount::VisitOffsetOfExpr(clang::OffsetOfExpr *expr) { return false; } -std::string ConverterRefCount::GetComparisonTraitSignature( - const RecordTrait &trait, std::string_view lhs, std::string_view rhs, - std::string_view rhs_type) const { - return std::format("fn {}({}: Ptr, {}: Ptr<{}>) -> bool", trait.method, - lhs, rhs, rhs_type); -} - // Whether decl is copied by copying its bytes or the pointers it holds. static bool IsClonedShallowly(const clang::RecordDecl *decl) { return decl->isUnion() || (HasDefaultedCopyConstructor(decl) && diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 06524716dc..83c2a7fb5f 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -52,11 +52,6 @@ class ConverterRefCount final : public Converter { const char *CharRustType() const override { return "i8"; } - std::string - GetComparisonTraitSignature(const RecordTrait &trait, std::string_view lhs, - std::string_view rhs, - std::string_view rhs_type) const override; - bool RecordImplementsClone(const clang::RecordDecl *decl) override; bool RecordDerivesClone(const clang::RecordDecl *decl); diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index 36fb266af7..cfc75e1e79 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -12,7 +12,6 @@ mod fn_ptr_arg; mod goto; mod initialization; mod lambda; -mod partially_ordered; mod record; mod state_machine; mod switch; @@ -361,22 +360,3 @@ pub fn derive_destructible_unsafe(input: TokenStream) -> TokenStream { destructor::expand(input, true) } -#[proc_macro_derive(LessThanComparable, attributes(three_way))] -pub fn derive_less_than_comparable(input: TokenStream) -> TokenStream { - partially_ordered::expand_less_than_comparable(input, false) -} - -#[proc_macro_derive(LessThanComparableUnsafe, attributes(three_way))] -pub fn derive_less_than_comparable_unsafe(input: TokenStream) -> TokenStream { - partially_ordered::expand_less_than_comparable(input, true) -} - -#[proc_macro_derive(PartiallyOrderedWith, attributes(three_way))] -pub fn derive_partially_ordered_with(input: TokenStream) -> TokenStream { - partially_ordered::expand(input, false) -} - -#[proc_macro_derive(PartiallyOrderedWithUnsafe, attributes(three_way))] -pub fn derive_partially_ordered_with_unsafe(input: TokenStream) -> TokenStream { - partially_ordered::expand(input, true) -} diff --git a/libcc2rs-macros/src/partially_ordered.rs b/libcc2rs-macros/src/partially_ordered.rs deleted file mode 100644 index 98fb9c3181..0000000000 --- a/libcc2rs-macros/src/partially_ordered.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2022-present INESC-ID. -// Distributed under the MIT license that can be found in the LICENSE file. - -use proc_macro::TokenStream; -use quote::quote; -use syn::{DeriveInput, parse_macro_input}; - -fn three_way_path(input: &DeriveInput) -> syn::Path { - input - .attrs - .iter() - .find(|attr| attr.path().is_ident("three_way")) - .expect("three_way(path) names the operator<=> of the type") - .parse_args() - .expect("three_way(path)") -} - -pub fn expand_less_than_comparable(input: TokenStream, is_unsafe: bool) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let three_way = three_way_path(&input); - if is_unsafe { - return quote! { - impl #impl_generics ::libcc2rs::LessThanComparableUnsafe for #name #ty_generics #where_clause { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - ::libcc2rs::is_lt(unsafe { #three_way(this, rhs) }) - } - } - } - .into(); - } - quote! { - impl #impl_generics ::libcc2rs::LessThanComparable for #name #ty_generics #where_clause { - fn less(this: ::libcc2rs::Ptr, rhs: ::libcc2rs::Ptr) -> bool { - ::libcc2rs::is_lt(#three_way(this, rhs)) - } - } - } - .into() -} - -pub fn expand(input: TokenStream, is_unsafe: bool) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let three_way = three_way_path(&input); - let relations = [ - (quote!(greater), quote!(is_gt)), - (quote!(less_equal), quote!(is_lteq)), - (quote!(greater_equal), quote!(is_gteq)), - ]; - if is_unsafe { - let methods = relations.iter().map(|(method, relation)| { - quote! { - unsafe fn #method(this: *const Self, rhs: *const Self) -> bool { - ::libcc2rs::#relation(unsafe { #three_way(this, rhs) }) - } - } - }); - return quote! { - impl #impl_generics ::libcc2rs::PartiallyOrderedWithUnsafe for #name #ty_generics #where_clause { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - unsafe { ::less(this, rhs) } - } - #(#methods)* - } - } - .into(); - } - let methods = relations.iter().map(|(method, relation)| { - quote! { - fn #method(this: ::libcc2rs::Ptr, rhs: ::libcc2rs::Ptr) -> bool { - ::libcc2rs::#relation(#three_way(this, rhs)) - } - } - }); - quote! { - impl #impl_generics ::libcc2rs::PartiallyOrderedWith for #name #ty_generics #where_clause { - fn less(this: ::libcc2rs::Ptr, rhs: ::libcc2rs::Ptr) -> bool { - ::less(this, rhs) - } - #(#methods)* - } - } - .into() -} diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index c6875abcf7..fbb968a679 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -6,43 +6,62 @@ use std::cmp::Ordering; +use crate::overload::{ConvertibleTo, ConvertibleToUnsafe}; use crate::rc::{AsPointer, Ptr, Value}; +use crate::reference::{Const, LvalueRef, LvalueRefUnsafe}; use crate::reinterpret::ByteRepr; -pub trait LessThanComparable: Sized { - fn less(this: Ptr, rhs: Ptr) -> bool; +pub trait BooleanTestable: ConvertibleTo {} + +impl> BooleanTestable for T {} + +pub trait BooleanTestableUnsafe: ConvertibleToUnsafe {} + +impl> BooleanTestableUnsafe for T {} + +pub trait LessThanComparable: ByteRepr + Sized { + type Result: BooleanTestable; + + fn less(a: LvalueRef>, b: LvalueRef>) -> Self::Result; } pub trait LessThanComparableUnsafe: Sized { + type Result: BooleanTestableUnsafe; + /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn less(this: *const Self, rhs: *const Self) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) + -> Self::Result; } -// TODO: equal and not_equal return a boolean-testable type in C++ -// ([concept.booleantestable]); replace bool with BooleanTestable. pub trait WeaklyEqualityComparableWith = Self>: - Sized + ByteRepr + Sized { - fn equal(this: Ptr, rhs: Ptr) -> bool; + type EqualResult: BooleanTestable; + type NotEqualResult: BooleanTestable; - fn not_equal(this: Ptr, rhs: Ptr) -> bool { - !Self::equal(this, rhs) - } + fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult; + + fn not_equal(a: LvalueRef>, b: LvalueRef>) -> Self::NotEqualResult; } pub trait WeaklyEqualityComparableWithUnsafe = Self>: Sized { + type EqualResult: BooleanTestableUnsafe; + type NotEqualResult: BooleanTestableUnsafe; + /// # Safety - /// `rhs` must point to a live value. - unsafe fn equal(this: *const Self, rhs: *const U) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) + -> Self::EqualResult; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn not_equal(this: *const Self, rhs: *const U) -> bool { - unsafe { !Self::equal(this, rhs) } - } + /// `a` and `b` must refer to live values. + unsafe fn not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::NotEqualResult; } pub trait EqualityComparable: WeaklyEqualityComparableWith {} @@ -84,8 +103,13 @@ macro_rules! impl_less_than_comparable { where $ty: PartialOrd + $crate::ByteRepr, { - fn less(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a < b)) + type Result = bool; + + fn less( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a < b)) } } )*}; @@ -97,8 +121,13 @@ macro_rules! impl_less_than_comparable_unsafe { where $ty: PartialOrd, { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this < *rhs } + type Result = bool; + + unsafe fn less( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() < *b.as_const_ptr() } } } )*}; @@ -116,15 +145,23 @@ impl_less_than_comparable_unsafe!( *mut T, *const T, ); -impl LessThanComparable for Vec { - fn less(this: Ptr, rhs: Ptr) -> bool { - let (m, n) = (this.with(Vec::len), rhs.with(Vec::len)); - let (a, b) = (this.decay(), rhs.decay()); +impl LessThanComparable for Vec +where + Self: ByteRepr, +{ + type Result = bool; + + fn less(a: LvalueRef>, b: LvalueRef>) -> bool { + let (a, b) = (a.as_pointer(), b.as_pointer()); + let (m, n) = (a.with(Vec::len), b.with(Vec::len)); + let (a, b) = (a.decay(), b.decay()); for i in 0..m.min(n) { - if T::less(a.offset(i), b.offset(i)) { + let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); + if ConvertibleTo::::convert_value(T::less(x, y)) { return true; } - if T::less(b.offset(i), a.offset(i)) { + let (x, y) = (LvalueRef::bind(b.offset(i)), LvalueRef::bind(a.offset(i))); + if ConvertibleTo::::convert_value(T::less(x, y)) { return false; } } @@ -132,18 +169,20 @@ impl LessThanComparable for Vec { } } -impl LessThanComparable for Box<[T]> { - fn less(this: Ptr, rhs: Ptr) -> bool { - let (m, n) = ( - this.with(|elems| elems.len()), - rhs.with(|elems| elems.len()), - ); - let (a, b) = (this.decay(), rhs.decay()); +impl LessThanComparable for Box<[T]> { + type Result = bool; + + fn less(a: LvalueRef>, b: LvalueRef>) -> bool { + let (a, b) = (a.as_pointer(), b.as_pointer()); + let (m, n) = (a.with(|elems| elems.len()), b.with(|elems| elems.len())); + let (a, b) = (a.decay(), b.decay()); for i in 0..m.min(n) { - if T::less(a.offset(i), b.offset(i)) { + let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); + if ConvertibleTo::::convert_value(T::less(x, y)) { return true; } - if T::less(b.offset(i), a.offset(i)) { + let (x, y) = (LvalueRef::bind(b.offset(i)), LvalueRef::bind(a.offset(i))); + if ConvertibleTo::::convert_value(T::less(x, y)) { return false; } } @@ -155,29 +194,43 @@ impl LessThanComparable for (Value where Self: ByteRepr, { - fn less(this: Ptr, rhs: Ptr) -> bool { + type Result = bool; + + fn less(a: LvalueRef>, b: LvalueRef>) -> bool { let pointers = |pair: &Self| { ( AsPointer::::as_pointer(&pair.0), AsPointer::::as_pointer(&pair.1), ) }; - let (a0, a1) = this.with(pointers); - let (b0, b1) = rhs.with(pointers); - A::less(a0.clone(), b0.clone()) || (!A::less(b0, a0) && B::less(a1, b1)) + let (a0, a1) = a.as_pointer().with(pointers); + let (b0, b1) = b.as_pointer().with(pointers); + let (x, y) = (LvalueRef::bind(a0.clone()), LvalueRef::bind(b0.clone())); + if ConvertibleTo::::convert_value(A::less(x, y)) { + return true; + } + if ConvertibleTo::::convert_value(A::less(LvalueRef::bind(b0), LvalueRef::bind(a0))) { + return false; + } + ConvertibleTo::::convert_value(B::less(LvalueRef::bind(a1), LvalueRef::bind(b1))) } } impl LessThanComparableUnsafe for Vec { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { + type Result = bool; + + unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { - let (m, n) = ((*this).len(), (*rhs).len()); - let (a, b) = ((*this).as_ptr(), (*rhs).as_ptr()); + let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); + let (m, n) = ((*a).len(), (*b).len()); + let (a, b) = ((*a).as_ptr(), (*b).as_ptr()); for i in 0..m.min(n) { - if T::less(a.add(i), b.add(i)) { + let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return true; } - if T::less(b.add(i), a.add(i)) { + let (x, y) = (LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i))); + if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return false; } } @@ -187,14 +240,18 @@ impl LessThanComparableUnsafe for Vec { } impl LessThanComparableUnsafe for [T; N] { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - let (a, b) = (this as *const T, rhs as *const T); + type Result = bool; + + unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); for i in 0..N { unsafe { - if T::less(a.add(i), b.add(i)) { + let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return true; } - if T::less(b.add(i), a.add(i)) { + let (x, y) = (LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i))); + if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return false; } } @@ -204,11 +261,23 @@ impl LessThanComparableUnsafe for [ } impl LessThanComparableUnsafe for (A, B) { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { + type Result = bool; + + unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { - A::less(&raw const (*this).0, &raw const (*rhs).0) - || (!A::less(&raw const (*rhs).0, &raw const (*this).0) - && B::less(&raw const (*this).1, &raw const (*rhs).1)) + let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); + let (a0, b0) = (&raw const (*a).0, &raw const (*b).0); + let (a1, b1) = (&raw const (*a).1, &raw const (*b).1); + let (x, y) = (LvalueRefUnsafe::bind(a0), LvalueRefUnsafe::bind(b0)); + if ConvertibleToUnsafe::::convert_value(A::less(x, y)) { + return true; + } + let (x, y) = (LvalueRefUnsafe::bind(b0), LvalueRefUnsafe::bind(a0)); + if ConvertibleToUnsafe::::convert_value(A::less(x, y)) { + return false; + } + let (x, y) = (LvalueRefUnsafe::bind(a1), LvalueRefUnsafe::bind(b1)); + ConvertibleToUnsafe::::convert_value(B::less(x, y)) } } } @@ -219,8 +288,21 @@ macro_rules! impl_weakly_equality_comparable_with { where $ty: PartialEq + $crate::ByteRepr, { - fn equal(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a == b)) + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a == b)) + } + + fn not_equal( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a != b)) } } )*}; @@ -232,8 +314,21 @@ macro_rules! impl_weakly_equality_comparable_with_unsafe { where $ty: PartialEq, { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this == *rhs } + type EqualResult = bool; + type NotEqualResult = bool; + + unsafe fn equal( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() == *b.as_const_ptr() } + } + + unsafe fn not_equal( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() != *b.as_const_ptr() } } } )*}; @@ -245,19 +340,50 @@ impl_weakly_equality_comparable_with!( Ptr, Option, ); -impl WeaklyEqualityComparableWith for Vec { - fn equal(this: Ptr, rhs: Ptr) -> bool { - let len = this.with(Vec::len); - let (a, b) = (this.decay(), rhs.decay()); - len == rhs.with(Vec::len) && (0..len).all(|i| T::equal(a.offset(i), b.offset(i))) +impl WeaklyEqualityComparableWith for Vec +where + Self: ByteRepr, +{ + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { + let (a, b) = (a.as_pointer(), b.as_pointer()); + let len = a.with(Vec::len); + if len != b.with(Vec::len) { + return false; + } + let (a, b) = (a.decay(), b.decay()); + (0..len).all(|i| { + let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); + ConvertibleTo::::convert_value(T::equal(x, y)) + }) + } + + fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::equal(a, b) } } -impl WeaklyEqualityComparableWith for Box<[T]> { - fn equal(this: Ptr, rhs: Ptr) -> bool { - let len = this.with(|elems| elems.len()); - let (a, b) = (this.decay(), rhs.decay()); - len == rhs.with(|elems| elems.len()) && (0..len).all(|i| T::equal(a.offset(i), b.offset(i))) +impl WeaklyEqualityComparableWith for Box<[T]> { + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { + let (a, b) = (a.as_pointer(), b.as_pointer()); + let len = a.with(|elems| elems.len()); + if len != b.with(|elems| elems.len()) { + return false; + } + let (a, b) = (a.decay(), b.decay()); + (0..len).all(|i| { + let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); + ConvertibleTo::::convert_value(T::equal(x, y)) + }) + } + + fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::equal(a, b) } } @@ -266,16 +392,27 @@ impl WeaklyEqualityComparableWith where Self: ByteRepr, { - fn equal(this: Ptr, rhs: Ptr) -> bool { + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { let pointers = |pair: &Self| { ( AsPointer::::as_pointer(&pair.0), AsPointer::::as_pointer(&pair.1), ) }; - let (a0, a1) = this.with(pointers); - let (b0, b1) = rhs.with(pointers); - A::equal(a0, b0) && B::equal(a1, b1) + let (a0, a1) = a.as_pointer().with(pointers); + let (b0, b1) = b.as_pointer().with(pointers); + let (x, y) = (LvalueRef::bind(a0), LvalueRef::bind(b0)); + if !ConvertibleTo::::convert_value(A::equal(x, y)) { + return false; + } + ConvertibleTo::::convert_value(B::equal(LvalueRef::bind(a1), LvalueRef::bind(b1))) + } + + fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::equal(a, b) } } @@ -286,52 +423,116 @@ impl_weakly_equality_comparable_with_unsafe!( ); impl WeaklyEqualityComparableWithUnsafe for Vec { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { + type EqualResult = bool; + type NotEqualResult = bool; + + unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { - let (len, a, b) = ((*this).len(), (*this).as_ptr(), (*rhs).as_ptr()); - len == (*rhs).len() && (0..len).all(|i| T::equal(a.add(i), b.add(i))) + let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); + let len = (*a).len(); + if len != (*b).len() { + return false; + } + let (a, b) = ((*a).as_ptr(), (*b).as_ptr()); + (0..len).all(|i| { + let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + ConvertibleToUnsafe::::convert_value(T::equal(x, y)) + }) } } + + unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe { !Self::equal(a, b) } + } } impl WeaklyEqualityComparableWithUnsafe for [T; N] { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { - let (a, b) = (this as *const T, rhs as *const T); - (0..N).all(|i| unsafe { T::equal(a.add(i), b.add(i)) }) + type EqualResult = bool; + type NotEqualResult = bool; + + unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); + (0..N).all(|i| unsafe { + let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + ConvertibleToUnsafe::::convert_value(T::equal(x, y)) + }) + } + + unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe { !Self::equal(a, b) } } } impl WeaklyEqualityComparableWithUnsafe for (A, B) { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { + type EqualResult = bool; + type NotEqualResult = bool; + + unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { - A::equal(&raw const (*this).0, &raw const (*rhs).0) - && B::equal(&raw const (*this).1, &raw const (*rhs).1) + let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); + let (x, y) = ( + LvalueRefUnsafe::bind(&raw const (*a).0), + LvalueRefUnsafe::bind(&raw const (*b).0), + ); + if !ConvertibleToUnsafe::::convert_value(A::equal(x, y)) { + return false; + } + let (x, y) = ( + LvalueRefUnsafe::bind(&raw const (*a).1), + LvalueRefUnsafe::bind(&raw const (*b).1), + ); + ConvertibleToUnsafe::::convert_value(B::equal(x, y)) } } + + unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe { !Self::equal(a, b) } + } } -pub trait PartiallyOrderedWith = Self>: Sized { - fn less(this: Ptr, rhs: Ptr) -> bool; - fn greater(this: Ptr, rhs: Ptr) -> bool; - fn less_equal(this: Ptr, rhs: Ptr) -> bool; - fn greater_equal(this: Ptr, rhs: Ptr) -> bool; +pub trait PartiallyOrderedWith = Self>: ByteRepr + Sized { + type LessResult: BooleanTestable; + type GreaterResult: BooleanTestable; + type LessEqualResult: BooleanTestable; + type GreaterEqualResult: BooleanTestable; + + fn less(a: LvalueRef>, b: LvalueRef>) -> Self::LessResult; + fn greater(a: LvalueRef>, b: LvalueRef>) -> Self::GreaterResult; + fn less_equal(a: LvalueRef>, b: LvalueRef>) -> Self::LessEqualResult; + fn greater_equal(a: LvalueRef>, b: LvalueRef>) + -> Self::GreaterEqualResult; } pub trait PartiallyOrderedWithUnsafe = Self>: Sized { + type LessResult: BooleanTestableUnsafe; + type GreaterResult: BooleanTestableUnsafe; + type LessEqualResult: BooleanTestableUnsafe; + type GreaterEqualResult: BooleanTestableUnsafe; + /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn less(this: *const Self, rhs: *const U) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) + -> Self::LessResult; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn greater(this: *const Self, rhs: *const U) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn greater( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::GreaterResult; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn less_equal(this: *const Self, rhs: *const U) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn less_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::LessEqualResult; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn greater_equal(this: *const Self, rhs: *const U) -> bool; + /// `a` and `b` must refer to live values. + unsafe fn greater_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult; } pub trait TotallyOrdered: EqualityComparable + PartiallyOrderedWith {} @@ -379,17 +580,34 @@ macro_rules! impl_partially_ordered_with { where $ty: PartialOrd + $crate::ByteRepr, { - fn less(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a < b)) + type LessResult = bool; + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; + + fn less( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a < b)) } - fn greater(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a > b)) + fn greater( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a > b)) } - fn less_equal(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a <= b)) + fn less_equal( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a <= b)) } - fn greater_equal(this: $crate::Ptr, rhs: $crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a >= b)) + fn greater_equal( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a >= b)) } } )*}; @@ -401,17 +619,34 @@ macro_rules! impl_partially_ordered_with_unsafe { where $ty: PartialOrd, { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this < *rhs } + type LessResult = bool; + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; + + unsafe fn less( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() < *b.as_const_ptr() } } - unsafe fn greater(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this > *rhs } + unsafe fn greater( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() > *b.as_const_ptr() } } - unsafe fn less_equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this <= *rhs } + unsafe fn less_equal( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() <= *b.as_const_ptr() } } - unsafe fn greater_equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { *this >= *rhs } + unsafe fn greater_equal( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> bool { + unsafe { *a.as_const_ptr() >= *b.as_const_ptr() } } } )*}; @@ -432,7 +667,7 @@ impl_partially_ordered_with_unsafe!( pub trait ThreeWayComparable: EqualityComparable + PartiallyOrderedWith { type Category: Into; - fn three_way(this: Ptr, rhs: Ptr) -> Self::Category; + fn three_way(a: LvalueRef>, b: LvalueRef>) -> Self::Category; } pub trait ThreeWayComparableUnsafe: @@ -441,8 +676,11 @@ pub trait ThreeWayComparableUnsafe: type Category: Into; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn three_way(this: *const Self, rhs: *const Self) -> Self::Category; + /// `a` and `b` must refer to live values. + unsafe fn three_way( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::Category; } pub trait ThreeWayComparableWith< @@ -454,7 +692,7 @@ pub trait ThreeWayComparableWith< { type CategoryWith: Into; - fn three_way_with(this: Ptr, rhs: Ptr) -> Self::CategoryWith; + fn three_way_with(a: LvalueRef>, b: LvalueRef>) -> Self::CategoryWith; } pub trait ThreeWayComparableWithUnsafe< @@ -468,23 +706,29 @@ pub trait ThreeWayComparableWithUnsafe< type CategoryWith: Into; /// # Safety - /// `this` and `rhs` must point to live values. - unsafe fn three_way_with(this: *const Self, rhs: *const U) -> Self::CategoryWith; + /// `a` and `b` must refer to live values. + unsafe fn three_way_with( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::CategoryWith; } impl ThreeWayComparableWith for T { type CategoryWith = T::Category; - fn three_way_with(this: Ptr, rhs: Ptr) -> Self::CategoryWith { - T::three_way(this, rhs) + fn three_way_with(a: LvalueRef>, b: LvalueRef>) -> Self::CategoryWith { + T::three_way(a, b) } } impl ThreeWayComparableWithUnsafe for T { type CategoryWith = T::Category; - unsafe fn three_way_with(this: *const Self, rhs: *const Self) -> Self::CategoryWith { - unsafe { T::three_way(this, rhs) } + unsafe fn three_way_with( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::CategoryWith { + unsafe { T::three_way(a, b) } } } @@ -499,8 +743,12 @@ macro_rules! impl_three_way_comparable { { type Category = $crate::$category; - fn three_way(this: $crate::Ptr, rhs: $crate::Ptr) -> Self::Category { - this.with(|a| rhs.with(|b| $crate::$category::from($order::$compare(a, b)))) + fn three_way( + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) -> Self::Category { + let (a, b) = (a.as_pointer(), b.as_pointer()); + a.with(|a| b.with(|b| $crate::$category::from($order::$compare(a, b)))) } } )*}; @@ -514,8 +762,12 @@ macro_rules! impl_three_way_comparable_unsafe { { type Category = $crate::$category; - unsafe fn three_way(this: *const Self, rhs: *const Self) -> Self::Category { - unsafe { $crate::$category::from($order::$compare(&*this, &*rhs)) } + unsafe fn three_way( + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> Self::Category { + let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); + unsafe { $crate::$category::from($order::$compare(&*a, &*b)) } } } )*}; @@ -541,9 +793,12 @@ impl_three_way_comparable_unsafe!(PartialOrdering, PartialOrd::partial_cmp, <> f // The order of two values that std::sort and std::map derive from operator<. pub fn cpp_cmp(lhs: &Ptr, rhs: &Ptr) -> Ordering { - if T::less(lhs.clone(), rhs.clone()) { - Ordering::Less - } else if T::less(rhs.clone(), lhs.clone()) { + let (x, y) = (LvalueRef::bind(lhs.clone()), LvalueRef::bind(rhs.clone())); + if ConvertibleTo::::convert_value(T::less(x, y)) { + return Ordering::Less; + } + let (x, y) = (LvalueRef::bind(rhs.clone()), LvalueRef::bind(lhs.clone())); + if ConvertibleTo::::convert_value(T::less(x, y)) { Ordering::Greater } else { Ordering::Equal diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index c149582224..d627365b88 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -494,14 +494,40 @@ impl PartialEq for FnPtr { impl Eq for FnPtr {} impl crate::WeaklyEqualityComparableWith for FnPtr { - fn equal(this: crate::Ptr, rhs: crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| a.addr == b.addr)) + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal( + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a.addr == b.addr)) + } + + fn not_equal( + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| a.addr != b.addr)) } } impl crate::WeaklyEqualityComparableWithUnsafe for FnPtr { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { (*this).addr == (*rhs).addr } + type EqualResult = bool; + type NotEqualResult = bool; + + unsafe fn equal( + a: crate::LvalueRefUnsafe>, + b: crate::LvalueRefUnsafe>, + ) -> bool { + unsafe { (*a.as_const_ptr()).addr == (*b.as_const_ptr()).addr } + } + + unsafe fn not_equal( + a: crate::LvalueRefUnsafe>, + b: crate::LvalueRefUnsafe>, + ) -> bool { + unsafe { (*a.as_const_ptr()).addr != (*b.as_const_ptr()).addr } } } diff --git a/libcc2rs/src/lib.rs b/libcc2rs/src/lib.rs index a2b4d2757c..3531679c1b 100644 --- a/libcc2rs/src/lib.rs +++ b/libcc2rs/src/lib.rs @@ -140,10 +140,9 @@ pub use libcc2rs_macros::{ ByteRepr, Conversions, ConversionsUnsafe, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, Copyable, CopyableUnsafe, DefaultConstructible, DefaultConstructibleUnsafe, DefaultInitializable, DefaultInitializableUnsafe, Destructible, - DestructibleUnsafe, FnPtrArg, LessThanComparable, LessThanComparableUnsafe, Memberwise, - MemberwiseUnsafe, Movable, MovableUnsafe, MoveAssignable, MoveAssignableUnsafe, - MoveConstructible, MoveConstructibleUnsafe, PartiallyOrderedWith, PartiallyOrderedWithUnsafe, - Record, Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, + DestructibleUnsafe, FnPtrArg, Memberwise, MemberwiseUnsafe, Movable, MovableUnsafe, + MoveAssignable, MoveAssignableUnsafe, MoveConstructible, MoveConstructibleUnsafe, Record, + Swappable, SwappableUnsafe, TriviallyCopyable, TriviallyCopyableUnsafe, TriviallyDefaultConstructible, TriviallyDefaultConstructibleUnsafe, VaArg, ZeroInitialization, ZeroInitializationUnsafe, assign, assign_unsafe, goto, goto_block, lambda, lambda_unsafe, switch, diff --git a/libcc2rs/src/overload.rs b/libcc2rs/src/overload.rs index 64ec858b70..71f7440e2e 100644 --- a/libcc2rs/src/overload.rs +++ b/libcc2rs/src/overload.rs @@ -118,6 +118,17 @@ impl ConstructibleFrom for T { pub trait ConvertibleTo: Sized { fn convert(self, to: Ptr); + + fn convert_value(self) -> To + where + To: crate::TriviallyCopyable + crate::ZeroInitialization, + { + let to: crate::rc::Value = std::rc::Rc::new(std::cell::RefCell::new( + ::zero_init(), + )); + self.convert(crate::rc::AsPointer::::as_pointer(&to)); + crate::rc::AsPointer::::as_pointer(&to).read() + } } impl ConvertibleTo for From { @@ -142,6 +153,19 @@ pub trait ConvertibleToUnsafe: Sized { /// # Safety /// `to` is storage for an object, and `self` refers to a live object. unsafe fn convert(self, to: *mut To); + + /// # Safety + /// `self` refers to a live object. + unsafe fn convert_value(self) -> To + where + To: crate::TriviallyCopyableUnsafe + crate::ZeroInitializationUnsafe, + { + unsafe { + let mut to = ::zero_init(); + self.convert(&raw mut to); + to + } + } } impl ConvertibleToUnsafe for From { @@ -151,45 +175,67 @@ impl ConvertibleToUnsafe for From } pub trait AsArg { - fn as_arg(&self) -> Arg; + fn as_arg(self) -> Arg; +} + +impl AsArg for T { + fn as_arg(self) -> Arg { + let object: crate::rc::Value = std::rc::Rc::new(std::cell::RefCell::new(self)); + let ptr = crate::rc::AsPointer::::as_pointer(&object); + Arg { + owner: Some(Box::new(object)), + ..Arg::rvalue(ptr) + } + } } impl AsArg for LvalueRef { - fn as_arg(&self) -> Arg { + fn as_arg(self) -> Arg { Arg::lvalue(self.as_pointer()) } } impl AsArg for LvalueRef> { - fn as_arg(&self) -> Arg { + fn as_arg(self) -> Arg { Arg::const_lvalue(self.as_pointer()) } } impl AsArg for RvalueRef { - fn as_arg(&self) -> Arg { + fn as_arg(self) -> Arg { Arg::rvalue(self.as_pointer()) } } pub trait AsArgUnsafe { - fn as_arg(&self) -> Arg<*mut c_void>; + fn as_arg(self) -> Arg<*mut c_void>; +} + +impl AsArgUnsafe for T { + fn as_arg(self) -> Arg<*mut c_void> { + let mut object = Box::new(self); + let ptr: *mut T = &raw mut *object; + Arg { + owner: Some(object), + ..Arg::rvalue_unsafe(ptr) + } + } } impl AsArgUnsafe for LvalueRefUnsafe { - fn as_arg(&self) -> Arg<*mut c_void> { + fn as_arg(self) -> Arg<*mut c_void> { Arg::lvalue_unsafe(self.as_ptr()) } } impl AsArgUnsafe for LvalueRefUnsafe> { - fn as_arg(&self) -> Arg<*mut c_void> { + fn as_arg(self) -> Arg<*mut c_void> { Arg::const_lvalue_unsafe(self.as_const_ptr()) } } impl AsArgUnsafe for RvalueRefUnsafe { - fn as_arg(&self) -> Arg<*mut c_void> { + fn as_arg(self) -> Arg<*mut c_void> { Arg::rvalue_unsafe(self.as_ptr()) } } @@ -435,18 +481,18 @@ impl ParameterUnsafe for RvalueRefUnsafe> { } pub trait ArgList { - fn as_args(&self) -> Vec>; + fn as_args(self) -> Vec>; } pub trait ArgListUnsafe { - fn as_args(&self) -> Vec>; + fn as_args(self) -> Vec>; } macro_rules! arg_list { ($($name:ident),*) => { impl<$($name: AsArg),*> ArgList for ($($name,)*) { #[allow(non_snake_case, clippy::vec_init_then_push)] - fn as_args(&self) -> Vec> { + fn as_args(self) -> Vec> { let ($($name,)*) = self; vec![$($name.as_arg()),*] } @@ -454,7 +500,7 @@ macro_rules! arg_list { impl<$($name: AsArgUnsafe),*> ArgListUnsafe for ($($name,)*) { #[allow(non_snake_case, clippy::vec_init_then_push)] - fn as_args(&self) -> Vec> { + fn as_args(self) -> Vec> { let ($($name,)*) = self; vec![$($name.as_arg()),*] } @@ -474,6 +520,7 @@ pub struct Arg

{ pub table: fn() -> Table

, pub category: Category, pub ptr: P, + pub owner: Option>, } impl Arg<*mut c_void> { @@ -494,6 +541,7 @@ impl Arg<*mut c_void> { table: T::table, category, ptr: ptr.cast(), + owner: None, } } } @@ -516,6 +564,7 @@ impl Arg { table: T::table, category, ptr: ptr.to_any(), + owner: None, } } } diff --git a/libcc2rs/src/reference.rs b/libcc2rs/src/reference.rs index 182e238984..3a73830ca3 100644 --- a/libcc2rs/src/reference.rs +++ b/libcc2rs/src/reference.rs @@ -125,10 +125,24 @@ macro_rules! reference { where T::Object: crate::WeaklyEqualityComparableWith + ByteRepr, { - fn equal(this: Ptr, rhs: Ptr) -> bool { + type EqualResult = ::EqualResult; + type NotEqualResult = + ::NotEqualResult; + + fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult { ::equal( - this.with(|r| r.0.clone()), - rhs.with(|r| r.0.clone()), + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), + ) + } + + fn not_equal( + a: LvalueRef>, + b: LvalueRef>, + ) -> Self::NotEqualResult { + ::not_equal( + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) } } @@ -137,10 +151,12 @@ macro_rules! reference { where T::Object: crate::LessThanComparable + ByteRepr, { - fn less(this: Ptr, rhs: Ptr) -> bool { + type Result = ::Result; + + fn less(a: LvalueRef>, b: LvalueRef>) -> Self::Result { ::less( - this.with(|r| r.0.clone()), - rhs.with(|r| r.0.clone()), + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) } } @@ -271,30 +287,96 @@ macro_rules! reference_unsafe { impl crate::WeaklyEqualityComparableWithUnsafe for $name { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { T::equal((*this).as_ptr().cast::(), (*rhs).as_ptr().cast::()) } + type EqualResult = T::EqualResult; + type NotEqualResult = T::NotEqualResult; + + unsafe fn equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::EqualResult { + unsafe { + T::equal( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + unsafe { + T::not_equal( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } } } impl crate::WeaklyEqualityComparableWithUnsafe for $name> { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { - unsafe { T::equal((*this).as_ptr().cast::(), (*rhs).as_ptr().cast::()) } + type EqualResult = T::EqualResult; + type NotEqualResult = T::NotEqualResult; + + unsafe fn equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::EqualResult { + unsafe { + T::equal( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + unsafe { + T::not_equal( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } } } impl crate::LessThanComparableUnsafe for $name { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - unsafe { T::less((*this).as_ptr().cast::(), (*rhs).as_ptr().cast::()) } + type Result = T::Result; + + unsafe fn less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::Result { + unsafe { + T::less( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } } } impl crate::LessThanComparableUnsafe for $name> { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { - unsafe { T::less((*this).as_ptr().cast::(), (*rhs).as_ptr().cast::()) } + type Result = T::Result; + + unsafe fn less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::Result { + unsafe { + T::less( + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } } } }; diff --git a/libcc2rs/src/void.rs b/libcc2rs/src/void.rs index e5dba00b77..2466da31c0 100644 --- a/libcc2rs/src/void.rs +++ b/libcc2rs/src/void.rs @@ -149,8 +149,21 @@ impl PartialEq for AnyPtr { } impl crate::WeaklyEqualityComparableWith for AnyPtr { - fn equal(this: crate::Ptr, rhs: crate::Ptr) -> bool { - this.with(|a| rhs.with(|b| *a.ptr == *b.ptr)) + type EqualResult = bool; + type NotEqualResult = bool; + + fn equal( + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| *a.ptr == *b.ptr)) + } + + fn not_equal( + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) -> bool { + a.as_pointer().with(|a| b.as_pointer().with(|b| *a.ptr != *b.ptr)) } } diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index f5fde68c92..c0a13f2128 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -9,6 +9,7 @@ use std::rc::Rc; fn f1, T2: LessThanComparable + Clone + ByteRepr>(a0: T1, a1: T1) { let __n = a1.iter_distance(&a0); let mut __order: Vec = (0..__n).collect(); + // TODO: C++ sort calls operator< once per comparison; this calls it twice. __order.sort_by(|&__x, &__y| cpp_cmp(&a0.iter_at(__x), &a0.iter_at(__y))); reorder(__order, |__i| a0.iter_at(__i)); } @@ -29,8 +30,10 @@ where let __first: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); let mut __out = a2; - while ::not_equal(__first.as_pointer(), __last.as_pointer()) - { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__first.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { object!(__value, T4, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -56,9 +59,13 @@ fn f3< ) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal(__it.borrow().iter_deref(), a2.clone()) - { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(a2.clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -88,13 +95,19 @@ fn f8, T2: LessThanComparable>(a0: T1, a1: T1) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); let mut __best = __it.borrow().clone(); - if ::not_equal(__it.as_pointer(), __last.as_pointer()) { + if ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { __it.borrow_mut().iter_inc(); - while ::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) { - if LessThanComparable::less(__best.iter_deref(), __it.borrow().iter_deref()) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__best.iter_deref()), + LvalueRef::>::bind(__it.borrow().iter_deref()), + )) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -116,19 +129,22 @@ fn f10< ) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - if ::equal(__it.as_pointer(), __last.as_pointer()) { + if ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { __last.borrow().clone() } else { let mut __write = __it.borrow().clone(); __it.borrow_mut().iter_inc(); - while ::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) { - if !WeaklyEqualityComparableWith::equal( - __write.iter_deref(), - __it.borrow().iter_deref(), - ) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { + if !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__write.iter_deref()), + LvalueRef::>::bind(__it.borrow().iter_deref()), + )) { __write.iter_inc(); __write .iter_deref() @@ -144,7 +160,10 @@ fn f10< fn f12, T2: Clone + ByteRepr>(a0: T1, a1: T1, a2: T2) { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { __it.borrow().iter_deref().write(Clone::clone(&a2)); __it.borrow_mut().iter_inc(); } @@ -155,7 +174,10 @@ fn f13>(a0: T1, a1: T1, a2: &mut ::std::fs::File) -> :: let __last: Value = Rc::new(RefCell::new(a1)); let __out = &mut *a2; let mut __bytes: Vec = Vec::new(); - while ::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { __bytes.push(__it.borrow().iter_deref().read() as u8); __it.borrow_mut().iter_inc(); } @@ -184,7 +206,10 @@ where } fn f16(a0: Ptr, a1: Ptr) -> Ptr { - if LessThanComparable::less(a1.clone(), a0.clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(a1.clone()), + LvalueRef::>::bind(a0.clone()), + )) { a1 } else { a0 @@ -192,7 +217,10 @@ fn f16(a0: Ptr, a1: Ptr) -> Ptr { } fn f17(a0: Ptr, a1: Ptr) -> Ptr { - if LessThanComparable::less(a0.clone(), a1.clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(a0.clone()), + LvalueRef::>::bind(a1.clone()), + )) { a1 } else { a0 diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 9eee9d415a..ede6cfb958 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -7,12 +7,19 @@ use std::io::{Seek, Write}; unsafe fn f1, T2: LessThanComparableUnsafe>(a0: T1, a1: T1) { let __n = a1.iter_distance(&a0); let mut __order: Vec = (0..__n).collect(); + // TODO: C++ sort calls operator< once per comparison; this calls it twice. __order.sort_by(|&__x, &__y| { - let __a = a0.iter_at(__x) as *const _; - let __b = a0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = a0.iter_at(__x) as *const T2; + let __b = a0.iter_at(__y) as *const T2; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -42,7 +49,12 @@ where { let mut __first = a0; let mut __out = a2; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &a1) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { object_unsafe!(__value, T4, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -67,9 +79,17 @@ unsafe fn f3< a2: T2, ) -> T1 { let mut __it = a0; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &a2) - { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const a2), + ), + ) { __it.iter_inc(); } __it @@ -103,14 +123,24 @@ where unsafe fn f8, T2: LessThanComparableUnsafe>(a0: T1, a1: T1) -> T1 { let mut __best = a0.clone(); - if WeaklyEqualityComparableWithUnsafe::not_equal(&a0, &a1) { + if ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { let mut __it = a0; __it.iter_inc(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) { - if LessThanComparableUnsafe::less( - __best.iter_deref() as *const _, - __it.iter_deref() as *const _, - ) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__best.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), + )) { __best = __it.clone(); } __it.iter_inc(); @@ -132,15 +162,27 @@ unsafe fn f10< a0: T1, a1: T1, ) -> T1 { - if WeaklyEqualityComparableWithUnsafe::equal(&a0, &a1) { + if ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) { a1 } else { let mut __write = a0.clone(); let mut __it = a0; __it.iter_inc(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) { - if !WeaklyEqualityComparableWithUnsafe::equal(&*__write.iter_deref(), __it.iter_deref()) - { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { + if !ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(__write.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), + ), + ) { __write.iter_inc(); *__write.iter_deref() = (*__it.iter_deref()).clone(); } @@ -153,7 +195,12 @@ unsafe fn f10< unsafe fn f12, T2: Clone>(a0: T1, a1: T1, a2: T2) { let mut __it = a0; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { *__it.iter_deref() = Clone::clone(&a2); __it.iter_inc(); } @@ -167,7 +214,12 @@ unsafe fn f13>( let mut __it = a0; let __out = &mut *a2; let mut __bytes: Vec = Vec::new(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { __bytes.push(*__it.iter_deref() as u8); __it.iter_inc(); } @@ -194,7 +246,10 @@ where unsafe fn f16(a0: *const T1, a1: *const T1) -> *const T1 { let __a: *const _ = a0; let __b: *const _ = a1; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -204,7 +259,10 @@ unsafe fn f16(a0: *const T1, a1: *const T1) -> *co unsafe fn f17(a0: *const T1, a1: *const T1) -> *const T1 { let __a: *const _ = a0; let __b: *const _ = a1; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index 4f15125eb3..d24a62347a 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -8,9 +8,9 @@ use std::marker::PhantomData; use std::rc::Rc; use crate::{ - ByteRepr, EqualityComparable, EqualityComparableUnsafe, MapNode, PartiallyOrderedWith, - PartiallyOrderedWithUnsafe, PostfixDec, PostfixInc, PrefixDec, PrefixInc, Ptr, TotallyOrdered, - TotallyOrderedUnsafe, UnsafeMapNode, Value, + ByteRepr, Const, EqualityComparable, EqualityComparableUnsafe, LvalueRef, LvalueRefUnsafe, + MapNode, PartiallyOrderedWith, PartiallyOrderedWithUnsafe, PostfixDec, PostfixInc, PrefixDec, + PrefixInc, Ptr, TotallyOrdered, TotallyOrderedUnsafe, UnsafeMapNode, Value, }; pub trait CppIterator: Clone { @@ -174,14 +174,30 @@ macro_rules! uninhabited_iterator { impl ByteRepr for $name {} impl crate::WeaklyEqualityComparableWith for $name { - fn equal(this: Ptr, _: Ptr) -> bool { - this.with(|it| it.never()) + type EqualResult = bool; + type NotEqualResult = bool; + fn equal(this: LvalueRef>, _: LvalueRef>) -> bool { + this.as_pointer().with(|it| it.never()) + } + fn not_equal(this: LvalueRef>, _: LvalueRef>) -> bool { + this.as_pointer().with(|it| it.never()) } } impl crate::WeaklyEqualityComparableWithUnsafe for $name { - unsafe fn equal(this: *const Self, _: *const Self) -> bool { - unsafe { (*this).never() } + type EqualResult = bool; + type NotEqualResult = bool; + unsafe fn equal( + this: LvalueRefUnsafe>, + _: LvalueRefUnsafe>, + ) -> bool { + unsafe { (*this.as_const_ptr()).never() } + } + unsafe fn not_equal( + this: LvalueRefUnsafe>, + _: LvalueRefUnsafe>, + ) -> bool { + unsafe { (*this.as_const_ptr()).never() } } } @@ -191,8 +207,8 @@ macro_rules! uninhabited_iterator { } } - impl crate::Constructor<(crate::LvalueRef>,)> for $name { - fn constructor(_: Ptr, (src,): (crate::LvalueRef>,)) { + impl crate::Constructor<(LvalueRef>,)> for $name { + fn constructor(_: Ptr, (src,): (LvalueRef>,)) { src.as_pointer().with(|it| it.never()) } } @@ -203,12 +219,12 @@ macro_rules! uninhabited_iterator { } } - impl crate::ConstructorUnsafe<(crate::LvalueRefUnsafe>,)> + impl crate::ConstructorUnsafe<(LvalueRefUnsafe>,)> for $name { unsafe fn constructor( _: *mut Self, - (src,): (crate::LvalueRefUnsafe>,), + (src,): (LvalueRefUnsafe>,), ) { unsafe { (*src.as_const_ptr()).never() } } @@ -286,13 +302,22 @@ impl Clone for BidirectionalIterator { impl ByteRepr for BidirectionalIterator {} impl crate::WeaklyEqualityComparableWith for BidirectionalIterator { - fn equal(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + type EqualResult = bool; + type NotEqualResult = bool; + fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Map(a), Self::Map(b)) => Rc::ptr_eq(a, b), }) }) } + fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { + (Self::Map(a), Self::Map(b)) => !Rc::ptr_eq(a, b), + }) + }) + } } impl CppIterator for BidirectionalIterator { @@ -349,13 +374,25 @@ impl Clone for UnsafeBidirectionalIterator { } impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeBidirectionalIterator { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { + type EqualResult = bool; + type NotEqualResult = bool; + unsafe fn equal(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Map(a), Self::Map(b)) => a == b, } } } + unsafe fn not_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { + unsafe { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { + (Self::Map(a), Self::Map(b)) => a != b, + } + } + } } impl UnsafeCppIterator for UnsafeBidirectionalIterator { @@ -536,40 +573,53 @@ crate::constructor::impl_trivial_copy_move!( ); impl crate::WeaklyEqualityComparableWith for RandomAccessIterator { - fn equal(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + type EqualResult = bool; + type NotEqualResult = bool; + fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a == b, }) }) } + fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { + (Self::Vec(a), Self::Vec(b)) => a != b, + }) + }) + } } impl PartiallyOrderedWith for RandomAccessIterator { - fn less(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + type LessResult = bool; + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; + fn less(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a < b, }) }) } - fn greater(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + fn greater(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a > b, }) }) } - fn less_equal(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + fn less_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a <= b, }) }) } - fn greater_equal(this: Ptr, rhs: Ptr) -> bool { - this.with(|a| { - rhs.with(|b| match (a, b) { + fn greater_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + this.as_pointer().with(|a| { + rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a >= b, }) }) @@ -577,40 +627,71 @@ impl PartiallyOrderedWith for RandomAccessIterator { } impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator { - unsafe fn equal(this: *const Self, rhs: *const Self) -> bool { + type EqualResult = bool; + type NotEqualResult = bool; + unsafe fn equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a == b, } } } + unsafe fn not_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { + unsafe { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { + (Self::Vec(a), Self::Vec(b)) => a != b, + } + } + } } impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { - unsafe fn less(this: *const Self, rhs: *const Self) -> bool { + type LessResult = bool; + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; + unsafe fn less( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a < b, } } } - unsafe fn greater(this: *const Self, rhs: *const Self) -> bool { + unsafe fn greater( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a > b, } } } - unsafe fn less_equal(this: *const Self, rhs: *const Self) -> bool { + unsafe fn less_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a <= b, } } } - unsafe fn greater_equal(this: *const Self, rhs: *const Self) -> bool { + unsafe fn greater_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { - match (&*this, &*rhs) { + match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a >= b, } } @@ -635,9 +716,11 @@ macro_rules! iter_step { Rc::new(RefCell::new(self)) } fn iter_not_equal(cur: &Self::Var, end: &Self::Var) -> bool { - ::not_equal( - crate::AsPointer::::as_pointer(cur), - crate::AsPointer::::as_pointer(end), + crate::ConvertibleTo::::convert_value( + ::not_equal( + LvalueRef::>::bind(crate::AsPointer::::as_pointer(cur)), + LvalueRef::>::bind(crate::AsPointer::::as_pointer(end)), + ), ) } fn iter_next(cur: &mut Self::Var) -> Self { @@ -658,7 +741,14 @@ macro_rules! iter_step_unsafe { self } fn iter_not_equal(cur: &Self::Var, end: &Self::Var) -> bool { - unsafe { ::not_equal(cur, end) } + unsafe { + crate::ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const *cur), + LvalueRefUnsafe::>::bind(&raw const *end), + ), + ) + } } fn iter_next(cur: &mut Self::Var) -> Self { UnsafeCppIterator::::iter_post_inc(cur) diff --git a/rules/iterator_category/tgt_refcount.rs b/rules/iterator_category/tgt_refcount.rs index 71e13deeba..bd7953b275 100644 --- a/rules/iterator_category/tgt_refcount.rs +++ b/rules/iterator_category/tgt_refcount.rs @@ -59,11 +59,17 @@ fn f8, T2>(a0: T1) -> Ptr { } fn f9, T2>(a0: Ptr, a1: Ptr) -> bool { - WeaklyEqualityComparableWith::equal(a0, a1) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f10, T2>(a0: Ptr, a1: Ptr) -> bool { - WeaklyEqualityComparableWith::not_equal(a0, a1) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f11, T2>(a0: &mut T1) -> &mut T1 { @@ -106,19 +112,31 @@ fn f19, T2>(a0: T1, a1: isize) -> Ptr { } fn f20, T2>(a0: Ptr, a1: Ptr) -> bool { - PartiallyOrderedWith::less(a0, a1) + ConvertibleTo::::convert_value(PartiallyOrderedWith::less( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f21, T2>(a0: Ptr, a1: Ptr) -> bool { - PartiallyOrderedWith::greater(a0, a1) + ConvertibleTo::::convert_value(PartiallyOrderedWith::greater( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f22, T2>(a0: Ptr, a1: Ptr) -> bool { - PartiallyOrderedWith::less_equal(a0, a1) + ConvertibleTo::::convert_value(PartiallyOrderedWith::less_equal( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f23, T2>(a0: Ptr, a1: Ptr) -> bool { - PartiallyOrderedWith::greater_equal(a0, a1) + ConvertibleTo::::convert_value(PartiallyOrderedWith::greater_equal( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } fn f24, T2>(a0: T2) -> T1 { @@ -143,5 +161,8 @@ fn f27< a0: Ptr, a1: Ptr, ) -> bool { - WeaklyEqualityComparableWith::equal(a0, a1) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>::bind(a0), + LvalueRef::>::bind(a1), + )) } diff --git a/rules/iterator_category/tgt_unsafe.rs b/rules/iterator_category/tgt_unsafe.rs index aadacbf262..9b3714a888 100644 --- a/rules/iterator_category/tgt_unsafe.rs +++ b/rules/iterator_category/tgt_unsafe.rs @@ -59,11 +59,17 @@ fn f8, T2>(a0: T1) -> *mut T2 { } unsafe fn f9, T2>(a0: T1, a1: T1) -> bool { - WeaklyEqualityComparableWithUnsafe::equal(&a0, &a1) + ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f10, T2>(a0: T1, a1: T1) -> bool { - WeaklyEqualityComparableWithUnsafe::not_equal(&a0, &a1) + ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } fn f11, T2>(a0: &mut T1) -> &mut T1 { @@ -106,19 +112,31 @@ fn f19, T2>(a0: T1, a1: isize) -> *mut T2 } unsafe fn f20, T2>(a0: T1, a1: T1) -> bool { - PartiallyOrderedWithUnsafe::less(&a0, &a1) + ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f21, T2>(a0: T1, a1: T1) -> bool { - PartiallyOrderedWithUnsafe::greater(&a0, &a1) + ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f22, T2>(a0: T1, a1: T1) -> bool { - PartiallyOrderedWithUnsafe::less_equal(&a0, &a1) + ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less_equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f23, T2>(a0: T1, a1: T1) -> bool { - PartiallyOrderedWithUnsafe::greater_equal(&a0, &a1) + ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater_equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } fn f24, T2>(a0: T2) -> T1 { @@ -143,5 +161,8 @@ unsafe fn f27< a0: T1, a1: T2, ) -> bool { - WeaklyEqualityComparableWithUnsafe::equal(&a0, &a1) + ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } diff --git a/rules/map/shim.rs b/rules/map/shim.rs index e77027f1dc..e5365c978a 100644 --- a/rules/map/shim.rs +++ b/rules/map/shim.rs @@ -9,10 +9,10 @@ use std::rc::{Rc, Weak}; use crate::{ AsPointer, BidirectionalIterator, ByteRepr, Const, Constructor, ConstructorUnsafe, - CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, - LessThanComparable, LessThanComparableUnsafe, LvalueRef, LvalueRefUnsafe, Ptr, - UnsafeBidirectionalIterator, Value, ZeroInitialization, copy_constructed, - copy_constructed_unsafe, cpp_cmp, + ConvertibleToUnsafe, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, + CopyConstructibleUnsafe, LessThanComparable, LessThanComparableUnsafe, LvalueRef, + LvalueRefUnsafe, Ptr, UnsafeBidirectionalIterator, Value, ZeroInitialization, + copy_constructed, copy_constructed_unsafe, cpp_cmp, }; impl ByteRepr for BTreeMap {} @@ -407,9 +407,15 @@ struct UnsafeMapKey(*const K); impl Ord for UnsafeMapKey { fn cmp(&self, other: &Self) -> Ordering { unsafe { - if K::less(self.0, other.0) { + if ConvertibleToUnsafe::::convert_value(K::less( + LvalueRefUnsafe::>::bind(self.0), + LvalueRefUnsafe::>::bind(other.0), + )) { Ordering::Less - } else if K::less(other.0, self.0) { + } else if ConvertibleToUnsafe::::convert_value(K::less( + LvalueRefUnsafe::>::bind(other.0), + LvalueRefUnsafe::>::bind(self.0), + )) { Ordering::Greater } else { Ordering::Equal diff --git a/rules/pair/tgt_refcount.rs b/rules/pair/tgt_refcount.rs index 1cbd23af3e..bb299f1a9b 100644 --- a/rules/pair/tgt_refcount.rs +++ b/rules/pair/tgt_refcount.rs @@ -218,8 +218,13 @@ fn f28, T2: WeaklyEqualityComparableWith, Value), a1: (Value, Value), ) -> bool { - !(WeaklyEqualityComparableWith::equal(a0.0.as_pointer(), a1.0.as_pointer()) - && WeaklyEqualityComparableWith::equal(a0.1.as_pointer(), a1.1.as_pointer())) + !(ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(a0.0.as_pointer()), + LvalueRef::>::bind(a1.0.as_pointer()), + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(a0.1.as_pointer()), + LvalueRef::>::bind(a1.1.as_pointer()), + ))) } fn f34< @@ -248,34 +253,51 @@ fn f29( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - LessThanComparable::less(a0, a1) + ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a0), + LvalueRef::, Value)>>::bind(a1), + )) } fn f30( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - !LessThanComparable::less(a1, a0) + !ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a1), + LvalueRef::, Value)>>::bind(a0), + )) } fn f31( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - LessThanComparable::less(a1, a0) + ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a1), + LvalueRef::, Value)>>::bind(a0), + )) } fn f32( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - !LessThanComparable::less(a0, a1) + !ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a0), + LvalueRef::, Value)>>::bind(a1), + )) } fn f33, T2: WeaklyEqualityComparableWith>( a0: (Value, Value), a1: (Value, Value), ) -> bool { - WeaklyEqualityComparableWith::equal(a0.0.as_pointer(), a1.0.as_pointer()) - && WeaklyEqualityComparableWith::equal(a0.1.as_pointer(), a1.1.as_pointer()) + ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(a0.0.as_pointer()), + LvalueRef::>::bind(a1.0.as_pointer()), + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(a0.1.as_pointer()), + LvalueRef::>::bind(a1.1.as_pointer()), + )) } diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index 0a41887c0e..cc7248506d 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -210,36 +210,55 @@ unsafe fn f28< a0: (T1, T2), a1: (T1, T2), ) -> bool { - !(WeaklyEqualityComparableWithUnsafe::equal(&a0.0, &a1.0) - && WeaklyEqualityComparableWithUnsafe::equal(&a0.1, &a1.1)) + !(ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a0.0), + LvalueRefUnsafe::>::bind(&raw const a1.0), + )) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&raw const a0.1), + LvalueRefUnsafe::>::bind(&raw const a1.1), + ), + )) } unsafe fn f29( a0: (T1, T2), a1: (T1, T2), ) -> bool { - LessThanComparableUnsafe::less(&a0, &a1) + ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f30( a0: (T1, T2), a1: (T1, T2), ) -> bool { - !LessThanComparableUnsafe::less(&a1, &a0) + !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&raw const a0), + )) } unsafe fn f31( a0: (T1, T2), a1: (T1, T2), ) -> bool { - LessThanComparableUnsafe::less(&a1, &a0) + ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&raw const a0), + )) } unsafe fn f32( a0: (T1, T2), a1: (T1, T2), ) -> bool { - !LessThanComparableUnsafe::less(&a0, &a1) + !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&raw const a1), + )) } unsafe fn f33< @@ -249,8 +268,15 @@ unsafe fn f33< a0: (T1, T2), a1: (T1, T2), ) -> bool { - WeaklyEqualityComparableWithUnsafe::equal(&a0.0, &a1.0) - && WeaklyEqualityComparableWithUnsafe::equal(&a0.1, &a1.1) + ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a0.0), + LvalueRefUnsafe::>::bind(&raw const a1.0), + )) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&raw const a0.1), + LvalueRefUnsafe::>::bind(&raw const a1.1), + ), + ) } unsafe fn f34< diff --git a/rules/vector/tgt_refcount.rs b/rules/vector/tgt_refcount.rs index 57fb717d39..5a479f3f13 100644 --- a/rules/vector/tgt_refcount.rs +++ b/rules/vector/tgt_refcount.rs @@ -110,7 +110,10 @@ fn f92< let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -165,7 +168,10 @@ fn f101< let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value = Rc::new(RefCell::new(a2)); let __last: Value = Rc::new(RefCell::new(a3)); - while ::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(::not_equal( + LvalueRef::>::bind(__it.as_pointer()), + LvalueRef::>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/rules/vector/tgt_unsafe.rs b/rules/vector/tgt_unsafe.rs index 505f41b0b7..4aedac640b 100644 --- a/rules/vector/tgt_unsafe.rs +++ b/rules/vector/tgt_unsafe.rs @@ -168,7 +168,12 @@ unsafe fn f92< ) -> Vec { let mut __v: Vec = Vec::new(); let mut __it = a0; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a1) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a1), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -218,7 +223,12 @@ unsafe fn f101< let __off = a1.iter_distance(&UnsafeRandomAccessIterator::Vec(a0.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = a2; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &a3) { + while ConvertibleToUnsafe::::convert_value( + ::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const a3), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index 1b1ac0deb3..d08e61c30b 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -27,6 +27,28 @@ pub struct S { #[offset(4)] pub b: i32, } +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for S { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -35,39 +57,35 @@ fn main_0() -> i32 { let s1: Value = Rc::new(RefCell::new(S { a: 1, b: 2 })); let s2: Value = Rc::new(RefCell::new(S { a: 1, b: 2 })); let s3: Value = Rc::new(RefCell::new(S { a: 1, b: 3 })); - assert!(({ WeaklyEqualityComparableWith::equal(s1.as_pointer(), s2.as_pointer(),) })); - assert!(({ WeaklyEqualityComparableWith::not_equal(s1.as_pointer(), s3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(s1.as_pointer(), s3.as_pointer(),) })); - assert!(({ LessThanComparable::less(s1.as_pointer(), s3.as_pointer(),) })); - assert!(!({ LessThanComparable::less(s3.as_pointer(), s1.as_pointer(),) })); - assert!((({ compare_0(s1.as_pointer(), s3.as_pointer(),) }) == -1_i32)); - assert!((({ compare_0(s3.as_pointer(), s1.as_pointer(),) }) == 1)); - assert!((({ compare_0(s1.as_pointer(), s2.as_pointer(),) }) == 0)); + assert!(({ operator_eq_0(s1.as_pointer(), s2.as_pointer(),) })); + assert!(({ operator_ne_1(s1.as_pointer(), s3.as_pointer(),) })); + assert!(!({ operator_eq_0(s1.as_pointer(), s3.as_pointer(),) })); + assert!(({ operator_lt_2(s1.as_pointer(), s3.as_pointer(),) })); + assert!(!({ operator_lt_2(s3.as_pointer(), s1.as_pointer(),) })); + assert!((({ compare_3(s1.as_pointer(), s3.as_pointer(),) }) == -1_i32)); + assert!((({ compare_3(s3.as_pointer(), s1.as_pointer(),) }) == 1)); + assert!((({ compare_3(s1.as_pointer(), s2.as_pointer(),) }) == 0)); return 0; } -impl LessThanComparable for S { - fn less(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.a) } < { y.with(|__s| __s.a) }) - || (({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }) - && ({ x.with(|__s| __s.b) } < { y.with(|__s| __s.b) })); - } +pub fn operator_eq_0(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }) + && ({ x.with(|__s| __s.b) } == { y.with(|__s| __s.b) }); +} +pub fn operator_ne_1(x: Ptr, y: Ptr) -> bool { + return !({ operator_eq_0((x).clone(), (y).clone()) }); } -pub fn compare_0(x: Ptr, y: Ptr) -> i32 { - if ({ LessThanComparable::less((x).clone(), (y).clone()) }) { +pub fn operator_lt_2(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.a) } < { y.with(|__s| __s.a) }) + || (({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }) + && ({ x.with(|__s| __s.b) } < { y.with(|__s| __s.b) })); +} +pub fn compare_3(x: Ptr, y: Ptr) -> i32 { + if ({ operator_lt_2((x).clone(), (y).clone()) }) { return -1_i32; } - if ({ LessThanComparable::less((y).clone(), (x).clone()) }) { + if ({ operator_lt_2((y).clone(), (x).clone()) }) { return 1; } return 0; } -impl WeaklyEqualityComparableWith for S { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }) - && ({ x.with(|__s| __s.b) } == { y.with(|__s| __s.b) }); - } - fn not_equal(x: Ptr, y: Ptr) -> bool { - return !({ WeaklyEqualityComparableWith::equal((x).clone(), (y).clone()) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 4c4224906a..f2ea868c9e 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -68,6 +68,89 @@ impl p2_implicit_conversion_function_Ratio { return (this.with(|__s| __s.numerator) / this.with(|__s| __s.denominator)); } } +impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } +} +impl LessThanComparable for p2_implicit_conversion_function_Ratio { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } +} +impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }); + } +} pub fn test_1() { let ratio: Value = Rc::new(RefCell::new(p2_implicit_conversion_function_Ratio { diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index 9321a13393..cc3dc1fced 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -34,10 +34,108 @@ pub struct p1_each_relation_is_an_operator_Score { #[offset(0)] pub points: i32, } -impl LessThanComparable for p1_each_relation_is_an_operator_Score { - fn less(this: Ptr, other: Ptr) -> bool { +impl p1_each_relation_is_an_operator_Score { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.points) } == { other.with(|__s| __s.points) }); + } + pub fn operator_lt(this: Ptr, other: Ptr) -> bool { return ({ this.with(|__s| __s.points) } < { other.with(|__s| __s.points) }); } + pub fn operator_gt(this: Ptr, other: Ptr) -> bool { + (*greater_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); + return ({ this.with(|__s| __s.points) } > { other.with(|__s| __s.points) }); + } + pub fn operator_le(this: Ptr, other: Ptr) -> bool { + (*less_equal_calls_1.with(Value::clone).borrow_mut()).prefix_inc(); + return ({ this.with(|__s| __s.points) } <= { other.with(|__s| __s.points) }); + } + pub fn operator_ge(this: Ptr, other: Ptr) -> bool { + (*greater_equal_calls_2.with(Value::clone).borrow_mut()).prefix_inc(); + return ({ this.with(|__s| __s.points) } >= { other.with(|__s| __s.points) }); + } +} +impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_each_relation_is_an_operator_Score { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_gt((__lhs).clone(), (__rhs).clone()) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_le((__lhs).clone(), (__rhs).clone()) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_each_relation_is_an_operator_Score::operator_ge((__lhs).clone(), (__rhs).clone()) + }); + } } pub fn test_3() { let low: Value = @@ -48,12 +146,36 @@ pub fn test_3() { Rc::new(RefCell::new(p1_each_relation_is_an_operator_Score { points: 20, })); - assert!(({ LessThanComparable::less(low.as_pointer(), high.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater(high.as_pointer(), low.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::less_equal(low.as_pointer(), high.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::less_equal(low.as_pointer(), low.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater_equal(high.as_pointer(), low.as_pointer(),) })); - assert!(!({ PartiallyOrderedWith::greater_equal(low.as_pointer(), high.as_pointer(),) })); + assert!( + ({ + p1_each_relation_is_an_operator_Score::operator_lt(low.as_pointer(), high.as_pointer()) + }) + ); + assert!( + ({ + p1_each_relation_is_an_operator_Score::operator_gt(high.as_pointer(), low.as_pointer()) + }) + ); + assert!( + ({ + p1_each_relation_is_an_operator_Score::operator_le(low.as_pointer(), high.as_pointer()) + }) + ); + assert!( + ({ + p1_each_relation_is_an_operator_Score::operator_le(low.as_pointer(), low.as_pointer()) + }) + ); + assert!( + ({ + p1_each_relation_is_an_operator_Score::operator_ge(high.as_pointer(), low.as_pointer()) + }) + ); + assert!( + !({ + p1_each_relation_is_an_operator_Score::operator_ge(low.as_pointer(), high.as_pointer()) + }) + ); assert!((greater_calls_0.with(|rc| *rc.borrow()) == 1)); assert!((less_equal_calls_1.with(|rc| *rc.borrow()) == 2)); assert!((greater_equal_calls_2.with(|rc| *rc.borrow()) == 2)); @@ -69,20 +191,19 @@ pub fn test_3() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct p1_relations_from_three_way_Level { #[offset(0)] pub depth: i32, } -impl ThreeWayComparable for p1_relations_from_three_way_Level { - type Category = libcc2rs::StrongOrdering; - fn three_way( +impl p1_relations_from_three_way_Level { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.depth) } == { other.with(|__s| __s.depth) }); + } + pub fn operator_cmp( this: Ptr, other: Ptr, ) -> libcc2rs::StrongOrdering { @@ -92,29 +213,143 @@ impl ThreeWayComparable for p1_relations_from_three_way_Level { )); } } +impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_relations_from_three_way_Level { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl PartiallyOrderedWith for p1_relations_from_three_way_Level { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl ThreeWayComparable for p1_relations_from_three_way_Level { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } +} pub fn test_4() { let shallow: Value = Rc::new(RefCell::new(p1_relations_from_three_way_Level { depth: 1 })); let deep: Value = Rc::new(RefCell::new(p1_relations_from_three_way_Level { depth: 5 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(shallow.as_pointer(), deep.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp(shallow.as_pointer(), deep.as_pointer()) + }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(deep.as_pointer(), shallow.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp(deep.as_pointer(), shallow.as_pointer()) + }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(shallow.as_pointer(), deep.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp(shallow.as_pointer(), deep.as_pointer()) + }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(shallow.as_pointer(), shallow.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp( + shallow.as_pointer(), + shallow.as_pointer(), + ) + }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(deep.as_pointer(), shallow.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp(deep.as_pointer(), shallow.as_pointer()) + }) )); assert!( !(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(shallow.as_pointer(), deep.as_pointer(),) }) + ({ + p1_relations_from_three_way_Level::operator_cmp( + shallow.as_pointer(), + deep.as_pointer(), + ) + }) )) ); } @@ -132,10 +367,8 @@ thread_local!( TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, + Conversions, )] -#[three_way(p1_operator_preferred_over_three_way_Level::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct p1_operator_preferred_over_three_way_Level { @@ -152,6 +385,95 @@ impl p1_operator_preferred_over_three_way_Level { &(other.with(|__s| __s.depth)), )); } + pub fn operator_gt( + this: Ptr, + other: Ptr, + ) -> bool { + (*greater_calls_5.with(Value::clone).borrow_mut()).prefix_inc(); + return ({ this.with(|__s| __s.depth) } > { other.with(|__s| __s.depth) }); + } +} +impl LessThanComparable for p1_operator_preferred_over_three_way_Level { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_operator_preferred_over_three_way_Level::operator_gt( + (__lhs).clone(), + (__rhs).clone(), + ) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } } pub fn test_6() { let shallow: Value = @@ -162,7 +484,14 @@ pub fn test_6() { Rc::new(RefCell::new(p1_operator_preferred_over_three_way_Level { depth: 5, })); - assert!(({ PartiallyOrderedWith::greater(deep.as_pointer(), shallow.as_pointer(),) })); + assert!( + ({ + p1_operator_preferred_over_three_way_Level::operator_gt( + deep.as_pointer(), + shallow.as_pointer(), + ) + }) + ); assert!((greater_calls_5.with(|rc| *rc.borrow()) == 1)); assert!(libcc2rs::is_lt( ({ @@ -192,52 +521,6 @@ fn main_0() -> i32 { ({ test_6() }); return 0; } -impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { - fn greater(this: Ptr, other: Ptr) -> bool { - (*greater_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); - return ({ this.with(|__s| __s.points) } > { other.with(|__s| __s.points) }); - } - fn less_equal(this: Ptr, other: Ptr) -> bool { - (*less_equal_calls_1.with(Value::clone).borrow_mut()).prefix_inc(); - return ({ this.with(|__s| __s.points) } <= { other.with(|__s| __s.points) }); - } - fn greater_equal(this: Ptr, other: Ptr) -> bool { - (*greater_equal_calls_2.with(Value::clone).borrow_mut()).prefix_inc(); - return ({ this.with(|__s| __s.points) } >= { other.with(|__s| __s.points) }); - } - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } -} -impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { - fn greater(this: Ptr, other: Ptr) -> bool { - (*greater_calls_5.with(Value::clone).borrow_mut()).prefix_inc(); - return ({ this.with(|__s| __s.depth) } > { other.with(|__s| __s.depth) }); - } - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } - fn less_equal(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_lteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs, rhs, - )) - } - fn greater_equal(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_gteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs, rhs, - )) - } -} -impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.points) } == { other.with(|__s| __s.points) }); - } -} -impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.depth) } == { other.with(|__s| __s.depth) }); - } -} pub fn __cpp2rust_init_globals() { let _ = greater_calls_0.with(|_| ()); let _ = less_equal_calls_1.with(|_| ()); From 8e28bc640d7bec972955c0521f1107565dd66257 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 21:50:18 +0000 Subject: [PATCH 04/17] Update tests --- .../out/unsafe/friend_operator.rs | 88 ++- .../out/refcount/class.spaceship.rs | 571 ++++++++++++++++-- .../out/unsafe/class.spaceship.rs | 476 +++++++++++++-- .../class.conv/out/unsafe/class.conv.fct.rs | 76 +++ .../refcount/concept.equalitycomparable.rs | 231 +++++-- .../out/unsafe/concept.equalitycomparable.rs | 242 ++++++-- .../out/unsafe/concept.totallyordered.rs | 420 ++++++++++--- .../out/refcount/concept.convertible.rs | 97 +++ .../out/unsafe/concept.convertible.rs | 90 +++ .../out/refcount/sequence.reqmts.rs | 104 +++- .../out/unsafe/sequence.reqmts.rs | 119 +++- .../allocator.requirements.general.rs | 32 +- .../unsafe/allocator.requirements.general.rs | 38 +- .../out/refcount/utility.arg.requirements.rs | 337 +++++++++-- .../out/unsafe/utility.arg.requirements.rs | 308 ++++++++-- .../stmt.select/out/refcount/stmt.switch.rs | 155 +++++ .../stmt.select/out/unsafe/stmt.switch.rs | 169 ++++++ .../support/cmp/out/refcount/cmp.concept.rs | 484 +++++++++++++-- .../std/support/cmp/out/unsafe/cmp.concept.rs | 464 ++++++++++++-- .../pairs/out/refcount/pairs.pair.rs | 145 +++-- .../utilities/pairs/out/unsafe/pairs.pair.rs | 120 +++- tests/ub/out/refcount/max.rs | 10 +- tests/ub/out/unsafe/max.rs | 10 +- tests/unit/out/refcount/class.rs | 18 +- .../refcount/container_element_receiver.rs | 5 +- tests/unit/out/refcount/copy_ctor.rs | 5 +- .../refcount/elidable_iterator_copy_cxx11.rs | 18 +- .../out/refcount/emplace_receiver_alias.rs | 5 +- .../out/refcount/emplace_receiver_order.rs | 12 +- tests/unit/out/refcount/find.rs | 154 +++-- tests/unit/out/refcount/friend.rs | 32 +- .../out/refcount/global_call_temporaries.rs | 72 +-- tests/unit/out/refcount/map.rs | 81 ++- tests/unit/out/refcount/map_key_copy_ctor.rs | 10 +- tests/unit/out/refcount/map_key_identity.rs | 262 ++++---- tests/unit/out/refcount/map_try_emplace.rs | 2 +- tests/unit/out/refcount/max.rs | 138 +++-- tests/unit/out/refcount/min_max_ptr2ptr.rs | 30 +- .../out/refcount/operator_comparison_free.rs | 164 +++-- .../refcount/operator_comparison_member.rs | 104 +++- .../out/refcount/operator_comparison_mixed.rs | 84 +++ .../refcount/operator_comparison_nonbool.rs | 307 +++++++++- .../operator_comparison_noncopyable.rs | 28 +- .../out/refcount/operator_other_member.rs | 51 ++ tests/unit/out/refcount/operator_three_way.rs | 92 ++- .../refcount/pair_converting_construction.rs | 77 +++ tests/unit/out/refcount/push_emplace_back.rs | 20 +- .../refcount/redundant_copy_in_conversion.rs | 31 +- tests/unit/out/refcount/size_t_ssize_t.rs | 116 +++- tests/unit/out/refcount/sort_no_copy.rs | 116 ++-- tests/unit/out/refcount/stdcopy.rs | 20 +- tests/unit/out/refcount/stdcopy_ostream.rs | 5 +- tests/unit/out/refcount/stdmin_fpoint.rs | 5 +- .../refcount/unboxed_conditional_iterator.rs | 35 +- tests/unit/out/refcount/unboxed_locals.rs | 5 +- tests/unit/out/refcount/vector.rs | 30 +- .../out/refcount/vector_iter_range_ctor.rs | 139 ++++- .../out/refcount/vector_with_allocator.rs | 25 +- tests/unit/out/unsafe/cast.rs | 14 +- tests/unit/out/unsafe/class.rs | 14 +- .../out/unsafe/container_element_receiver.rs | 9 +- tests/unit/out/unsafe/copy_ctor.rs | 11 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 33 +- .../unit/out/unsafe/emplace_receiver_alias.rs | 5 +- .../unit/out/unsafe/emplace_receiver_order.rs | 15 +- tests/unit/out/unsafe/find.rs | 236 +++++--- tests/unit/out/unsafe/friend.rs | 32 +- .../out/unsafe/global_call_temporaries.rs | 45 +- tests/unit/out/unsafe/map.rs | 131 ++-- tests/unit/out/unsafe/map_key_copy_ctor.rs | 13 +- tests/unit/out/unsafe/map_key_identity.rs | 129 +++- tests/unit/out/unsafe/map_try_emplace.rs | 6 +- tests/unit/out/unsafe/max.rs | 94 ++- tests/unit/out/unsafe/min_max_ptr2ptr.rs | 30 +- .../out/unsafe/operator_comparison_free.rs | 209 +++++-- .../out/unsafe/operator_comparison_member.rs | 122 +++- .../out/unsafe/operator_comparison_mixed.rs | 138 +++++ .../out/unsafe/operator_comparison_nonbool.rs | 357 ++++++++++- .../unsafe/operator_comparison_noncopyable.rs | 34 +- .../unit/out/unsafe/operator_other_member.rs | 76 +++ tests/unit/out/unsafe/operator_three_way.rs | 112 +++- .../unsafe/pair_converting_construction.rs | 76 +++ tests/unit/out/unsafe/push_emplace_back.rs | 20 +- .../unsafe/redundant_copy_in_conversion.rs | 46 +- tests/unit/out/unsafe/size_t_ssize_t.rs | 107 +++- tests/unit/out/unsafe/sort.rs | 14 +- tests/unit/out/unsafe/sort_no_copy.rs | 265 +++++--- tests/unit/out/unsafe/stdcopy.rs | 20 +- tests/unit/out/unsafe/stdcopy_ostream.rs | 11 +- tests/unit/out/unsafe/stdmin_fpoint.rs | 5 +- .../unsafe/unboxed_conditional_iterator.rs | 42 +- tests/unit/out/unsafe/unboxed_locals.rs | 5 +- tests/unit/out/unsafe/vector.rs | 44 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 133 +++- .../unit/out/unsafe/vector_with_allocator.rs | 25 +- tests/unit/out/unsafe/void_return.rs | 28 +- 96 files changed, 8033 insertions(+), 1757 deletions(-) diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index 9b135af2e2..a25a0c3d5d 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -23,6 +23,46 @@ pub struct S { pub a: i32, pub b: i32, } +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _x: *const S = __lhs; + operator_eq_0(_x, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _x: *const S = __lhs; + operator_ne_1(_x, __rhs) + }); + } +} +impl LessThanComparableUnsafe for S { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _x: *const S = __lhs; + operator_lt_2(_x, __rhs) + }); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -36,67 +76,63 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const S = &s1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &s2) + operator_eq_0(_x, &s2) }) ); assert!( (unsafe { let _x: *const S = &s1; - WeaklyEqualityComparableWithUnsafe::not_equal(_x, &s3) + operator_ne_1(_x, &s3) }) ); assert!( !(unsafe { let _x: *const S = &s1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &s3) + operator_eq_0(_x, &s3) }) ); assert!( (unsafe { let _x: *const S = &s1; - LessThanComparableUnsafe::less(_x, &s3) + operator_lt_2(_x, &s3) }) ); assert!( !(unsafe { let _x: *const S = &s3; - LessThanComparableUnsafe::less(_x, &s1) + operator_lt_2(_x, &s1) }) ); - assert!(((unsafe { compare_0(&s1, &s3,) }) == (-1_i32))); - assert!(((unsafe { compare_0(&s3, &s1,) }) == (1))); - assert!(((unsafe { compare_0(&s1, &s2,) }) == (0))); + assert!(((unsafe { compare_3(&s1, &s3,) }) == (-1_i32))); + assert!(((unsafe { compare_3(&s3, &s1,) }) == (1))); + assert!(((unsafe { compare_3(&s1, &s2,) }) == (0))); return 0; } -impl LessThanComparableUnsafe for S { - unsafe fn less(x: *const S, y: *const S) -> bool { - return (((*x).a) < ((*y).a)) || ((((*x).a) == ((*y).a)) && (((*x).b) < ((*y).b))); - } +pub unsafe fn operator_eq_0(x: *const S, y: *const S) -> bool { + return (((*x).a) == ((*y).a)) && (((*x).b) == ((*y).b)); +} +pub unsafe fn operator_ne_1(x: *const S, y: *const S) -> bool { + return !(unsafe { + let _x: *const S = x; + operator_eq_0(_x, y) + }); +} +pub unsafe fn operator_lt_2(x: *const S, y: *const S) -> bool { + return (((*x).a) < ((*y).a)) || ((((*x).a) == ((*y).a)) && (((*x).b) < ((*y).b))); } -pub unsafe fn compare_0(x: *const S, y: *const S) -> i32 { +pub unsafe fn compare_3(x: *const S, y: *const S) -> i32 { if (unsafe { let _x: *const S = x; - LessThanComparableUnsafe::less(_x, y) + operator_lt_2(_x, y) }) { return -1_i32; } if (unsafe { let _x: *const S = y; - LessThanComparableUnsafe::less(_x, x) + operator_lt_2(_x, x) }) { return 1; } return 0; } -impl WeaklyEqualityComparableWithUnsafe for S { - unsafe fn equal(x: *const S, y: *const S) -> bool { - return (((*x).a) == ((*y).a)) && (((*x).b) == ((*y).b)); - } - unsafe fn not_equal(x: *const S, y: *const S) -> bool { - return !(unsafe { - let _x: *const S = x; - WeaklyEqualityComparableWithUnsafe::equal(_x, y) - }); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 8d14e1f93a..3f95d1966a 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -17,11 +17,8 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(12)] pub struct p1_memberwise_in_declaration_order_Date { @@ -32,9 +29,8 @@ pub struct p1_memberwise_in_declaration_order_Date { #[offset(8)] pub day: i32, } -impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { - type Category = libcc2rs::StrongOrdering; - fn three_way( +impl p1_memberwise_in_declaration_order_Date { + pub fn operator_cmp( this: Ptr, _a0: Ptr, ) -> libcc2rs::StrongOrdering { @@ -67,6 +63,132 @@ impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.year) } == { _a0.with(|__s| __s.year) }) + && (({ this.with(|__s| __s.month) } == { _a0.with(|__s| __s.month) }) + && ({ this.with(|__s| __s.day) } == { _a0.with(|__s| __s.day) })); + } +} +impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_memberwise_in_declaration_order_Date::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_memberwise_in_declaration_order_Date::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_memberwise_in_declaration_order_Date { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_memberwise_in_declaration_order_Date::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } } pub fn test_0() { let earlier: Value = @@ -88,29 +210,76 @@ pub fn test_0() { day: 1, })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(earlier.as_pointer(), later_day.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + earlier.as_pointer(), + later_day.as_pointer(), + ) + }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(later_year.as_pointer(), later_day.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + later_year.as_pointer(), + later_day.as_pointer(), + ) + }) )); assert!(libcc2rs::is_eq( - ({ ThreeWayComparable::three_way(earlier.as_pointer(), earlier.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + earlier.as_pointer(), + earlier.as_pointer(), + ) + }) )); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(earlier.as_pointer(), later_day.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + earlier.as_pointer(), + later_day.as_pointer(), + ) + }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(later_year.as_pointer(), earlier.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + later_year.as_pointer(), + earlier.as_pointer(), + ) + }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(earlier.as_pointer(), earlier.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + earlier.as_pointer(), + earlier.as_pointer(), + ) + }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(later_year.as_pointer(), later_day.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + later_year.as_pointer(), + later_day.as_pointer(), + ) + }) )); - assert!(({ WeaklyEqualityComparableWith::equal(earlier.as_pointer(), earlier.as_pointer(),) })); assert!( - !({ WeaklyEqualityComparableWith::equal(earlier.as_pointer(), later_day.as_pointer(),) }) + ({ + p1_memberwise_in_declaration_order_Date::operator_eq( + earlier.as_pointer(), + earlier.as_pointer(), + ) + }) + ); + assert!( + !({ + p1_memberwise_in_declaration_order_Date::operator_eq( + earlier.as_pointer(), + later_day.as_pointer(), + ) + }) ); } #[derive( @@ -124,11 +293,8 @@ pub fn test_0() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(16)] pub struct p2_common_comparison_category_Reading { @@ -137,9 +303,8 @@ pub struct p2_common_comparison_category_Reading { #[offset(8)] pub value: f64, } -impl ThreeWayComparable for p2_common_comparison_category_Reading { - type Category = libcc2rs::PartialOrdering; - fn three_way( +impl p2_common_comparison_category_Reading { + pub fn operator_cmp( this: Ptr, _a0: Ptr, ) -> libcc2rs::PartialOrdering { @@ -170,6 +335,131 @@ impl ThreeWayComparable for p2_common_comparison_category_Reading { ({ (*libcc2rs::strong_ordering_equal().upgrade().deref()) }), ); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.sensor) } == { _a0.with(|__s| __s.sensor) }) + && ({ this.with(|__s| __s.value) } == { _a0.with(|__s| __s.value) }); + } +} +impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p2_common_comparison_category_Reading { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl PartiallyOrderedWith for p2_common_comparison_category_Reading { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl ThreeWayComparable for p2_common_comparison_category_Reading { + type Category = libcc2rs::PartialOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p2_common_comparison_category_Reading::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } } pub fn test_1() { let low: Value = @@ -183,20 +473,30 @@ pub fn test_1() { value: 2.5_f64, })); let order: Value = Rc::new(RefCell::new( - ({ ThreeWayComparable::three_way(low.as_pointer(), high.as_pointer()) }), + ({ + p2_common_comparison_category_Reading::operator_cmp(low.as_pointer(), high.as_pointer()) + }), )); assert!(libcc2rs::is_lt(({ (*order.borrow()) }))); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(low.as_pointer(), high.as_pointer(),) }) + ({ + p2_common_comparison_category_Reading::operator_cmp(low.as_pointer(), high.as_pointer()) + }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(high.as_pointer(), low.as_pointer(),) }) + ({ + p2_common_comparison_category_Reading::operator_cmp(high.as_pointer(), low.as_pointer()) + }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(low.as_pointer(), low.as_pointer(),) }) + ({ + p2_common_comparison_category_Reading::operator_cmp(low.as_pointer(), low.as_pointer()) + }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(high.as_pointer(), low.as_pointer(),) }) + ({ + p2_common_comparison_category_Reading::operator_cmp(high.as_pointer(), low.as_pointer()) + }) )); } #[derive( @@ -210,11 +510,8 @@ pub fn test_1() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct weak_ordering_from_user_operator_Fraction { @@ -234,6 +531,90 @@ impl weak_ordering_from_user_operator_Fraction { ))); } } +impl LessThanComparable for weak_ordering_from_user_operator_Fraction { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} pub fn test_2() { let half: Value = Rc::new(RefCell::new(weak_ordering_from_user_operator_Fraction { @@ -299,22 +680,34 @@ pub fn test_2() { }) )); assert!( - (if LessThanComparable::less(third.as_pointer().clone(), half.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + third.as_pointer().clone() + ), + LvalueRef::>::bind( + half.as_pointer().clone() + ) + )) { half.as_pointer() } else { third.as_pointer() } - .with(|__s| __s.denominator) - == 2) + .with(|__s| __s.denominator) == 2) ); assert!( - (if LessThanComparable::less(half.as_pointer().clone(), third.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + half.as_pointer().clone() + ), + LvalueRef::>::bind( + third.as_pointer().clone() + ) + )) { half.as_pointer() } else { third.as_pointer() } - .with(|__s| __s.denominator) - == 3) + .with(|__s| __s.denominator) == 3) ); } #[derive( @@ -328,11 +721,8 @@ pub fn test_2() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct partial_ordering_from_user_operator_Interval { @@ -360,6 +750,90 @@ impl partial_ordering_from_user_operator_Interval { return (*libcc2rs::partial_ordering_unordered().upgrade().deref()); } } +impl LessThanComparable for partial_ordering_from_user_operator_Interval { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} +impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } +} pub fn test_3() { let early: Value = Rc::new(RefCell::new(partial_ordering_from_user_operator_Interval { @@ -468,17 +942,4 @@ fn main_0() -> i32 { ({ test_3() }); return 0; } -impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.year) } == { _a0.with(|__s| __s.year) }) - && (({ this.with(|__s| __s.month) } == { _a0.with(|__s| __s.month) }) - && ({ this.with(|__s| __s.day) } == { _a0.with(|__s| __s.day) })); - } -} -impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.sensor) } == { _a0.with(|__s| __s.sensor) }) - && ({ this.with(|__s| __s.value) } == { _a0.with(|__s| __s.value) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 9eeab57e06..8352e91cb9 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -16,20 +16,16 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_memberwise_in_declaration_order_Date { pub year: i32, pub month: i32, pub day: i32, } -impl ThreeWayComparableUnsafe for p1_memberwise_in_declaration_order_Date { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( +impl p1_memberwise_in_declaration_order_Date { + pub unsafe fn operator_cmp( this: *const Self, _a0: *const p1_memberwise_in_declaration_order_Date, ) -> libcc2rs::StrongOrdering { @@ -57,6 +53,119 @@ impl ThreeWayComparableUnsafe for p1_memberwise_in_declaration_order_Date { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq( + this: *const Self, + _a0: *const p1_memberwise_in_declaration_order_Date, + ) -> bool { + return (((*this).year) == ((*_a0).year)) + && ((((*this).month) == ((*_a0).month)) && (((*this).day) == ((*_a0).day))); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return (unsafe { + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return !(unsafe { + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return libcc2rs::is_gt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return libcc2rs::is_lteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return libcc2rs::is_gteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl ThreeWayComparableUnsafe for p1_memberwise_in_declaration_order_Date { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + return (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }); + } } pub unsafe fn test_0() { let mut earlier: p1_memberwise_in_declaration_order_Date = @@ -78,40 +187,52 @@ pub unsafe fn test_0() { day: 1, }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const earlier, &later_day,) }) + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const earlier, &later_day) + }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const later_year, &later_day,) }) + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const later_year, &later_day) + }) )); assert!(libcc2rs::is_eq( (unsafe { let _arg0: *const p1_memberwise_in_declaration_order_Date = &earlier; - ThreeWayComparableUnsafe::three_way(&raw const earlier, _arg0) + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const earlier, _arg0) }) )); assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const earlier, &later_day,) }) + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const earlier, &later_day) + }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const later_year, &earlier,) }) + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const later_year, &earlier) + }) )); assert!(libcc2rs::is_lteq( (unsafe { let _arg0: *const p1_memberwise_in_declaration_order_Date = &earlier; - ThreeWayComparableUnsafe::three_way(&raw const earlier, _arg0) + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const earlier, _arg0) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const later_year, &later_day,) }) + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const later_year, &later_day) + }) )); assert!( (unsafe { let _arg0: *const p1_memberwise_in_declaration_order_Date = &earlier; - WeaklyEqualityComparableWithUnsafe::equal(&raw const earlier, _arg0) + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const earlier, _arg0) }) ); assert!( - !(unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const earlier, &later_day,) }) + !(unsafe { + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const earlier, &later_day) + }) ); } #[repr(C)] @@ -124,19 +245,15 @@ pub unsafe fn test_0() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p2_common_comparison_category_Reading { pub sensor: i32, pub value: f64, } -impl ThreeWayComparableUnsafe for p2_common_comparison_category_Reading { - type Category = libcc2rs::PartialOrdering; - unsafe fn three_way( +impl p2_common_comparison_category_Reading { + pub unsafe fn operator_cmp( this: *const Self, _a0: *const p2_common_comparison_category_Reading, ) -> libcc2rs::PartialOrdering { @@ -159,6 +276,118 @@ impl ThreeWayComparableUnsafe for p2_common_comparison_category_Reading { } return libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_EQUAL); } + pub unsafe fn operator_eq( + this: *const Self, + _a0: *const p2_common_comparison_category_Reading, + ) -> bool { + return (((*this).sensor) == ((*_a0).sensor)) && (((*this).value) == ((*_a0).value)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return (unsafe { + p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return !(unsafe { + p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return libcc2rs::is_gt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return libcc2rs::is_lteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return libcc2rs::is_gteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl ThreeWayComparableUnsafe for p2_common_comparison_category_Reading { + type Category = libcc2rs::PartialOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + return (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }); + } } pub unsafe fn test_1() { let mut low: p2_common_comparison_category_Reading = p2_common_comparison_category_Reading { @@ -170,22 +399,22 @@ pub unsafe fn test_1() { value: 2.5_f64, }; let mut order: libcc2rs::PartialOrdering = - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const low, &high) }); + (unsafe { p2_common_comparison_category_Reading::operator_cmp(&raw const low, &high) }); assert!(libcc2rs::is_lt(order)); assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const low, &high,) }) + (unsafe { p2_common_comparison_category_Reading::operator_cmp(&raw const low, &high,) }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const high, &low,) }) + (unsafe { p2_common_comparison_category_Reading::operator_cmp(&raw const high, &low,) }) )); assert!(libcc2rs::is_lteq( (unsafe { let _arg0: *const p2_common_comparison_category_Reading = &low; - ThreeWayComparableUnsafe::three_way(&raw const low, _arg0) + p2_common_comparison_category_Reading::operator_cmp(&raw const low, _arg0) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const high, &low,) }) + (unsafe { p2_common_comparison_category_Reading::operator_cmp(&raw const high, &low,) }) )); } #[repr(C)] @@ -198,11 +427,8 @@ pub unsafe fn test_1() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(weak_ordering_from_user_operator_Fraction::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct weak_ordering_from_user_operator_Fraction { pub numerator: i32, @@ -219,6 +445,75 @@ impl weak_ordering_from_user_operator_Fraction { ))); } } +impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + return libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + return libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + return libcc2rs::is_gt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + return libcc2rs::is_lteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + return libcc2rs::is_gteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} pub unsafe fn test_2() { let mut half: weak_ordering_from_user_operator_Fraction = weak_ordering_from_user_operator_Fraction { @@ -269,7 +564,12 @@ pub unsafe fn test_2() { (((*{ let __a: *const _ = &mut third; let __b: *const _ = &mut half; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -282,7 +582,12 @@ pub unsafe fn test_2() { (((*{ let __a: *const _ = &mut third; let __b: *const _ = &mut half; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -302,11 +607,8 @@ pub unsafe fn test_2() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(partial_ordering_from_user_operator_Interval::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct partial_ordering_from_user_operator_Interval { pub low: i32, @@ -329,6 +631,90 @@ impl partial_ordering_from_user_operator_Interval { return libcc2rs::PARTIAL_ORDERING_UNORDERED; } } +impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + return libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + return libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + return libcc2rs::is_gt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + return libcc2rs::is_lteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + return libcc2rs::is_gteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ); + } +} pub unsafe fn test_3() { let mut early: partial_ordering_from_user_operator_Interval = partial_ordering_from_user_operator_Interval { low: 1, high: 3 }; @@ -420,18 +806,4 @@ unsafe fn main_0() -> i32 { (unsafe { test_3() }); return 0; } -impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { - unsafe fn equal( - this: *const Self, - _a0: *const p1_memberwise_in_declaration_order_Date, - ) -> bool { - return (((*this).year) == ((*_a0).year)) - && ((((*this).month) == ((*_a0).month)) && (((*this).day) == ((*_a0).day))); - } -} -impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { - unsafe fn equal(this: *const Self, _a0: *const p2_common_comparison_category_Reading) -> bool { - return (((*this).sensor) == ((*_a0).sensor)) && (((*this).value) == ((*_a0).value)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 9aa229123c..bd0797a523 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -59,6 +59,82 @@ impl p2_implicit_conversion_function_Ratio { return (((*this).numerator) / ((*this).denominator)); } } +impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Ratio { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + != (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } +} +impl LessThanComparableUnsafe for p2_implicit_conversion_function_Ratio { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } +} +impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + > (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + <= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + >= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); + } +} pub unsafe fn test_1() { let mut ratio: p2_implicit_conversion_function_Ratio = p2_implicit_conversion_function_Ratio { numerator: 9, diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index 36685a983f..ae2302b7c9 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -28,6 +28,35 @@ pub struct p1_3_not_equal_Meters { #[offset(0)] pub value: i32, } +impl p1_3_not_equal_Meters { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.value) } == { other.with(|__s| __s.value) }); + } + pub fn operator_ne(this: Ptr, other: Ptr) -> bool { + (*not_equal_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); + return ({ this.with(|__s| __s.value) } != { other.with(|__s| __s.value) }); + } +} +impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn test_1() { let three: Value = Rc::new(RefCell::new(p1_3_not_equal_Meters { value: 3 })); @@ -35,15 +64,11 @@ pub fn test_1() { Rc::new(RefCell::new(p1_3_not_equal_Meters { value: 3 })); let four: Value = Rc::new(RefCell::new(p1_3_not_equal_Meters { value: 4 })); + assert!(({ p1_3_not_equal_Meters::operator_eq(three.as_pointer(), also_three.as_pointer(),) })); assert!( - ({ WeaklyEqualityComparableWith::equal(three.as_pointer(), also_three.as_pointer(),) }) - ); - assert!( - !({ - WeaklyEqualityComparableWith::not_equal(three.as_pointer(), also_three.as_pointer()) - }) + !({ p1_3_not_equal_Meters::operator_ne(three.as_pointer(), also_three.as_pointer(),) }) ); - assert!(({ WeaklyEqualityComparableWith::not_equal(three.as_pointer(), four.as_pointer(),) })); + assert!(({ p1_3_not_equal_Meters::operator_ne(three.as_pointer(), four.as_pointer(),) })); assert!((not_equal_calls_0.with(|rc| *rc.borrow()) == 2)); } #[derive( @@ -65,31 +90,76 @@ pub struct p1_2_reversed_operands_Meters { #[offset(0)] pub value: i32, } +impl p1_2_reversed_operands_Meters { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.value) } == { (other.read()) }); + } +} +impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for i32 { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } +} pub fn test_2() { let three: Value = Rc::new(RefCell::new(p1_2_reversed_operands_Meters { value: 3 })); assert!( ({ let _other: Value = Rc::new(RefCell::new(3)); - WeaklyEqualityComparableWith::equal(three.as_pointer(), _other.as_pointer()) + p1_2_reversed_operands_Meters::operator_eq(three.as_pointer(), _other.as_pointer()) }) ); assert!( ({ let _other: Value = Rc::new(RefCell::new(3)); - WeaklyEqualityComparableWith::equal(three.as_pointer(), _other.as_pointer()) + p1_2_reversed_operands_Meters::operator_eq(three.as_pointer(), _other.as_pointer()) }) ); assert!( !({ let _other: Value = Rc::new(RefCell::new(4)); - WeaklyEqualityComparableWith::equal(three.as_pointer(), _other.as_pointer()) + p1_2_reversed_operands_Meters::operator_eq(three.as_pointer(), _other.as_pointer()) }) ); assert!( !({ let _other: Value = Rc::new(RefCell::new(4)); - WeaklyEqualityComparableWith::equal(three.as_pointer(), _other.as_pointer()) + p1_2_reversed_operands_Meters::operator_eq(three.as_pointer(), _other.as_pointer()) }) ); } @@ -112,6 +182,51 @@ pub struct p1_different_types_Meters { #[offset(0)] pub value: i32, } +impl p1_different_types_Meters { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.value) } == { (other.read()) }); + } +} +impl WeaklyEqualityComparableWith for p1_different_types_Meters { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for i32 { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } +} pub fn test_3() { let lengths: Value> = Rc::new(RefCell::new(Vec::from([ p1_different_types_Meters { value: 1 }, @@ -126,12 +241,22 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().begin())); let __last: Value> = Rc::new(RefCell::new(lengths.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_0.as_pointer().clone(), + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + )) && !ConvertibleTo::::convert_value( + ::equal( + LvalueRef::>::bind( + __it.borrow().iter_deref(), + ), + LvalueRef::>::bind(__tmp_0.as_pointer().clone()), + ), ) { __it.borrow_mut().iter_inc(); } @@ -139,9 +264,15 @@ pub fn test_3() { } }), )); - assert!(WeaklyEqualityComparableWith::not_equal( - found.as_pointer(), - Rc::new(RefCell::new(lengths.decay().end())).as_pointer() + assert!(ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind( + found.as_pointer() + ), + LvalueRef::>>::bind( + Rc::new(RefCell::new(lengths.decay().end())).as_pointer() + ), + ) )); assert!((({ (*found.borrow()).iter_deref() }).with(|__s| __s.value) == 2)); assert!(match ( @@ -153,12 +284,22 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().begin())); let __last: Value> = Rc::new(RefCell::new(lengths.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_2.as_pointer().clone(), + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + )) && !ConvertibleTo::::convert_value( + ::equal( + LvalueRef::>::bind( + __it.borrow().iter_deref(), + ), + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + ), ) { __it.borrow_mut().iter_inc(); } @@ -170,7 +311,14 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().end())).as_pointer(), ) { (__tmp_1, __tmp_3) => { - WeaklyEqualityComparableWith::equal((__tmp_1).clone(), (__tmp_3).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind( + (__tmp_1).clone(), + ), + LvalueRef::>>::bind( + (__tmp_3).clone(), + ), + )) } }); } @@ -184,35 +332,6 @@ fn main_0() -> i32 { ({ test_3() }); return 0; } -impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.value) } == { other.with(|__s| __s.value) }); - } - fn not_equal(this: Ptr, other: Ptr) -> bool { - (*not_equal_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); - return ({ this.with(|__s| __s.value) } != { other.with(|__s| __s.value) }); - } -} -impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.value) } == { (other.read()) }); - } -} -impl WeaklyEqualityComparableWith for p1_different_types_Meters { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.value) } == { (other.read()) }); - } -} -impl WeaklyEqualityComparableWith for i32 { - fn equal(lhs: Ptr, rhs: Ptr) -> bool { - >::equal(rhs, lhs) - } -} -impl WeaklyEqualityComparableWith for i32 { - fn equal(lhs: Ptr, rhs: Ptr) -> bool { - >::equal(rhs, lhs) - } -} pub fn __cpp2rust_init_globals() { let _ = not_equal_calls_0.with(|_| ()); } diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 232ae81cb3..a46e6a30ff 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -24,15 +24,42 @@ pub static mut not_equal_calls_0: std::cell::LazyCell = pub struct p1_3_not_equal_Meters { pub value: i32, } +impl p1_3_not_equal_Meters { + pub unsafe fn operator_eq(this: *const Self, other: *const p1_3_not_equal_Meters) -> bool { + return (((*this).value) == ((*other).value)); + } + pub unsafe fn operator_ne(this: *const Self, other: *const p1_3_not_equal_Meters) -> bool { + (*std::cell::LazyCell::force_mut(&mut *&raw mut not_equal_calls_0)).prefix_inc(); + return (((*this).value) != ((*other).value)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); + let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); + return (unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); + let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); + return (unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) }); + } +} pub unsafe fn test_1() { let mut three: p1_3_not_equal_Meters = p1_3_not_equal_Meters { value: 3 }; let mut also_three: p1_3_not_equal_Meters = p1_3_not_equal_Meters { value: 3 }; let mut four: p1_3_not_equal_Meters = p1_3_not_equal_Meters { value: 4 }; - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const three, &also_three,) })); - assert!( - !(unsafe { WeaklyEqualityComparableWithUnsafe::not_equal(&raw const three, &also_three,) }) - ); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::not_equal(&raw const three, &four,) })); + assert!((unsafe { p1_3_not_equal_Meters::operator_eq(&raw const three, &also_three,) })); + assert!(!(unsafe { p1_3_not_equal_Meters::operator_ne(&raw const three, &also_three,) })); + assert!((unsafe { p1_3_not_equal_Meters::operator_ne(&raw const three, &four,) })); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut not_equal_calls_0)) == (2))); } #[repr(C)] @@ -51,30 +78,79 @@ pub unsafe fn test_1() { pub struct p1_2_reversed_operands_Meters { pub value: i32, } +impl p1_2_reversed_operands_Meters { + pub unsafe fn operator_eq(this: *const Self, other: *const i32) -> bool { + return (((*this).value) == (*other)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + return !(unsafe { + p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i32 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); + return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); + return !(unsafe { + p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) + }); + } +} pub unsafe fn test_2() { let mut three: p1_2_reversed_operands_Meters = p1_2_reversed_operands_Meters { value: 3 }; assert!( (unsafe { let mut _other: i32 = 3; - WeaklyEqualityComparableWithUnsafe::equal(&raw const three, &mut _other) + p1_2_reversed_operands_Meters::operator_eq(&raw const three, &mut _other) }) ); assert!( (unsafe { let mut _other: i32 = 3; - WeaklyEqualityComparableWithUnsafe::equal(&raw const three, &mut _other) + p1_2_reversed_operands_Meters::operator_eq(&raw const three, &mut _other) }) ); assert!( !(unsafe { let mut _other: i32 = 4; - WeaklyEqualityComparableWithUnsafe::equal(&raw const three, &mut _other) + p1_2_reversed_operands_Meters::operator_eq(&raw const three, &mut _other) }) ); assert!( !(unsafe { let mut _other: i32 = 4; - WeaklyEqualityComparableWithUnsafe::equal(&raw const three, &mut _other) + p1_2_reversed_operands_Meters::operator_eq(&raw const three, &mut _other) }) ); } @@ -94,6 +170,51 @@ pub unsafe fn test_2() { pub struct p1_different_types_Meters { pub value: i32, } +impl p1_different_types_Meters { + pub unsafe fn operator_eq(this: *const Self, other: *const i32) -> bool { + return (((*this).value) == (*other)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i32 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); + return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); + return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); + } +} pub unsafe fn test_3() { let mut lengths: Vec = Vec::from([ p1_different_types_Meters { value: 1 }, @@ -104,31 +225,67 @@ pub unsafe fn test_3() { let mut __tmp_0 = { lengths.begin() }; let mut __tmp_1 = { lengths.end() }; let mut __it = (__tmp_0).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &2) - { + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_1, + ), + )) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 2), + )) { __it.iter_inc(); } __it }; - assert!(WeaklyEqualityComparableWithUnsafe::not_equal( - &found, - &lengths.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const found + ), + LvalueRefUnsafe::>>::bind( + &raw const lengths.end() + ), + ) )); assert!((((*found.iter_deref()).value) == (2))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_2 = { lengths.begin() }; - let mut __tmp_3 = { lengths.end() }; - let mut __it = (__tmp_2).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &7) - { - __it.iter_inc(); - } - __it - }, - &lengths.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const { + let mut __tmp_2 = { lengths.begin() }; + let mut __tmp_3 = { lengths.end() }; + let mut __it = (__tmp_2).clone(); + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __it), + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __tmp_3), + )) && !ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind( + __it.iter_deref(), + ), + LvalueRefUnsafe::>::bind(&raw const 7), + ), + ) { + __it.iter_inc(); + } + __it + } + ), + LvalueRefUnsafe::>>::bind( + &raw const lengths.end() + ), + ) )); } pub fn main() { @@ -143,35 +300,6 @@ unsafe fn main_0() -> i32 { (unsafe { test_3() }); return 0; } -impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { - unsafe fn equal(this: *const Self, other: *const p1_3_not_equal_Meters) -> bool { - return (((*this).value) == ((*other).value)); - } - unsafe fn not_equal(this: *const Self, other: *const p1_3_not_equal_Meters) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut not_equal_calls_0)).prefix_inc(); - return (((*this).value) != ((*other).value)); - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { - unsafe fn equal(this: *const Self, other: *const i32) -> bool { - return (((*this).value) == (*other)); - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { - unsafe fn equal(this: *const Self, other: *const i32) -> bool { - return (((*this).value) == (*other)); - } -} -impl WeaklyEqualityComparableWithUnsafe for i32 { - unsafe fn equal(lhs: *const Self, rhs: *const p1_2_reversed_operands_Meters) -> bool { - >::equal(rhs, lhs) - } -} -impl WeaklyEqualityComparableWithUnsafe for i32 { - unsafe fn equal(lhs: *const Self, rhs: *const p1_different_types_Meters) -> bool { - >::equal(rhs, lhs) - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const not_equal_calls_0); } diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index 01557f4739..ff68b5ff34 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -28,27 +28,150 @@ pub static mut greater_equal_calls_2: std::cell::LazyCell = pub struct p1_each_relation_is_an_operator_Score { pub points: i32, } -impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { - unsafe fn less(this: *const Self, other: *const p1_each_relation_is_an_operator_Score) -> bool { +impl p1_each_relation_is_an_operator_Score { + pub unsafe fn operator_eq( + this: *const Self, + other: *const p1_each_relation_is_an_operator_Score, + ) -> bool { + return (((*this).points) == ((*other).points)); + } + pub unsafe fn operator_lt( + this: *const Self, + other: *const p1_each_relation_is_an_operator_Score, + ) -> bool { return (((*this).points) < ((*other).points)); } + pub unsafe fn operator_gt( + this: *const Self, + other: *const p1_each_relation_is_an_operator_Score, + ) -> bool { + (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_0)).prefix_inc(); + return (((*this).points) > ((*other).points)); + } + pub unsafe fn operator_le( + this: *const Self, + other: *const p1_each_relation_is_an_operator_Score, + ) -> bool { + (*std::cell::LazyCell::force_mut(&mut *&raw mut less_equal_calls_1)).prefix_inc(); + return (((*this).points) <= ((*other).points)); + } + pub unsafe fn operator_ge( + this: *const Self, + other: *const p1_each_relation_is_an_operator_Score, + ) -> bool { + (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_equal_calls_2)).prefix_inc(); + return (((*this).points) >= ((*other).points)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return !(unsafe { + p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) + }); + } +} +impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) + }); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_gt(&raw const (*__lhs), __rhs) + }); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_le(&raw const (*__lhs), __rhs) + }); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + return (unsafe { + p1_each_relation_is_an_operator_Score::operator_ge(&raw const (*__lhs), __rhs) + }); + } } pub unsafe fn test_3() { let mut low: p1_each_relation_is_an_operator_Score = p1_each_relation_is_an_operator_Score { points: 10 }; let mut high: p1_each_relation_is_an_operator_Score = p1_each_relation_is_an_operator_Score { points: 20 }; - assert!((unsafe { LessThanComparableUnsafe::less(&raw const low, &high,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::greater(&raw const high, &low,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::less_equal(&raw const low, &high,) })); + assert!( + (unsafe { p1_each_relation_is_an_operator_Score::operator_lt(&raw const low, &high,) }) + ); + assert!( + (unsafe { p1_each_relation_is_an_operator_Score::operator_gt(&raw const high, &low,) }) + ); + assert!( + (unsafe { p1_each_relation_is_an_operator_Score::operator_le(&raw const low, &high,) }) + ); assert!( (unsafe { let _other: *const p1_each_relation_is_an_operator_Score = &low; - PartiallyOrderedWithUnsafe::less_equal(&raw const low, _other) + p1_each_relation_is_an_operator_Score::operator_le(&raw const low, _other) }) ); - assert!((unsafe { PartiallyOrderedWithUnsafe::greater_equal(&raw const high, &low,) })); - assert!(!(unsafe { PartiallyOrderedWithUnsafe::greater_equal(&raw const low, &high,) })); + assert!( + (unsafe { p1_each_relation_is_an_operator_Score::operator_ge(&raw const high, &low,) }) + ); + assert!( + !(unsafe { p1_each_relation_is_an_operator_Score::operator_ge(&raw const low, &high,) }) + ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_0)) == (1))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut less_equal_calls_1)) == (2))); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut greater_equal_calls_2)) == (2))); @@ -63,18 +186,20 @@ pub unsafe fn test_3() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_relations_from_three_way_Level { pub depth: i32, } -impl ThreeWayComparableUnsafe for p1_relations_from_three_way_Level { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( +impl p1_relations_from_three_way_Level { + pub unsafe fn operator_eq( + this: *const Self, + other: *const p1_relations_from_three_way_Level, + ) -> bool { + return (((*this).depth) == ((*other).depth)); + } + pub unsafe fn operator_cmp( this: *const Self, other: *const p1_relations_from_three_way_Level, ) -> libcc2rs::StrongOrdering { @@ -84,32 +209,140 @@ impl ThreeWayComparableUnsafe for p1_relations_from_three_way_Level { )); } } +impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return (unsafe { + p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return !(unsafe { + p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return libcc2rs::is_gt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return libcc2rs::is_lteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return libcc2rs::is_gteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl ThreeWayComparableUnsafe for p1_relations_from_three_way_Level { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + return (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }); + } +} pub unsafe fn test_4() { let mut shallow: p1_relations_from_three_way_Level = p1_relations_from_three_way_Level { depth: 1 }; let mut deep: p1_relations_from_three_way_Level = p1_relations_from_three_way_Level { depth: 5 }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const shallow, &deep,) }) + (unsafe { p1_relations_from_three_way_Level::operator_cmp(&raw const shallow, &deep,) }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const deep, &shallow,) }) + (unsafe { p1_relations_from_three_way_Level::operator_cmp(&raw const deep, &shallow,) }) )); assert!(libcc2rs::is_lteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const shallow, &deep,) }) + (unsafe { p1_relations_from_three_way_Level::operator_cmp(&raw const shallow, &deep,) }) )); assert!(libcc2rs::is_lteq( (unsafe { let _other: *const p1_relations_from_three_way_Level = &shallow; - ThreeWayComparableUnsafe::three_way(&raw const shallow, _other) + p1_relations_from_three_way_Level::operator_cmp(&raw const shallow, _other) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const deep, &shallow,) }) + (unsafe { p1_relations_from_three_way_Level::operator_cmp(&raw const deep, &shallow,) }) )); assert!( !(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const shallow, &deep,) }) + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const shallow, &deep) + }) )) ); } @@ -125,10 +358,8 @@ pub static mut greater_calls_5: std::cell::LazyCell = TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, + ConversionsUnsafe, )] -#[three_way(p1_operator_preferred_over_three_way_Level::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_operator_preferred_over_three_way_Level { pub depth: i32, @@ -143,13 +374,91 @@ impl p1_operator_preferred_over_three_way_Level { &((*other).depth), )); } + pub unsafe fn operator_gt( + this: *const Self, + other: *const p1_operator_preferred_over_three_way_Level, + ) -> bool { + (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_5)).prefix_inc(); + return (((*this).depth) > ((*other).depth)); + } +} +impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + return libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + return libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + return (unsafe { + p1_operator_preferred_over_three_way_Level::operator_gt(&raw const (*__lhs), __rhs) + }); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + return libcc2rs::is_lteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + return libcc2rs::is_gteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } } pub unsafe fn test_6() { let mut shallow: p1_operator_preferred_over_three_way_Level = p1_operator_preferred_over_three_way_Level { depth: 1 }; let mut deep: p1_operator_preferred_over_three_way_Level = p1_operator_preferred_over_three_way_Level { depth: 5 }; - assert!((unsafe { PartiallyOrderedWithUnsafe::greater(&raw const deep, &shallow,) })); + assert!( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_gt(&raw const deep, &shallow) + }) + ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_5)) == (1))); assert!(libcc2rs::is_lt( (unsafe { @@ -175,67 +484,6 @@ unsafe fn main_0() -> i32 { (unsafe { test_6() }); return 0; } -impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { - unsafe fn greater( - this: *const Self, - other: *const p1_each_relation_is_an_operator_Score, - ) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_0)).prefix_inc(); - return (((*this).points) > ((*other).points)); - } - unsafe fn less_equal( - this: *const Self, - other: *const p1_each_relation_is_an_operator_Score, - ) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut less_equal_calls_1)).prefix_inc(); - return (((*this).points) <= ((*other).points)); - } - unsafe fn greater_equal( - this: *const Self, - other: *const p1_each_relation_is_an_operator_Score, - ) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_equal_calls_2)).prefix_inc(); - return (((*this).points) >= ((*other).points)); - } - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } -} -impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { - unsafe fn greater( - this: *const Self, - other: *const p1_operator_preferred_over_three_way_Level, - ) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut greater_calls_5)).prefix_inc(); - return (((*this).depth) > ((*other).depth)); - } - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } - unsafe fn less_equal(lhs: *const Self, rhs: *const Self) -> bool { - libcc2rs::is_lteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs, rhs, - )) - } - unsafe fn greater_equal(lhs: *const Self, rhs: *const Self) -> bool { - libcc2rs::is_gteq(p1_operator_preferred_over_three_way_Level::operator_cmp( - lhs, rhs, - )) - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { - unsafe fn equal( - this: *const Self, - other: *const p1_each_relation_is_an_operator_Score, - ) -> bool { - return (((*this).points) == ((*other).points)); - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { - unsafe fn equal(this: *const Self, other: *const p1_relations_from_three_way_Level) -> bool { - return (((*this).depth) == ((*other).depth)); - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const greater_calls_0); std::cell::LazyCell::force(&*&raw const less_equal_calls_1); diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index 08b66f6b78..c739773f45 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -83,6 +83,103 @@ impl p1_convertible_to_Ratio { return (this.with(|__s| __s.numerator) / this.with(|__s| __s.denominator)); } } +impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } == { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } != { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } +} +impl LessThanComparable for p1_convertible_to_Ratio { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } +} +impl PartiallyOrderedWith for p1_convertible_to_Ratio { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } > { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } <= { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } >= { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }); + } +} +impl ThreeWayComparable for p1_convertible_to_Ratio { + type Category = std_strong_ordering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }), + &({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }), + )); + } +} const _: () = assert!(true, "std::convertible_to"); const _: () = assert!(!(false), "!std::convertible_to"); const _: () = assert!(true, "std::convertible_to"); diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 3a19952892..82d5c9cdf8 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -73,6 +73,96 @@ impl p1_convertible_to_Ratio { return (((*this).numerator) / ((*this).denominator)); } } +impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + != (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } +} +impl LessThanComparableUnsafe for p1_convertible_to_Ratio { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } +} +impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + > (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + <= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + >= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); + } +} +impl ThreeWayComparableUnsafe for p1_convertible_to_Ratio { + type Category = std_strong_ordering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }), + &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) }), + )); + } +} const _: () = assert!(true, "std::convertible_to"); const _: () = assert!(!(false), "!std::convertible_to"); const _: () = assert!(true, "std::convertible_to"); diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 21121f5e06..06fc312c01 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -31,6 +31,82 @@ impl p38_insert_range_by_conversion_function_Ratio { return this.with(|__s| __s.num); } } +impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ratio { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + == { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + != { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } +} +impl LessThanComparable for p38_insert_range_by_conversion_function_Ratio { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } +} +impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + > { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + <= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } + >= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); + } +} pub fn test_0() { let ratios: Value> = Rc::new(RefCell::new(Box::new([ @@ -46,10 +122,16 @@ pub fn test_0() { Rc::new(RefCell::new(ratios.decay())); let __last: Value> = Rc::new(RefCell::new(ratios.decay().offset((2) as isize))); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -114,10 +196,16 @@ pub fn test_1() { Rc::new(RefCell::new(levels.decay())); let __last: Value> = Rc::new(RefCell::new(levels.decay().offset((2) as isize))); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index 17cd966374..e6f2668b5a 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -28,6 +28,103 @@ impl p38_insert_range_by_conversion_function_Ratio { return (*this).num; } } +impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_function_Ratio { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) == (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) != (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } +} +impl LessThanComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) < (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } +} +impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Ratio { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) < (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) > (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) <= (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + return ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) >= (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })); + } +} pub unsafe fn test_0() { let mut ratios: [p38_insert_range_by_conversion_function_Ratio; 2] = [ p38_insert_range_by_conversion_function_Ratio { num: 1 }, @@ -41,7 +138,16 @@ pub unsafe fn test_0() { __tmp_0.iter_distance(&UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ratios.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value( + <*mut p38_insert_range_by_conversion_function_Ratio>::not_equal( + LvalueRefUnsafe::>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>::bind( + &raw const __tmp_1, + ), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -95,16 +201,7 @@ pub unsafe fn test_1() { __tmp_2.iter_distance(&UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = levels.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) { - __tmp.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __tmp.as_mut_ptr().add(__tmp.len() - 1), - (LvalueRefUnsafe::< - Const, - >::bind(__it.iter_deref()),), - ); - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_best_conversion_function_Level >::not_equal(LvalueRefUnsafe::>::bind(&raw const __it), LvalueRefUnsafe::>::bind(&raw const __tmp_3 )), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } ints.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr().add(__off)) }; diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 76311ce8ab..397e667d7b 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -45,12 +45,38 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { field!(this, id).write(0); } } +impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int__int__ { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { { p16_rebind_member_Alloc_std_pair_const_int__int__ { id: 0 } } } } -pub fn test_0() { +pub fn operator_eq_0( + a: Ptr, + b: Ptr, +) -> bool { + return ({ a.with(|__s| __s.id) } == { b.with(|__s| __s.id) }); +} +pub fn test_1() { let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); let n: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { @@ -89,7 +115,7 @@ pub fn test_0() { #[conversions(copy, move)] #[byte_size(1)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} -pub fn test_1() { +pub fn test_2() { let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { (__tmp_2,) => { @@ -113,8 +139,8 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { - ({ test_0() }); ({ test_1() }); + ({ test_2() }); return 0; } pub fn __cpp2rust_init_globals() {} diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index 82820a63f9..6f13c98c37 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -40,12 +40,44 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { (&raw mut (*this).id).write(0); } } +impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + return (unsafe { + let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; + operator_eq_0(_a, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + return !(unsafe { + let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; + operator_eq_0(_a, __rhs) + }); + } +} impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { unsafe { p16_rebind_member_Alloc_std_pair_const_int__int__ { id: 0 } } } } -pub unsafe fn test_0() { +pub unsafe fn operator_eq_0( + a: *const p16_rebind_member_Alloc_std_pair_const_int__int__, + b: *const p16_rebind_member_Alloc_std_pair_const_int__int__, +) -> bool { + return (((*a).id) == ((*b).id)); +} +pub unsafe fn test_1() { let mut m: UnsafeMap = UnsafeMap::new(); let mut n: UnsafeMap = UnsafeMap::new(); { @@ -83,7 +115,7 @@ pub unsafe fn test_0() { )] #[conversions(copy, move)] pub struct p18_rebind_to_container_node_Alloc_std_pair_const_int__int__ {} -pub unsafe fn test_1() { +pub unsafe fn test_2() { let mut m: UnsafeMap = UnsafeMap::new(); { let mut __tmp_2: i32; @@ -110,8 +142,8 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - (unsafe { test_0() }); (unsafe { test_1() }); + (unsafe { test_2() }); return 0; } pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 0cf9911565..1b78e55e5a 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -30,14 +30,27 @@ pub struct table29_member_operator_Version { #[offset(4)] pub minor: i32, } -impl LessThanComparable for table29_member_operator_Version { - fn less(this: Ptr, other: Ptr) -> bool { +impl table29_member_operator_Version { + pub fn operator_lt(this: Ptr, other: Ptr) -> bool { (*less_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); return ({ this.with(|__s| __s.major) } < { other.with(|__s| __s.major) }) || (({ this.with(|__s| __s.major) } == { other.with(|__s| __s.major) }) && ({ this.with(|__s| __s.minor) } < { other.with(|__s| __s.minor) })); } } +impl LessThanComparable for table29_member_operator_Version { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table29_member_operator_Version::operator_lt((__lhs).clone(), (__rhs).clone()) + }); + } +} pub fn test_1() { let old_version: Value = Rc::new(RefCell::new(table29_member_operator_Version { @@ -50,10 +63,14 @@ pub fn test_1() { minor: 0, })); assert!( - (if LessThanComparable::less( - old_version.as_pointer().clone(), - new_version.as_pointer().clone() - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + old_version.as_pointer().clone() + ), + LvalueRef::>::bind( + new_version.as_pointer().clone() + ) + )) { new_version.as_pointer() } else { old_version.as_pointer() @@ -62,10 +79,14 @@ pub fn test_1() { == 2) ); assert!( - (if LessThanComparable::less( - new_version.as_pointer().clone(), - old_version.as_pointer().clone() - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + new_version.as_pointer().clone() + ), + LvalueRef::>::bind( + old_version.as_pointer().clone() + ) + )) { new_version.as_pointer() } else { old_version.as_pointer() @@ -105,16 +126,37 @@ pub fn test_1() { let __last: Value> = Rc::new(RefCell::new(versions.decay().end())); let mut __best = __it.borrow().clone(); - if >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) { - __it.borrow_mut().iter_inc(); - while >::not_equal( + if ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( __it.as_pointer(), + ), + LvalueRef::>>::bind( __last.as_pointer(), - ) { - if LessThanComparable::less(__best.iter_deref(), __it.borrow().iter_deref()) { + ), + )) { + __it.borrow_mut().iter_inc(); + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + )) { + if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + __best.iter_deref(), + ), + LvalueRef::>::bind( + __it.borrow().iter_deref(), + ), + ), + ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -194,6 +236,21 @@ impl table29_other_operator_shapes_Weight { return (this.with(|__s| __s.grams) < other.grams); } } +impl LessThanComparable for table29_other_operator_shapes_Weight { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table29_other_operator_shapes_Weight::operator_lt((__lhs).clone(), { + (*__rhs.upgrade().deref()) + }) + }); + } +} #[derive( Copy, Clone, @@ -214,13 +271,22 @@ pub struct table29_other_operator_shapes_Height { pub millimeters: i32, } impl LessThanComparable for table29_other_operator_shapes_Height { + type Result = bool; fn less( - lhs: Ptr, - rhs: Ptr, - ) -> bool { - return ({ lhs.with(|__s| __s.millimeters) } < { rhs.with(|__s| __s.millimeters) }); + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_lt_2( + lhs: Ptr, + rhs: Ptr, +) -> bool { + return ({ lhs.with(|__s| __s.millimeters) } < { rhs.with(|__s| __s.millimeters) }); +} #[derive( Copy, Clone, @@ -232,11 +298,8 @@ impl LessThanComparable for table29_other_operator_shapes_Height { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(table29_other_operator_shapes_Depth::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct table29_other_operator_shapes_Depth { @@ -254,7 +317,76 @@ impl table29_other_operator_shapes_Depth { )); } } -pub fn test_2() { +impl LessThanComparable for table29_other_operator_shapes_Depth { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} +impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} +pub fn test_3() { assert!( ({ let __tmp_5: Value = @@ -265,10 +397,14 @@ pub fn test_2() { Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 5, })); - if LessThanComparable::less( - (__tmp_5.as_pointer()).clone(), - (__tmp_6.as_pointer()).clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + (__tmp_5.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_6.as_pointer()).clone(), + ), + )) { (__tmp_6.as_pointer()) } else { (__tmp_5.as_pointer()) @@ -286,10 +422,14 @@ pub fn test_2() { Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 30, })); - if LessThanComparable::less( - (__tmp_7.as_pointer()).clone(), - (__tmp_8.as_pointer()).clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + (__tmp_7.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_8.as_pointer()).clone(), + ), + )) { (__tmp_7.as_pointer()) } else { (__tmp_8.as_pointer()) @@ -307,10 +447,14 @@ pub fn test_2() { Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 4, })); - if LessThanComparable::less( - (__tmp_9.as_pointer()).clone(), - (__tmp_10.as_pointer()).clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind( + (__tmp_9.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_10.as_pointer()).clone(), + ), + )) { (__tmp_10.as_pointer()) } else { (__tmp_9.as_pointer()) @@ -338,12 +482,28 @@ pub struct pairs_spec_p3_members_order_pairs_Rank { #[offset(0)] pub value: i32, } -impl LessThanComparable for pairs_spec_p3_members_order_pairs_Rank { - fn less(this: Ptr, other: Ptr) -> bool { +impl pairs_spec_p3_members_order_pairs_Rank { + pub fn operator_lt( + this: Ptr, + other: Ptr, + ) -> bool { return ({ this.with(|__s| __s.value) } < { other.with(|__s| __s.value) }); } } -pub fn test_3() { +impl LessThanComparable for pairs_spec_p3_members_order_pairs_Rank { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + pairs_spec_p3_members_order_pairs_Rank::operator_lt((__lhs).clone(), (__rhs).clone()) + }); + } +} +pub fn test_4() { let low: Value<(Value, Value)> = Rc::new(RefCell::new(( Rc::new(RefCell::new( @@ -365,30 +525,77 @@ pub fn test_3() { )), Rc::new(RefCell::new(5)), ))); - assert!(LessThanComparable::less( - low.as_pointer(), - high.as_pointer() - )); - assert!(LessThanComparable::less( - high.as_pointer(), - high_later.as_pointer() - )); - assert!(LessThanComparable::less( - low.as_pointer(), - high_later.as_pointer() - )); - assert!(!LessThanComparable::less( - high.as_pointer(), - low.as_pointer() - )); - assert!(!LessThanComparable::less( - high_later.as_pointer(), - high.as_pointer() - )); - assert!(!(LessThanComparable::less(high.as_pointer(), low.as_pointer()))); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + low.as_pointer() + ), + LvalueRef::, Value)>>::bind( + high.as_pointer() + ), + ))); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + high.as_pointer() + ), + LvalueRef::, Value)>>::bind( + high_later.as_pointer() + ), + ))); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + low.as_pointer() + ), + LvalueRef::, Value)>>::bind( + high_later.as_pointer() + ), + ))); + assert!(!ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + high.as_pointer() + ), + LvalueRef::, Value)>>::bind( + low.as_pointer() + ), + ))); + assert!(!ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + high_later.as_pointer() + ), + LvalueRef::, Value)>>::bind( + high.as_pointer() + ), + ))); + assert!( + !(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind( + high.as_pointer() + ), + LvalueRef::, Value)>>::bind( + low.as_pointer() + ), + ))) + ); assert!( ({ - ( (*(*if LessThanComparable::less(low .as_pointer() .clone(), high .as_pointer() .clone()) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) + ( (*(*if ConvertibleTo::::convert_value(<(Value, Value) >::less(LvalueRef::, Value) >>::bind(low .as_pointer() .clone()), LvalueRef::, Value) >>::bind(high .as_pointer() .clone()))) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) }) ); } @@ -398,8 +605,8 @@ pub fn main() { } fn main_0() -> i32 { ({ test_1() }); - ({ test_2() }); ({ test_3() }); + ({ test_4() }); return 0; } pub fn __cpp2rust_init_globals() { diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index fbfd021336..95c5e4bd0d 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -24,13 +24,29 @@ pub struct table29_member_operator_Version { pub major: i32, pub minor: i32, } -impl LessThanComparableUnsafe for table29_member_operator_Version { - unsafe fn less(this: *const Self, other: *const table29_member_operator_Version) -> bool { +impl table29_member_operator_Version { + pub unsafe fn operator_lt( + this: *const Self, + other: *const table29_member_operator_Version, + ) -> bool { (*std::cell::LazyCell::force_mut(&mut *&raw mut less_calls_0)).prefix_inc(); return (((*this).major) < ((*other).major)) || ((((*this).major) == ((*other).major)) && (((*this).minor) < ((*other).minor))); } } +impl LessThanComparableUnsafe for table29_member_operator_Version { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const table29_member_operator_Version); + let __rhs = (__rhs.as_ptr() as *const table29_member_operator_Version); + return (unsafe { + table29_member_operator_Version::operator_lt(&raw const (*__lhs), __rhs) + }); + } +} pub unsafe fn test_1() { let mut old_version: table29_member_operator_Version = table29_member_operator_Version { major: 1, minor: 4 }; @@ -40,7 +56,10 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -53,7 +72,10 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -73,11 +95,19 @@ pub unsafe fn test_1() { let __n = versions.end().iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const table29_member_operator_Version; + let __b = __tmp_0.iter_at(__y) as *const table29_member_operator_Version; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -99,13 +129,37 @@ pub unsafe fn test_1() { let mut __tmp_1 = { versions.begin() }; let mut __tmp_2 = { versions.end() }; let mut __best = __tmp_1.clone(); - if WeaklyEqualityComparableWithUnsafe::not_equal(&__tmp_1, &__tmp_2) { + if ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __tmp_1), + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __tmp_2), + ), + ) { let mut __it = (__tmp_1).clone(); __it.iter_inc(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_2) { - if LessThanComparableUnsafe::less( - __best.iter_deref() as *const _, - __it.iter_deref() as *const _, + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __it), + LvalueRefUnsafe::< + Const>, + >::bind(&raw const __tmp_2), + )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind( + __best.iter_deref(), + ), + LvalueRefUnsafe::>::bind( + __it.iter_deref(), + ), + ), ) { __best = __it.clone(); } @@ -153,6 +207,19 @@ impl table29_other_operator_shapes_Weight { return (((*this).grams) < (other.grams)); } } +impl LessThanComparableUnsafe for table29_other_operator_shapes_Weight { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Weight); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Weight); + return (unsafe { + table29_other_operator_shapes_Weight::operator_lt(&raw const (*__lhs), (*__rhs)) + }); + } +} #[repr(C)] #[derive( Copy, @@ -170,13 +237,25 @@ pub struct table29_other_operator_shapes_Height { pub millimeters: i32, } impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { + type Result = bool; unsafe fn less( - lhs: *const table29_other_operator_shapes_Height, - rhs: *const table29_other_operator_shapes_Height, - ) -> bool { - return (((*lhs).millimeters) < ((*rhs).millimeters)); + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Height); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); + return (unsafe { + let _lhs: *const table29_other_operator_shapes_Height = __lhs; + operator_lt_2(_lhs, __rhs) + }); } } +pub unsafe fn operator_lt_2( + lhs: *const table29_other_operator_shapes_Height, + rhs: *const table29_other_operator_shapes_Height, +) -> bool { + return (((*lhs).millimeters) < ((*rhs).millimeters)); +} #[repr(C)] #[derive( Copy, @@ -187,11 +266,8 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(table29_other_operator_shapes_Depth::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct table29_other_operator_shapes_Depth { pub millimeters: i32, @@ -207,7 +283,76 @@ impl table29_other_operator_shapes_Depth { )); } } -pub unsafe fn test_2() { +impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + return libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + return libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + return libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + return libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + return libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +pub unsafe fn test_3() { assert!( (({ let mut __tmp_3: table29_other_operator_shapes_Weight = @@ -217,7 +362,12 @@ pub unsafe fn test_2() { (*{ let __a: *const _ = (&mut __tmp_3); let __b: *const _ = (&mut __tmp_4); - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -235,7 +385,12 @@ pub unsafe fn test_2() { (*{ let __a: *const _ = (&mut __tmp_5); let __b: *const _ = (&mut __tmp_6); - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -253,7 +408,12 @@ pub unsafe fn test_2() { (*{ let __a: *const _ = (&mut __tmp_7); let __b: *const _ = (&mut __tmp_8); - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -279,32 +439,108 @@ pub unsafe fn test_2() { pub struct pairs_spec_p3_members_order_pairs_Rank { pub value: i32, } -impl LessThanComparableUnsafe for pairs_spec_p3_members_order_pairs_Rank { - unsafe fn less( +impl pairs_spec_p3_members_order_pairs_Rank { + pub unsafe fn operator_lt( this: *const Self, other: *const pairs_spec_p3_members_order_pairs_Rank, ) -> bool { return (((*this).value) < ((*other).value)); } } -pub unsafe fn test_3() { +impl LessThanComparableUnsafe for pairs_spec_p3_members_order_pairs_Rank { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); + let __rhs = (__rhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); + return (unsafe { + pairs_spec_p3_members_order_pairs_Rank::operator_lt(&raw const (*__lhs), __rhs) + }); + } +} +pub unsafe fn test_4() { let mut low: (pairs_spec_p3_members_order_pairs_Rank, i32) = ((pairs_spec_p3_members_order_pairs_Rank { value: 1 }), 9); let mut high: (pairs_spec_p3_members_order_pairs_Rank, i32) = ((pairs_spec_p3_members_order_pairs_Rank { value: 2 }), 0); let mut high_later: (pairs_spec_p3_members_order_pairs_Rank, i32) = ((pairs_spec_p3_members_order_pairs_Rank { value: 2 }), 5); - assert!(LessThanComparableUnsafe::less(&low, &high)); - assert!(LessThanComparableUnsafe::less(&high, &high_later)); - assert!(LessThanComparableUnsafe::less(&low, &high_later)); - assert!(!LessThanComparableUnsafe::less(&high, &low)); - assert!(!LessThanComparableUnsafe::less(&high_later, &high)); - assert!(!(LessThanComparableUnsafe::less(&high, &low))); + assert!(ConvertibleToUnsafe::::convert_value( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const low + ), + LvalueRefUnsafe::>::bind( + &raw const high + ), + ) + )); + assert!(ConvertibleToUnsafe::::convert_value( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const high + ), + LvalueRefUnsafe::>::bind( + &raw const high_later + ), + ) + )); + assert!(ConvertibleToUnsafe::::convert_value( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const low + ), + LvalueRefUnsafe::>::bind( + &raw const high_later + ), + ) + )); + assert!(!ConvertibleToUnsafe::::convert_value( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const high + ), + LvalueRefUnsafe::>::bind( + &raw const low + ), + ) + )); + assert!(!ConvertibleToUnsafe::::convert_value( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const high_later + ), + LvalueRefUnsafe::>::bind( + &raw const high + ), + ) + )); + assert!( + !(ConvertibleToUnsafe::::convert_value(<( + pairs_spec_p3_members_order_pairs_Rank, + i32 + ) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind( + &raw const high + ), + LvalueRefUnsafe::>::bind( + &raw const low + ), + ))) + ); assert!( (((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(<( + pairs_spec_p3_members_order_pairs_Rank, + i32, + )>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -321,8 +557,8 @@ pub fn main() { } unsafe fn main_0() -> i32 { (unsafe { test_1() }); - (unsafe { test_2() }); (unsafe { test_3() }); + (unsafe { test_4() }); return 0; } pub unsafe fn __cpp2rust_init_globals() { diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 0afa87e2a5..fb70a77b26 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -118,6 +118,161 @@ impl Destructible for p2_condition_variable_lives_for_whole_statement_ConvertsTo (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); } } +impl WeaklyEqualityComparableWith + for p2_condition_variable_lives_for_whole_statement_ConvertsToInt +{ + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } == { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } != { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } +} +impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } < { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } +} +impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } < { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } > { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } <= { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } >= { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }); + } +} pub fn test_7() { { let selector: Value = diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index ca1db4dfaa..6517dedc86 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -92,6 +92,175 @@ impl DestructibleUnsafe for p2_condition_variable_lives_for_whole_statement_Conv (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_6)).prefix_inc(); } } +impl WeaklyEqualityComparableWithUnsafe + for p2_condition_variable_lives_for_whole_statement_ConvertsToInt +{ + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) == (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) != (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } +} +impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) < (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } +} +impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) < (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) > (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) <= (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + return ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) >= (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })); + } +} pub unsafe fn test_7() { { let mut selector: p2_condition_variable_lives_for_whole_statement_ConvertsToInt = diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index c9a75b3c89..8bce80b37d 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -17,11 +17,8 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct p1_defaulted_three_way_Version { @@ -30,9 +27,8 @@ pub struct p1_defaulted_three_way_Version { #[offset(4)] pub minor: i32, } -impl ThreeWayComparable for p1_defaulted_three_way_Version { - type Category = libcc2rs::StrongOrdering; - fn three_way( +impl p1_defaulted_three_way_Version { + pub fn operator_cmp( this: Ptr, _a0: Ptr, ) -> libcc2rs::StrongOrdering { @@ -56,6 +52,104 @@ impl ThreeWayComparable for p1_defaulted_three_way_Version { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.major) } == { _a0.with(|__s| __s.major) }) + && ({ this.with(|__s| __s.minor) } == { _a0.with(|__s| __s.minor) }); + } +} +impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_defaulted_three_way_Version { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl PartiallyOrderedWith for p1_defaulted_three_way_Version { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl ThreeWayComparable for p1_defaulted_three_way_Version { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -74,25 +168,53 @@ pub fn test_0() { minor: 0, })); let order: Value = Rc::new(RefCell::new( - ({ ThreeWayComparable::three_way(old_version.as_pointer(), new_version.as_pointer()) }), + ({ + p1_defaulted_three_way_Version::operator_cmp( + old_version.as_pointer(), + new_version.as_pointer(), + ) + }), )); assert!(libcc2rs::is_lt(({ (*order.borrow()) }))); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(new_version.as_pointer(), old_version.as_pointer(),) }) + ({ + p1_defaulted_three_way_Version::operator_cmp( + new_version.as_pointer(), + old_version.as_pointer(), + ) + }) )); assert!(libcc2rs::is_eq( - ({ ThreeWayComparable::three_way(old_version.as_pointer(), old_version.as_pointer(),) }) + ({ + p1_defaulted_three_way_Version::operator_cmp( + old_version.as_pointer(), + old_version.as_pointer(), + ) + }) )); assert!( ({ - WeaklyEqualityComparableWith::equal(old_version.as_pointer(), old_version.as_pointer()) + p1_defaulted_three_way_Version::operator_eq( + old_version.as_pointer(), + old_version.as_pointer(), + ) }) ); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(old_version.as_pointer(), new_version.as_pointer(),) }) + ({ + p1_defaulted_three_way_Version::operator_cmp( + old_version.as_pointer(), + new_version.as_pointer(), + ) + }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(new_version.as_pointer(), old_version.as_pointer(),) }) + ({ + p1_defaulted_three_way_Version::operator_cmp( + new_version.as_pointer(), + old_version.as_pointer(), + ) + }) )); } thread_local!( @@ -109,20 +231,19 @@ thread_local!( TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct p1_user_written_three_way_Money { #[offset(0)] pub cents: i32, } -impl ThreeWayComparable for p1_user_written_three_way_Money { - type Category = libcc2rs::StrongOrdering; - fn three_way( +impl p1_user_written_three_way_Money { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.cents) } == { other.with(|__s| __s.cents) }); + } + pub fn operator_cmp( this: Ptr, other: Ptr, ) -> libcc2rs::StrongOrdering { @@ -133,6 +254,102 @@ impl ThreeWayComparable for p1_user_written_three_way_Money { )); } } +impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_user_written_three_way_Money { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl PartiallyOrderedWith for p1_user_written_three_way_Money { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl ThreeWayComparable for p1_user_written_three_way_Money { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } +} const _: () = assert!(true, "std::three_way_comparable"); pub fn test_2() { let small: Value = @@ -140,22 +357,34 @@ pub fn test_2() { let large: Value = Rc::new(RefCell::new(p1_user_written_three_way_Money { cents: 900 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(small.as_pointer(), large.as_pointer(),) }) + ({ + p1_user_written_three_way_Money::operator_cmp(small.as_pointer(), large.as_pointer()) + }) )); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(small.as_pointer(), large.as_pointer(),) }) + ({ + p1_user_written_three_way_Money::operator_cmp(small.as_pointer(), large.as_pointer()) + }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(large.as_pointer(), small.as_pointer(),) }) + ({ + p1_user_written_three_way_Money::operator_cmp(large.as_pointer(), small.as_pointer()) + }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(small.as_pointer(), small.as_pointer(),) }) + ({ + p1_user_written_three_way_Money::operator_cmp(small.as_pointer(), small.as_pointer()) + }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(large.as_pointer(), small.as_pointer(),) }) + ({ + p1_user_written_three_way_Money::operator_cmp(large.as_pointer(), small.as_pointer()) + }) )); assert!((three_way_calls_1.with(|rc| *rc.borrow()) == 5)); - assert!(({ WeaklyEqualityComparableWith::equal(small.as_pointer(), small.as_pointer(),) })); + assert!( + ({ p1_user_written_three_way_Money::operator_eq(small.as_pointer(), small.as_pointer(),) }) + ); assert!((three_way_calls_1.with(|rc| *rc.borrow()) == 5)); } #[derive( @@ -169,20 +398,19 @@ pub fn test_2() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct p1_weaker_category_Temperature { #[offset(0)] pub degrees: f64, } -impl ThreeWayComparable for p1_weaker_category_Temperature { - type Category = libcc2rs::PartialOrdering; - fn three_way( +impl p1_weaker_category_Temperature { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.degrees) } == { other.with(|__s| __s.degrees) }); + } + pub fn operator_cmp( this: Ptr, other: Ptr, ) -> libcc2rs::PartialOrdering { @@ -192,6 +420,100 @@ impl ThreeWayComparable for p1_weaker_category_Temperature { )); } } +impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for p1_weaker_category_Temperature { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl PartiallyOrderedWith for p1_weaker_category_Temperature { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + ); + } +} +impl ThreeWayComparable for p1_weaker_category_Temperature { + type Category = libcc2rs::PartialOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } +} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( !(false), @@ -207,14 +529,14 @@ pub fn test_3() { degrees: 21.5_f64, })); let order: Value = Rc::new(RefCell::new( - ({ ThreeWayComparable::three_way(cold.as_pointer(), warm.as_pointer()) }), + ({ p1_weaker_category_Temperature::operator_cmp(cold.as_pointer(), warm.as_pointer()) }), )); assert!(libcc2rs::is_lt(({ (*order.borrow()) }))); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(cold.as_pointer(), warm.as_pointer(),) }) + ({ p1_weaker_category_Temperature::operator_cmp(cold.as_pointer(), warm.as_pointer(),) }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(warm.as_pointer(), cold.as_pointer(),) }) + ({ p1_weaker_category_Temperature::operator_cmp(warm.as_pointer(), cold.as_pointer(),) }) )); } #[derive( @@ -228,11 +550,8 @@ pub fn test_3() { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(p1_three_way_without_equality_Rank::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct p1_three_way_without_equality_Rank { @@ -250,6 +569,75 @@ impl p1_three_way_without_equality_Rank { )); } } +impl LessThanComparable for p1_three_way_without_equality_Rank { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} +impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} const _: () = assert!(!(false), "!std::three_way_comparable"); pub fn test_4() { let low: Value = @@ -287,22 +675,6 @@ fn main_0() -> i32 { ({ test_4() }); return 0; } -impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.major) } == { _a0.with(|__s| __s.major) }) - && ({ this.with(|__s| __s.minor) } == { _a0.with(|__s| __s.minor) }); - } -} -impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.cents) } == { other.with(|__s| __s.cents) }); - } -} -impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { - fn equal(this: Ptr, other: Ptr) -> bool { - return ({ this.with(|__s| __s.degrees) } == { other.with(|__s| __s.degrees) }); - } -} pub fn __cpp2rust_init_globals() { let _ = three_way_calls_1.with(|_| ()); } diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index 3efb3e9381..d1391ae638 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -16,19 +16,15 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_defaulted_three_way_Version { pub major: i32, pub minor: i32, } -impl ThreeWayComparableUnsafe for p1_defaulted_three_way_Version { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( +impl p1_defaulted_three_way_Version { + pub unsafe fn operator_cmp( this: *const Self, _a0: *const p1_defaulted_three_way_Version, ) -> libcc2rs::StrongOrdering { @@ -50,6 +46,108 @@ impl ThreeWayComparableUnsafe for p1_defaulted_three_way_Version { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq( + this: *const Self, + _a0: *const p1_defaulted_three_way_Version, + ) -> bool { + return (((*this).major) == ((*_a0).major)) && (((*this).minor) == ((*_a0).minor)); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return (unsafe { + p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return !(unsafe { + p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return libcc2rs::is_lt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return libcc2rs::is_lt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return libcc2rs::is_gt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return libcc2rs::is_lteq( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return libcc2rs::is_gteq( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl ThreeWayComparableUnsafe for p1_defaulted_three_way_Version { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + return (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }); + } } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -61,29 +159,36 @@ pub unsafe fn test_0() { p1_defaulted_three_way_Version { major: 1, minor: 9 }; let mut new_version: p1_defaulted_three_way_Version = p1_defaulted_three_way_Version { major: 2, minor: 0 }; - let mut order: libcc2rs::StrongOrdering = - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const old_version, &new_version) }); + let mut order: libcc2rs::StrongOrdering = (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const old_version, &new_version) + }); assert!(libcc2rs::is_lt(order)); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const new_version, &old_version,) }) + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const new_version, &old_version) + }) )); assert!(libcc2rs::is_eq( (unsafe { let _arg0: *const p1_defaulted_three_way_Version = &old_version; - ThreeWayComparableUnsafe::three_way(&raw const old_version, _arg0) + p1_defaulted_three_way_Version::operator_cmp(&raw const old_version, _arg0) }) )); assert!( (unsafe { let _arg0: *const p1_defaulted_three_way_Version = &old_version; - WeaklyEqualityComparableWithUnsafe::equal(&raw const old_version, _arg0) + p1_defaulted_three_way_Version::operator_eq(&raw const old_version, _arg0) }) ); assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const old_version, &new_version,) }) + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const old_version, &new_version) + }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const new_version, &old_version,) }) + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const new_version, &old_version) + }) )); } pub static mut three_way_calls_1: std::cell::LazyCell = @@ -98,18 +203,20 @@ pub static mut three_way_calls_1: std::cell::LazyCell = TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_user_written_three_way_Money { pub cents: i32, } -impl ThreeWayComparableUnsafe for p1_user_written_three_way_Money { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( +impl p1_user_written_three_way_Money { + pub unsafe fn operator_eq( + this: *const Self, + other: *const p1_user_written_three_way_Money, + ) -> bool { + return (((*this).cents) == ((*other).cents)); + } + pub unsafe fn operator_cmp( this: *const Self, other: *const p1_user_written_three_way_Money, ) -> libcc2rs::StrongOrdering { @@ -120,33 +227,129 @@ impl ThreeWayComparableUnsafe for p1_user_written_three_way_Money { )); } } +impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return (unsafe { + p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return !(unsafe { + p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_user_written_three_way_Money { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return libcc2rs::is_lt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return libcc2rs::is_lt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return libcc2rs::is_gt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return libcc2rs::is_lteq( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return libcc2rs::is_gteq( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl ThreeWayComparableUnsafe for p1_user_written_three_way_Money { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + return (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }); + } +} const _: () = assert!(true, "std::three_way_comparable"); pub unsafe fn test_2() { let mut small: p1_user_written_three_way_Money = p1_user_written_three_way_Money { cents: 150 }; let mut large: p1_user_written_three_way_Money = p1_user_written_three_way_Money { cents: 900 }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const small, &large,) }) + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const small, &large,) }) )); assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const small, &large,) }) + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const small, &large,) }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const large, &small,) }) + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const large, &small,) }) )); assert!(libcc2rs::is_lteq( (unsafe { let _other: *const p1_user_written_three_way_Money = &small; - ThreeWayComparableUnsafe::three_way(&raw const small, _other) + p1_user_written_three_way_Money::operator_cmp(&raw const small, _other) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const large, &small,) }) + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const large, &small,) }) )); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut three_way_calls_1)) == (5))); assert!( (unsafe { let _other: *const p1_user_written_three_way_Money = &small; - WeaklyEqualityComparableWithUnsafe::equal(&raw const small, _other) + p1_user_written_three_way_Money::operator_eq(&raw const small, _other) }) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut three_way_calls_1)) == (5))); @@ -161,18 +364,20 @@ pub unsafe fn test_2() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_weaker_category_Temperature { pub degrees: f64, } -impl ThreeWayComparableUnsafe for p1_weaker_category_Temperature { - type Category = libcc2rs::PartialOrdering; - unsafe fn three_way( +impl p1_weaker_category_Temperature { + pub unsafe fn operator_eq( + this: *const Self, + other: *const p1_weaker_category_Temperature, + ) -> bool { + return (((*this).degrees) == ((*other).degrees)); + } + pub unsafe fn operator_cmp( this: *const Self, other: *const p1_weaker_category_Temperature, ) -> libcc2rs::PartialOrdering { @@ -182,6 +387,102 @@ impl ThreeWayComparableUnsafe for p1_weaker_category_Temperature { )); } } +impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return (unsafe { + p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return !(unsafe { + p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for p1_weaker_category_Temperature { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return libcc2rs::is_lt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return libcc2rs::is_lt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return libcc2rs::is_gt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return libcc2rs::is_lteq( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return libcc2rs::is_gteq( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + ); + } +} +impl ThreeWayComparableUnsafe for p1_weaker_category_Temperature { + type Category = libcc2rs::PartialOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + return (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }); + } +} const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( !(false), @@ -193,13 +494,13 @@ pub unsafe fn test_3() { let mut warm: p1_weaker_category_Temperature = p1_weaker_category_Temperature { degrees: 21.5_f64 }; let mut order: libcc2rs::PartialOrdering = - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const cold, &warm) }); + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const cold, &warm) }); assert!(libcc2rs::is_lt(order)); assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const cold, &warm,) }) + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const cold, &warm,) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const warm, &cold,) }) + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const warm, &cold,) }) )); } #[repr(C)] @@ -212,11 +513,8 @@ pub unsafe fn test_3() { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(p1_three_way_without_equality_Rank::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct p1_three_way_without_equality_Rank { pub value: i32, @@ -232,6 +530,75 @@ impl p1_three_way_without_equality_Rank { )); } } +impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + return libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + return libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + return libcc2rs::is_gt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + return libcc2rs::is_lteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + return libcc2rs::is_gteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} const _: () = assert!(!(false), "!std::three_way_comparable"); pub unsafe fn test_4() { let mut low: p1_three_way_without_equality_Rank = @@ -261,21 +628,6 @@ unsafe fn main_0() -> i32 { (unsafe { test_4() }); return 0; } -impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { - unsafe fn equal(this: *const Self, _a0: *const p1_defaulted_three_way_Version) -> bool { - return (((*this).major) == ((*_a0).major)) && (((*this).minor) == ((*_a0).minor)); - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { - unsafe fn equal(this: *const Self, other: *const p1_user_written_three_way_Money) -> bool { - return (((*this).cents) == ((*other).cents)); - } -} -impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { - unsafe fn equal(this: *const Self, other: *const p1_weaker_category_Temperature) -> bool { - return (((*this).degrees) == ((*other).degrees)); - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const three_way_calls_1); } diff --git a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs index 35d80cdd12..4d75a753ae 100644 --- a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs @@ -156,36 +156,103 @@ pub fn test_4() { Rc::new(RefCell::new(0)), ))); assert!( - !(WeaklyEqualityComparableWith::equal( - (*a.borrow()).0.as_pointer(), - (*b.borrow()).0.as_pointer() - ) && WeaklyEqualityComparableWith::equal( - (*a.borrow()).1.as_pointer(), - (*b.borrow()).1.as_pointer() - )) + !(ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + LvalueRef::>::bind((*b.borrow()).0.as_pointer()) + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*b.borrow()).1.as_pointer()) + ))) ); assert!( ({ - !(!(WeaklyEqualityComparableWith::equal( - (*a.borrow()).0.as_pointer(), - (*a.borrow()).0.as_pointer(), - ) && WeaklyEqualityComparableWith::equal( - (*a.borrow()).1.as_pointer(), - (*a.borrow()).1.as_pointer(), - ))) + !(!(ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + )))) }) ); - assert!(LessThanComparable::less(a.as_pointer(), b.as_pointer())); - assert!(!(LessThanComparable::less(b.as_pointer(), a.as_pointer()))); - assert!(LessThanComparable::less(b.as_pointer(), c.as_pointer())); - assert!(!LessThanComparable::less(a.as_pointer(), a.as_pointer())); - assert!(!(!LessThanComparable::less(b.as_pointer(), c.as_pointer()))); - assert!(LessThanComparable::less(b.as_pointer(), c.as_pointer())); - assert!(!(LessThanComparable::less(a.as_pointer(), a.as_pointer()))); - assert!(!LessThanComparable::less(c.as_pointer(), a.as_pointer())); - assert!(!(!LessThanComparable::less(a.as_pointer(), b.as_pointer()))); - let mut ordered: bool = (LessThanComparable::less(a.as_pointer(), b.as_pointer())) - && (LessThanComparable::less(b.as_pointer(), c.as_pointer())); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(b.as_pointer()), + ))); + assert!( + !(ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), + ) + )) + ); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), + ))); + assert!(!ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), + ))); + assert!( + !(!ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), + ) + )) + ); + assert!(ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), + ))); + assert!( + !(ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), + ) + )) + ); + assert!(!ConvertibleTo::::convert_value(<( + Value, + Value + ) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(c.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), + ))); + assert!( + !(!ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(b.as_pointer()), + ) + )) + ); + let mut ordered: bool = (ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(b.as_pointer()), + ), + )) && (ConvertibleTo::::convert_value( + <(Value, Value) as LessThanComparable>::less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), + ), + )); assert!(ordered); } pub fn test_5() { @@ -257,24 +324,24 @@ pub fn test_7() { ))); assert!( ({ - WeaklyEqualityComparableWith::equal( - (*to_x.borrow()).0.as_pointer(), - (*to_y.borrow()).0.as_pointer(), - ) && WeaklyEqualityComparableWith::equal( - (*to_x.borrow()).1.as_pointer(), - (*to_y.borrow()).1.as_pointer(), - ) + ConvertibleTo::::convert_value(>::equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), + LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), + )) }) ); (*y.borrow_mut()) = 5; assert!( - !(WeaklyEqualityComparableWith::equal( - (*to_x.borrow()).0.as_pointer(), - (*to_y.borrow()).0.as_pointer() - ) && WeaklyEqualityComparableWith::equal( - (*to_x.borrow()).1.as_pointer(), - (*to_y.borrow()).1.as_pointer() - )) + !(ConvertibleTo::::convert_value(>::equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()) + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), + LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()) + ))) ); } pub fn test_8() { diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index ca2b64b432..2260933e01 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -172,24 +172,96 @@ pub unsafe fn test_4() { let mut b: (i32, i32) = (1, 3); let mut c: (i32, i32) = (2, 0); assert!( - !(WeaklyEqualityComparableWithUnsafe::equal(&a.0, &b.0) - && WeaklyEqualityComparableWithUnsafe::equal(&a.1, &b.1)) + !(ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a.0), + LvalueRefUnsafe::>::bind(&raw const b.0) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a.1), + LvalueRefUnsafe::>::bind(&raw const b.1) + ),)) ); assert!( - !(!(WeaklyEqualityComparableWithUnsafe::equal(&a.0, &a.0) - && WeaklyEqualityComparableWithUnsafe::equal(&a.1, &a.1))) + !(!(ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a.0), + LvalueRefUnsafe::>::bind(&raw const a.0) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const a.1), + LvalueRefUnsafe::>::bind(&raw const a.1) + ),))) ); - assert!(LessThanComparableUnsafe::less(&a, &b)); - assert!(!(LessThanComparableUnsafe::less(&b, &a))); - assert!(LessThanComparableUnsafe::less(&b, &c)); - assert!(!LessThanComparableUnsafe::less(&a, &a)); - assert!(!(!LessThanComparableUnsafe::less(&b, &c))); - assert!(LessThanComparableUnsafe::less(&b, &c)); - assert!(!(LessThanComparableUnsafe::less(&a, &a))); - assert!(!LessThanComparableUnsafe::less(&c, &a)); - assert!(!(!LessThanComparableUnsafe::less(&a, &b))); - let mut ordered: bool = - (LessThanComparableUnsafe::less(&a, &b)) && (LessThanComparableUnsafe::less(&b, &c)); + assert!(ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&raw const b), + ) + )); + assert!( + !(ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&raw const a), + ) + )) + ); + assert!(ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&raw const c), + ) + )); + assert!(!ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&raw const a), + ) + )); + assert!( + !(!ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&raw const c), + ) + )) + ); + assert!(ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&raw const c), + ) + )); + assert!( + !(ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&raw const a), + ) + )) + ); + assert!(!ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const c), + LvalueRefUnsafe::>::bind(&raw const a), + ) + )); + assert!( + !(!ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&raw const b), + ) + )) + ); + let mut ordered: bool = (ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&raw const b), + ), + )) && (ConvertibleToUnsafe::::convert_value( + <(i32, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&raw const c), + ), + )); assert!(ordered); } pub unsafe fn test_5() { @@ -236,13 +308,23 @@ pub unsafe fn test_7() { let mut to_x: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut x), 0); let mut to_y: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut y), 0); assert!( - WeaklyEqualityComparableWithUnsafe::equal(&to_x.0, &to_y.0) - && WeaklyEqualityComparableWithUnsafe::equal(&to_x.1, &to_y.1) + ConvertibleToUnsafe::::convert_value(<*mut i32>::equal( + LvalueRefUnsafe::>>::bind(&raw const to_x.0), + LvalueRefUnsafe::>>::bind(&raw const to_y.0) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const to_x.1), + LvalueRefUnsafe::>::bind(&raw const to_y.1) + ),) ); y = 5; assert!( - !(WeaklyEqualityComparableWithUnsafe::equal(&to_x.0, &to_y.0) - && WeaklyEqualityComparableWithUnsafe::equal(&to_x.1, &to_y.1)) + !(ConvertibleToUnsafe::::convert_value(<*mut i32>::equal( + LvalueRefUnsafe::>>::bind(&raw const to_x.0), + LvalueRefUnsafe::>>::bind(&raw const to_y.0) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&raw const to_x.1), + LvalueRefUnsafe::>::bind(&raw const to_y.1) + ),)) ); } pub unsafe fn test_8() { diff --git a/tests/ub/out/refcount/max.rs b/tests/ub/out/refcount/max.rs index b6361498e4..706563f24c 100644 --- a/tests/ub/out/refcount/max.rs +++ b/tests/ub/out/refcount/max.rs @@ -14,7 +14,10 @@ fn main_0() -> i32 { let a: Ptr = ({ let __tmp_0: Value = Rc::new(RefCell::new(2)); let __tmp_1: Value = Rc::new(RefCell::new(1)); - if LessThanComparable::less(__tmp_0.as_pointer().clone(), __tmp_1.as_pointer().clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_0.as_pointer().clone()), + LvalueRef::>::bind(__tmp_1.as_pointer().clone()), + )) { __tmp_0.as_pointer() } else { __tmp_1.as_pointer() @@ -23,7 +26,10 @@ fn main_0() -> i32 { let b: Ptr = ({ let __tmp_2: Value = Rc::new(RefCell::new(1)); let __tmp_3: Value = Rc::new(RefCell::new(2)); - if LessThanComparable::less(__tmp_2.as_pointer().clone(), __tmp_3.as_pointer().clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + LvalueRef::>::bind(__tmp_3.as_pointer().clone()), + )) { __tmp_3.as_pointer() } else { __tmp_2.as_pointer() diff --git a/tests/ub/out/unsafe/max.rs b/tests/ub/out/unsafe/max.rs index 8461548df3..cf6a7a0189 100644 --- a/tests/ub/out/unsafe/max.rs +++ b/tests/ub/out/unsafe/max.rs @@ -19,7 +19,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -32,7 +35,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 01d48a3621..2c3aea2601 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -107,6 +107,12 @@ impl Counter { }); return this.with(|__s| __s.v); } + pub fn operator_eq(this: Ptr, o: Ptr) -> bool { + field!(this, calls).with_mut(|__v| { + __v.prefix_inc(); + }); + return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); + } } #[derive( Copy, @@ -196,8 +202,8 @@ fn main_0() -> i32 { assert!((({ Counter::Get(c1.as_pointer(),) }) == 3)); assert!((({ Counter::Get(c2.as_pointer(),) }) == 3)); assert!((({ Counter::Get((pc).clone(),) }) == 3)); - assert!(({ WeaklyEqualityComparableWith::equal(c1.as_pointer(), c2.as_pointer(),) })); - assert!(({ WeaklyEqualityComparableWith::equal(c2.as_pointer(), c1.as_pointer(),) })); + assert!(({ Counter::operator_eq(c1.as_pointer(), c2.as_pointer(),) })); + assert!(({ Counter::operator_eq(c2.as_pointer(), c1.as_pointer(),) })); assert!(({ (*c1.borrow()).calls } == 3)); assert!(({ (*c2.borrow()).calls } == 2)); let t: Value = Rc::new(RefCell::new(Tally { calls: 0 })); @@ -210,12 +216,4 @@ fn main_0() -> i32 { assert!(({ (*ct.borrow()).calls } == 10)); return 0; } -impl WeaklyEqualityComparableWith for Counter { - fn equal(this: Ptr, o: Ptr) -> bool { - field!(this, calls).with_mut(|__v| { - __v.prefix_inc(); - }); - return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index c4bb6c21e0..2eb597788b 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -42,7 +42,10 @@ pub fn sum_1(v: Ptr>) -> i32 { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { (__tmp_0,) => { - WeaklyEqualityComparableWith::not_equal(it.as_pointer(), (__tmp_0).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_0).clone()), + )) } } { 'for_body: { diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 36d2db9828..82a59a2dd4 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -473,7 +473,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(vec_.decay().begin())); let __last: Value> = Rc::new(RefCell::new(vec_.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index d094221826..6efbc29b4d 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -28,12 +28,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_2.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -43,7 +44,10 @@ fn main_0() -> i32 { assert!( match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { (__tmp_3,) => { - WeaklyEqualityComparableWith::not_equal(it.as_pointer(), (__tmp_3).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_3).clone()), + )) } } ); diff --git a/tests/unit/out/refcount/emplace_receiver_alias.rs b/tests/unit/out/refcount/emplace_receiver_alias.rs index 7fc1217ace..51d28dd1c2 100644 --- a/tests/unit/out/refcount/emplace_receiver_alias.rs +++ b/tests/unit/out/refcount/emplace_receiver_alias.rs @@ -36,7 +36,10 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( (alias).decay().offset(0_usize).decay().offset((3) as isize), )); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/emplace_receiver_order.rs b/tests/unit/out/refcount/emplace_receiver_order.rs index cb369b1ee9..69e28f4a85 100644 --- a/tests/unit/out/refcount/emplace_receiver_order.rs +++ b/tests/unit/out/refcount/emplace_receiver_order.rs @@ -43,8 +43,10 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -70,8 +72,10 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index f665062c8d..29a98c29e0 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -25,6 +25,11 @@ pub struct P { #[offset(0)] pub x: i32, } +impl P { + pub fn operator_eq(this: Ptr, o: Ptr

) -> bool { + return ({ this.with(|__s| __s.x) } == { o.with(|__s| __s.x) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -53,12 +58,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(({ (*v_begin.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new(({ (*v_end.borrow()).clone() }))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_3.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_3.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -66,7 +72,12 @@ fn main_0() -> i32 { }), )); let mut v_result_true: bool = match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { - (__tmp_4,) => WeaklyEqualityComparableWith::not_equal(it.as_pointer(), (__tmp_4).clone()), + (__tmp_4,) => { + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_4).clone()), + )) + } }; let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { @@ -96,7 +107,14 @@ fn main_0() -> i32 { .with(|__m: &Map, Value)>| __m.end()), )); let mut m_result_true: bool = - WeaklyEqualityComparableWith::not_equal(m_begin.as_pointer(), m_end.as_pointer()); + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::, Value)>>>::bind( + m_begin.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + m_end.as_pointer(), + ), + )); assert!( ((v_result_true) && (m_result_true)) && (match ( @@ -108,13 +126,19 @@ fn main_0() -> i32 { Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().begin())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_9.as_pointer().clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind( + __it.as_pointer(), + ), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_9.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -125,7 +149,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(v.decay().begin())).as_pointer(), ) { (__tmp_8, __tmp_10) => { - WeaklyEqualityComparableWith::equal((__tmp_8).clone(), (__tmp_10).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_8).clone()), + LvalueRef::>>::bind((__tmp_10).clone()), + )) } }) ); @@ -139,13 +166,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_12.as_pointer().clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_12.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -156,7 +187,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(3_isize))).as_pointer(), ) { (__tmp_11, __tmp_13) => { - WeaklyEqualityComparableWith::equal((__tmp_11).clone(), (__tmp_13).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_11).clone()), + LvalueRef::>>::bind((__tmp_13).clone()), + )) } }); assert!(match ( @@ -168,13 +202,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_15.as_pointer().clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -185,7 +223,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().end())).as_pointer(), ) { (__tmp_14, __tmp_16) => { - WeaklyEqualityComparableWith::equal((__tmp_14).clone(), (__tmp_16).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_14).clone()), + LvalueRef::>>::bind((__tmp_16).clone()), + )) } }); assert!(match ( @@ -197,13 +238,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_18.as_pointer().clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_18.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -214,7 +259,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))).as_pointer(), ) { (__tmp_17, __tmp_19) => { - WeaklyEqualityComparableWith::equal((__tmp_17).clone(), (__tmp_19).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_17).clone()), + LvalueRef::>>::bind((__tmp_19).clone()), + )) } }); let p: Value> = Rc::new(RefCell::new(Vec::from([ @@ -231,13 +279,15 @@ fn main_0() -> i32 { Rc::new(RefCell::new(p.decay().begin())); let __last: Value> = Rc::new(RefCell::new(p.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - (__tmp_21.as_pointer()).clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value(

::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -248,14 +298,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(p.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_22) => { - WeaklyEqualityComparableWith::equal((__tmp_20).clone(), (__tmp_22).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_20).clone()), + LvalueRef::>>::bind((__tmp_22).clone()), + )) } }); return 0; } -impl WeaklyEqualityComparableWith for P { - fn equal(this: Ptr, o: Ptr

) -> bool { - return ({ this.with(|__s| __s.x) } == { o.with(|__s| __s.x) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index b2098a0d9d..da0920398f 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -9,10 +9,13 @@ use std::rc::{Rc, Weak}; pub fn get_0(v: Ptr) -> i32 { return v.with(|__s| __s.x); } -pub fn scaled_1(v: Ptr, mut k: i32) -> i32 { +pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.x) } == { b.with(|__s| __s.x) }); +} +pub fn scaled_2(v: Ptr, mut k: i32) -> i32 { return ({ v.with(|__s| __s.x) } * { k }); } -pub fn scaled_2(v: Ptr, mut k: f64) -> f64 { +pub fn scaled_3(v: Ptr, mut k: f64) -> f64 { return ({ (v.with(|__s| __s.x) as f64) } * { k }); } #[derive( @@ -34,7 +37,7 @@ pub struct V { #[offset(0)] pub x: i32, } -pub fn get_3(w: Ptr) -> i32 { +pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } #[derive( @@ -56,7 +59,7 @@ pub struct W_int_ { #[offset(0)] pub x: i32, } -pub fn get_4(w: Ptr) -> i64 { +pub fn get_5(w: Ptr) -> i64 { return w.with(|__s| __s.x); } #[derive( @@ -97,7 +100,7 @@ pub struct D { #[offset(0)] pub x: i32, } -pub fn declared_then_defined_5(d: Ptr) -> i32 { +pub fn declared_then_defined_6(d: Ptr) -> i32 { return (d.with(|__s| __s.x) + 1); } pub fn main() { @@ -109,21 +112,16 @@ fn main_0() -> i32 { let b: Value = Rc::new(RefCell::new(V { x: 3 })); let c: Value = Rc::new(RefCell::new(V { x: 4 })); assert!((({ get_0(a.as_pointer(),) }) == 3)); - assert!(({ WeaklyEqualityComparableWith::equal(a.as_pointer(), b.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(a.as_pointer(), c.as_pointer(),) })); - assert!((({ scaled_1(c.as_pointer(), 2,) }) == 8)); - assert!((({ scaled_2(c.as_pointer(), 1.5_f64,) }) == 6_f64)); + assert!(({ operator_eq_1(a.as_pointer(), b.as_pointer(),) })); + assert!(!({ operator_eq_1(a.as_pointer(), c.as_pointer(),) })); + assert!((({ scaled_2(c.as_pointer(), 2,) }) == 8)); + assert!((({ scaled_3(c.as_pointer(), 1.5_f64,) }) == 6_f64)); let wi: Value = Rc::new(RefCell::new(W_int_ { x: 5 })); let wl: Value = Rc::new(RefCell::new(W_long_ { x: 6_i64 })); - assert!((({ get_3(wi.as_pointer(),) }) == 5)); - assert!((({ get_4(wl.as_pointer(),) }) == 6_i64)); + assert!((({ get_4(wi.as_pointer(),) }) == 5)); + assert!((({ get_5(wl.as_pointer(),) }) == 6_i64)); let d: Value = Rc::new(RefCell::new(D { x: 7 })); - assert!((({ declared_then_defined_5(d.as_pointer(),) }) == 8)); + assert!((({ declared_then_defined_6(d.as_pointer(),) }) == 8)); return 0; } -impl WeaklyEqualityComparableWith for V { - fn equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.x) } == { b.with(|__s| __s.x) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index 91d788b618..2b19008931 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -18,10 +18,10 @@ thread_local!( ({ __tmp_0 = Rc::new(RefCell::new(0)); __tmp_1 = Rc::new(RefCell::new(0)); - if LessThanComparable::less( - __tmp_0.as_pointer().clone(), - __tmp_1.as_pointer().clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_0.as_pointer().clone()), + LvalueRef::>::bind(__tmp_1.as_pointer().clone()), + )) { __tmp_0.as_pointer() } else { __tmp_1.as_pointer() @@ -46,10 +46,10 @@ thread_local!( let __rhs = { __tmp_2 = Rc::new(RefCell::new(6)); __tmp_3 = Rc::new(RefCell::new(5)); - (if LessThanComparable::less( - __tmp_2.as_pointer().clone(), - __tmp_3.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + LvalueRef::>::bind(__tmp_3.as_pointer().clone()), + )) { __tmp_2.as_pointer() } else { __tmp_3.as_pointer() @@ -71,10 +71,10 @@ thread_local!( let __rhs = { __tmp_4 = Rc::new(RefCell::new(1)); __tmp_5 = Rc::new(RefCell::new(2)); - (if LessThanComparable::less( - __tmp_4.as_pointer().clone(), - __tmp_5.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_4.as_pointer().clone()), + LvalueRef::>::bind(__tmp_5.as_pointer().clone()), + )) { __tmp_5.as_pointer() } else { __tmp_4.as_pointer() @@ -140,10 +140,10 @@ thread_local!( __tmp_7 = Rc::new(RefCell::new(Box::new([{ __tmp_8 = Rc::new(RefCell::new(4)); __tmp_9 = Rc::new(RefCell::new(3)); - (if LessThanComparable::less( - __tmp_8.as_pointer().clone(), - __tmp_9.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_8.as_pointer().clone()), + LvalueRef::>::bind(__tmp_9.as_pointer().clone()), + )) { __tmp_8.as_pointer() } else { __tmp_9.as_pointer() @@ -156,10 +156,10 @@ thread_local!( value: { __tmp_11 = Rc::new(RefCell::new(5)); __tmp_12 = Rc::new(RefCell::new(6)); - (if LessThanComparable::less( - __tmp_11.as_pointer().clone(), - __tmp_12.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_11.as_pointer().clone()), + LvalueRef::>::bind(__tmp_12.as_pointer().clone()), + )) { __tmp_12.as_pointer() } else { __tmp_11.as_pointer() @@ -183,10 +183,10 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_13 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if LessThanComparable::less( - __tmp_13.as_pointer().clone(), - left_10.with(|v| v.as_pointer()).clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_13.as_pointer().clone()), + LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), + )) { __tmp_13.as_pointer() } else { left_10.with(|v| v.as_pointer()) @@ -205,10 +205,10 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_14 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if LessThanComparable::less( - left_10.with(|v| v.as_pointer()).clone(), - __tmp_14.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), + LvalueRef::>::bind(__tmp_14.as_pointer().clone()), + )) { __tmp_14.as_pointer() } else { left_10.with(|v| v.as_pointer()) @@ -245,10 +245,10 @@ thread_local!( __tmp_15 = Rc::new(RefCell::new(Box::new([{ __tmp_16 = Rc::new(RefCell::new(7)); __tmp_17 = Rc::new(RefCell::new(8)); - (if LessThanComparable::less( - __tmp_16.as_pointer().clone(), - __tmp_17.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_16.as_pointer().clone()), + LvalueRef::>::bind(__tmp_17.as_pointer().clone()), + )) { __tmp_17.as_pointer() } else { __tmp_16.as_pointer() @@ -261,10 +261,10 @@ thread_local!( value: { __tmp_19 = Rc::new(RefCell::new(10)); __tmp_20 = Rc::new(RefCell::new(9)); - (if LessThanComparable::less( - __tmp_19.as_pointer().clone(), - __tmp_20.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_19.as_pointer().clone()), + LvalueRef::>::bind(__tmp_20.as_pointer().clone()), + )) { __tmp_19.as_pointer() } else { __tmp_20.as_pointer() diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index d4c16f8bde..7ab48ae425 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -230,7 +230,10 @@ fn main_0() -> i32 { }), ), )); - let mut x1: u32 = if WeaklyEqualityComparableWith::equal(it.as_pointer(), end.as_pointer()) { + let mut x1: u32 = if ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind(it.as_pointer()), + LvalueRef::, Value)>>>::bind(end.as_pointer()), + )) { 0_u32 } else { (*(*({ (*it.borrow()).iter_deref() }).upgrade().deref()) @@ -244,9 +247,14 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_20,) => { - WeaklyEqualityComparableWith::equal(const_it.as_pointer(), (__tmp_20).clone()) - } + (__tmp_20,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + const_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_20).clone(), + ), + )), } { 0_u32 } else { @@ -261,7 +269,14 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_21,) => WeaklyEqualityComparableWith::equal(it.as_pointer(), (__tmp_21).clone()), + (__tmp_21,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_21).clone(), + ), + )), } { 0_u32 } else { @@ -279,9 +294,14 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_22,) => { - WeaklyEqualityComparableWith::equal(const_it.as_pointer(), (__tmp_22).clone()) - } + (__tmp_22,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + const_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_22).clone(), + ), + )), } { 0_u32 } else { @@ -387,7 +407,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_28, __tmp_30) => { - WeaklyEqualityComparableWith::not_equal((__tmp_28).clone(), (__tmp_30).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::, Value)>>>::bind( + (__tmp_28).clone(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_30).clone(), + ), + )) } }); Map::erase((r).clone(), &({ (*it4.borrow()).clone() })); @@ -410,7 +437,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_31, __tmp_33) => { - WeaklyEqualityComparableWith::equal((__tmp_31).clone(), (__tmp_33).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + (__tmp_31).clone(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_33).clone(), + ), + )) } }); match (Rc::new(RefCell::new(7_i16)).as_pointer(),) { @@ -470,7 +504,14 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_40,) => { - WeaklyEqualityComparableWith::equal(next.as_pointer(), (__tmp_40).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + next.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_40).clone(), + ), + )) } }); { @@ -483,7 +524,14 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_42,) => { - WeaklyEqualityComparableWith::equal(next.as_pointer(), (__tmp_42).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + next.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_42).clone(), + ), + )) } }); assert!(({ ((*r.upgrade().deref()).len() == 3_usize) })); @@ -505,7 +553,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_43, __tmp_45) => { - WeaklyEqualityComparableWith::equal((__tmp_43).clone(), (__tmp_45).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + (__tmp_43).clone(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_45).clone(), + ), + )) } }); let other_map: Value< diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index c8c3306cea..5863858e55 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -41,10 +41,16 @@ impl Key { field!(this, k).write(o.with(|__s| __s.k)); (*moves_1.with(Value::clone).borrow_mut()).prefix_inc(); } + pub fn operator_lt(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.k) } < { o.with(|__s| __s.k) }); + } } impl LessThanComparable for Key { - fn less(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.k) } < { o.with(|__s| __s.k) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Key::operator_lt((__lhs).clone(), (__rhs).clone()) }); } } pub fn make_key_3(__return: Ptr, mut k: i32) { diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 9140286dc0..8a16161983 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -31,10 +31,19 @@ pub struct Key { pub identity: i32, } impl LessThanComparable for Key { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.order) } < { b.with(|__s| __s.order) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.order) } < { b.with(|__s| __s.order) }); +} +pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); +} #[derive( Copy, Clone, @@ -85,11 +94,7 @@ fn main_0() -> i32 { identity: 7, })); ok = { - ((ok as i32) - & ((WeaklyEqualityComparableWith::equal( - distinct_a.as_pointer(), - distinct_b.as_pointer(), - )) as i32)) + ((ok as i32) & ((operator_eq_2(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) != 0 }; let distinct: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -120,45 +125,13 @@ fn main_0() -> i32 { != 0 }; ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(distinct.as_pointer().with( - |__m: &Map, Value)>| __m.find(&distinct_a.as_pointer()), - ))) - .as_pointer(),) - { - (__tmp_0,) => { - WeaklyEqualityComparableWith::equal(a_it.as_pointer(), (__tmp_0).clone()) - } - }) as i32)) - != 0 + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.find(&distinct_a .as_pointer() )) )).as_pointer(),) { (__tmp_0,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(a_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_0 ).clone()), )) } } ) ) as i32 ) ) != 0 }; ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(distinct.as_pointer().with( - |__m: &Map, Value)>| __m.find(&distinct_b.as_pointer()), - ))) - .as_pointer(),) - { - (__tmp_1,) => { - WeaklyEqualityComparableWith::equal(b_it.as_pointer(), (__tmp_1).clone()) - } - }) as i32)) - != 0 + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.find(&distinct_b .as_pointer() )) )).as_pointer(),) { (__tmp_1,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(b_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_1 ).clone()), )) } } ) ) as i32 ) ) != 0 }; ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new( - distinct - .as_pointer() - .with(|__m: &Map, Value)>| __m.end()), - )) - .as_pointer(),) - { - (__tmp_2,) => { - WeaklyEqualityComparableWith::not_equal(b_it.as_pointer(), (__tmp_2).clone()) - } - }) as i32)) - != 0 + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.end()) )).as_pointer(),) { (__tmp_2,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( LvalueRef::, Value) > >>::bind(b_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_2 ).clone()), )) } } ) ) as i32 ) ) != 0 }; ok = { ((ok as i32) @@ -176,11 +149,7 @@ fn main_0() -> i32 { != 0 }; ok = { - ((ok as i32) - & ((WeaklyEqualityComparableWith::equal( - distinct_a.as_pointer(), - distinct_b.as_pointer(), - )) as i32)) + ((ok as i32) & ((operator_eq_2(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) != 0 }; let mut distinct_count: usize = 0_usize; @@ -223,12 +192,7 @@ fn main_0() -> i32 { })); ok = { ((ok as i32) - & (!({ - WeaklyEqualityComparableWith::equal( - equivalent_a.as_pointer(), - equivalent_b.as_pointer(), - ) - }) as i32)) + & (!({ operator_eq_2(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) != 0 }; let equivalent: Value, Value)>> = @@ -259,55 +223,76 @@ fn main_0() -> i32 { ok = { ((ok as i32) & (reused as i32)) != 0 }; ok = { ((ok as i32) & (((*equivalent.borrow()).len() == 1_usize) as i32)) != 0 }; if reused { - ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new( - equivalent - .as_pointer() - .with(|__m: &Map, Value)>| __m.end()), - )) - .as_pointer(),) - { - (__tmp_3,) => WeaklyEqualityComparableWith::not_equal( - first_it.as_pointer(), - (__tmp_3).clone(), - ), - }) as i32)) - != 0 - }; + ok = + { + ((ok as i32) + & ((match (Rc::new(RefCell::new( + equivalent + .as_pointer() + .with(|__m: &Map, Value)>| __m.end()), + )) + .as_pointer(),) + { + (__tmp_3,) => ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::not_equal( + LvalueRef::< + Const, Value)>>, + >::bind(first_it.as_pointer()), + LvalueRef::< + Const, Value)>>, + >::bind((__tmp_3).clone()), + ), + ), + }) as i32)) + != 0 + }; ok = { ((ok as i32) & (({ (first).clone() } == { (second).clone() }) as i32)) != 0 }; - ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_a.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_4,) => WeaklyEqualityComparableWith::equal( - first_it.as_pointer(), - (__tmp_4).clone(), - ), - }) as i32)) - != 0 - }; - ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_b.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_5,) => WeaklyEqualityComparableWith::equal( - first_it.as_pointer(), - (__tmp_5).clone(), - ), - }) as i32)) - != 0 - }; + ok = + { + ((ok as i32) + & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( + |__m: &Map, Value)>| { + __m.find(&equivalent_a.as_pointer()) + }, + ))) + .as_pointer(),) + { + (__tmp_4,) => ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::equal( + LvalueRef::< + Const, Value)>>, + >::bind(first_it.as_pointer()), + LvalueRef::< + Const, Value)>>, + >::bind((__tmp_4).clone()), + ), + ), + }) as i32)) + != 0 + }; + ok = + { + ((ok as i32) + & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( + |__m: &Map, Value)>| { + __m.find(&equivalent_b.as_pointer()) + }, + ))) + .as_pointer(),) + { + (__tmp_5,) => ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::equal( + LvalueRef::< + Const, Value)>>, + >::bind(first_it.as_pointer()), + LvalueRef::< + Const, Value)>>, + >::bind((__tmp_5).clone()), + ), + ), + }) as i32)) + != 0 + }; ok = { ((ok as i32) & (({ @@ -347,12 +332,7 @@ fn main_0() -> i32 { } ok = { ((ok as i32) - & (!({ - WeaklyEqualityComparableWith::equal( - equivalent_a.as_pointer(), - equivalent_b.as_pointer(), - ) - }) as i32)) + & (!({ operator_eq_2(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) != 0 }; let later_key: Value = Rc::new(RefCell::new(Key { @@ -369,22 +349,29 @@ fn main_0() -> i32 { }; ok = { ((ok as i32) & (((*equivalent.borrow()).len() == 2_usize) as i32)) != 0 }; if reused { - ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_a.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_6,) => WeaklyEqualityComparableWith::equal( - first_it.as_pointer(), - (__tmp_6).clone(), - ), - }) as i32)) - != 0 - }; + ok = + { + ((ok as i32) + & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( + |__m: &Map, Value)>| { + __m.find(&equivalent_a.as_pointer()) + }, + ))) + .as_pointer(),) + { + (__tmp_6,) => ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::equal( + LvalueRef::< + Const, Value)>>, + >::bind(first_it.as_pointer()), + LvalueRef::< + Const, Value)>>, + >::bind((__tmp_6).clone()), + ), + ), + }) as i32)) + != 0 + }; ok = { ((ok as i32) & (({ @@ -441,17 +428,7 @@ fn main_0() -> i32 { ok = { ((ok as i32) & (((*matching.borrow()).len() == 1_usize) as i32)) != 0 }; ok = { ((ok as i32) & (({ (matched).clone() } == { (matched_again).clone() }) as i32)) != 0 }; ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(matching.as_pointer().with( - |__m: &Map, Value)>| __m.find(&matching_b.as_pointer()), - ))) - .as_pointer(),) - { - (__tmp_7,) => { - WeaklyEqualityComparableWith::equal(matched_it.as_pointer(), (__tmp_7).clone()) - } - }) as i32)) - != 0 + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(matching .as_pointer() .with(|__m: &Map, Value)>| __m.find(&matching_b .as_pointer() )) )).as_pointer(),) { (__tmp_7,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(matched_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_7 ).clone()), )) } } ) ) as i32 ) ) != 0 }; ok = { ((ok as i32) @@ -478,17 +455,7 @@ fn main_0() -> i32 { }; ok = { ((ok as i32) & (((*matching.borrow()).len() == 2_usize) as i32)) != 0 }; ok = { - ((ok as i32) - & ((match (Rc::new(RefCell::new(matching.as_pointer().with( - |__m: &Map, Value)>| __m.find(&matching_a.as_pointer()), - ))) - .as_pointer(),) - { - (__tmp_8,) => { - WeaklyEqualityComparableWith::equal(matched_it.as_pointer(), (__tmp_8).clone()) - } - }) as i32)) - != 0 + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(matching .as_pointer() .with(|__m: &Map, Value)>| __m.find(&matching_a .as_pointer() )) )).as_pointer(),) { (__tmp_8,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(matched_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_8 ).clone()), )) } } ) ) as i32 ) ) != 0 }; ok = { ((ok as i32) @@ -507,11 +474,6 @@ fn main_0() -> i32 { }; return if ok { 0 } else { 1 }; } -impl WeaklyEqualityComparableWith for Key { - fn equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); - } -} pub fn __cpp2rust_init_globals() { let _ = default_constructions_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 9d4c95638a..79b1fd3c54 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -307,7 +307,7 @@ fn main_0() -> i32 { as i32)) != 0 }; - let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { WeaklyEqualityComparableWith::equal(({ (*result.borrow()) .0 .as_pointer() }), (__tmp_6 ).clone()) } } ; + let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(({ (*result.borrow()) .0 .as_pointer() })), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), )) } } ; ok = { ((ok as i32) & (found as i32)) != 0 }; ok = { ((ok as i32) diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 754e499b86..64b1b8e7b2 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -53,11 +53,17 @@ impl Bag { } } impl LessThanComparable for Bag { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.n) } < { b.with(|__s| __s.n) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); } } -pub fn make_4(__return: Ptr, mut n: i32) { +pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.n) } < { b.with(|__s| __s.n) }); +} +pub fn make_5(__return: Ptr, mut n: i32) { Bag::constructor_1(__return.clone(), n); return; } @@ -72,38 +78,49 @@ fn main_0() -> i32 { let x4: Value = Rc::new(RefCell::new(20)); let mut p1: Ptr = (x1.as_pointer()); let mut p2: Ptr = (x2.as_pointer()); - let mut r1: i32 = - (if LessThanComparable::less(x1.as_pointer().clone(), x2.as_pointer().clone()) { - x2.as_pointer() - } else { - x1.as_pointer() - } - .read()); - let mut r2: i32 = - (if LessThanComparable::less(x4.as_pointer().clone(), x3.as_pointer().clone()) { - x4.as_pointer() - } else { - x3.as_pointer() - } - .read()); - let mut r3: i32 = - (if LessThanComparable::less((p1).clone().clone(), x2.as_pointer().clone()) { - x2.as_pointer() - } else { - (p1).clone() - } - .read()); - let mut r4: i32 = - (if LessThanComparable::less(x3.as_pointer().clone(), (p2).clone().clone()) { - x3.as_pointer() - } else { - (p2).clone() - } - .read()); + let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(x1.as_pointer().clone()), + LvalueRef::>::bind(x2.as_pointer().clone()), + )) { + x2.as_pointer() + } else { + x1.as_pointer() + } + .read()); + let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(x4.as_pointer().clone()), + LvalueRef::>::bind(x3.as_pointer().clone()), + )) { + x4.as_pointer() + } else { + x3.as_pointer() + } + .read()); + let mut r3: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((p1).clone().clone()), + LvalueRef::>::bind(x2.as_pointer().clone()), + )) { + x2.as_pointer() + } else { + (p1).clone() + } + .read()); + let mut r4: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(x3.as_pointer().clone()), + LvalueRef::>::bind((p2).clone().clone()), + )) { + x3.as_pointer() + } else { + (p2).clone() + } + .read()); let mut r5: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(30)); let __tmp_1: Value = Rc::new(RefCell::new(40)); - (if LessThanComparable::less(__tmp_0.as_pointer().clone(), __tmp_1.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_0.as_pointer().clone()), + LvalueRef::>::bind(__tmp_1.as_pointer().clone()), + )) { __tmp_1.as_pointer() } else { __tmp_0.as_pointer() @@ -116,10 +133,19 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(values.decay())); let __last: Value> = Rc::new(RefCell::new(values.decay().offset((4) as isize))); let mut __best = __it.borrow().clone(); - if >::not_equal(__it.as_pointer(), __last.as_pointer()) { + if ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { __it.borrow_mut().iter_inc(); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { - if LessThanComparable::less(__best.iter_deref(), __it.borrow().iter_deref()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__best.iter_deref()), + LvalueRef::>::bind(__it.borrow().iter_deref()), + )) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -131,7 +157,10 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(0,) }), ({ pick_3(1,) }),) { (__tmp_2, __tmp_3) => { - if LessThanComparable::less((__tmp_2).clone().clone(), (__tmp_3).clone().clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((__tmp_2).clone().clone()), + LvalueRef::>::bind((__tmp_3).clone().clone()), + )) { (__tmp_3).clone() } else { (__tmp_2).clone() @@ -145,7 +174,10 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(1,) }), ({ pick_3(0,) }),) { (__tmp_4, __tmp_5) => { - if LessThanComparable::less((__tmp_5).clone().clone(), (__tmp_4).clone().clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((__tmp_5).clone().clone()), + LvalueRef::>::bind((__tmp_4).clone().clone()), + )) { (__tmp_5).clone() } else { (__tmp_4).clone() @@ -163,19 +195,19 @@ fn main_0() -> i32 { let __tmp_9: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); (match ( { - ({ make_4(Ptr::clone(&__tmp_7.as_pointer()), 1) }); + ({ make_5(Ptr::clone(&__tmp_7.as_pointer()), 1) }); __tmp_7.as_pointer() }, { - ({ make_4(Ptr::clone(&__tmp_9.as_pointer()), 2) }); + ({ make_5(Ptr::clone(&__tmp_9.as_pointer()), 2) }); __tmp_9.as_pointer() }, ) { (__tmp_6, __tmp_8) => { - if LessThanComparable::less( - (__tmp_6).clone().clone(), - (__tmp_8).clone().clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((__tmp_6).clone().clone()), + LvalueRef::>::bind((__tmp_8).clone().clone()), + )) { (__tmp_8).clone() } else { (__tmp_6).clone() @@ -189,19 +221,19 @@ fn main_0() -> i32 { let __tmp_13: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); (match ( { - ({ make_4(Ptr::clone(&__tmp_11.as_pointer()), 1) }); + ({ make_5(Ptr::clone(&__tmp_11.as_pointer()), 1) }); __tmp_11.as_pointer() }, { - ({ make_4(Ptr::clone(&__tmp_13.as_pointer()), 2) }); + ({ make_5(Ptr::clone(&__tmp_13.as_pointer()), 2) }); __tmp_13.as_pointer() }, ) { (__tmp_10, __tmp_12) => { - if LessThanComparable::less( - (__tmp_12).clone().clone(), - (__tmp_10).clone().clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((__tmp_12).clone().clone()), + LvalueRef::>::bind((__tmp_10).clone().clone()), + )) { (__tmp_12).clone() } else { (__tmp_10).clone() @@ -222,10 +254,10 @@ fn main_0() -> i32 { let __tmp_15: Value = Rc::new(RefCell::new((largest as u64))); (match (Rc::new(RefCell::new((({ size_of_2(i) }) as u64))).as_pointer(),) { (__tmp_14,) => { - if LessThanComparable::less( - __tmp_15.as_pointer().clone(), - (__tmp_14).clone().clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), + LvalueRef::>::bind((__tmp_14).clone().clone()), + )) { (__tmp_14).clone() } else { __tmp_15.as_pointer() diff --git a/tests/unit/out/refcount/min_max_ptr2ptr.rs b/tests/unit/out/refcount/min_max_ptr2ptr.rs index 016528fab0..6017ada47d 100644 --- a/tests/unit/out/refcount/min_max_ptr2ptr.rs +++ b/tests/unit/out/refcount/min_max_ptr2ptr.rs @@ -17,13 +17,19 @@ fn main_0() -> i32 { let pb: Value> = Rc::new(RefCell::new((b.as_pointer()))); let mut ppa: Ptr> = (pa.as_pointer()); let mut ppb: Ptr> = (pb.as_pointer()); - let mut r1: i32 = (if LessThanComparable::less((ppa.read()).clone(), (ppb.read()).clone()) { + let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((ppa.read()).clone()), + LvalueRef::>::bind((ppb.read()).clone()), + )) { (ppb.read()) } else { (ppa.read()) } .read()); - let mut r2: i32 = (if LessThanComparable::less((ppb.read()).clone(), (ppa.read()).clone()) { + let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((ppb.read()).clone()), + LvalueRef::>::bind((ppa.read()).clone()), + )) { (ppb.read()) } else { (ppa.read()) @@ -36,7 +42,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if LessThanComparable::less(high.as_pointer().clone(), low.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(>::less( + LvalueRef::>>::bind(high.as_pointer().clone()), + LvalueRef::>>::bind(low.as_pointer().clone()), + )) { high.as_pointer() } else { low.as_pointer() @@ -48,7 +57,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if LessThanComparable::less(low.as_pointer().clone(), high.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(>::less( + LvalueRef::>>::bind(low.as_pointer().clone()), + LvalueRef::>>::bind(high.as_pointer().clone()), + )) { low.as_pointer() } else { high.as_pointer() @@ -60,7 +72,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if LessThanComparable::less(low.as_pointer().clone(), high.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(>::less( + LvalueRef::>>::bind(low.as_pointer().clone()), + LvalueRef::>>::bind(high.as_pointer().clone()), + )) { high.as_pointer() } else { low.as_pointer() @@ -72,7 +87,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if LessThanComparable::less(high.as_pointer().clone(), low.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(>::less( + LvalueRef::>>::bind(high.as_pointer().clone()), + LvalueRef::>>::bind(low.as_pointer().clone()), + )) { low.as_pointer() } else { high.as_pointer() diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 33a83e3d88..cf8cb14339 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -25,15 +25,79 @@ pub struct S { #[offset(0)] pub v: i32, } +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for S { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); + } +} +impl PartiallyOrderedWith for S { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_gt_3((__lhs).clone(), (__rhs).clone()) }); } + type LessEqualResult = bool; + fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_le_4((__lhs).clone(), (__rhs).clone()) }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ge_5((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn operator_eq_0(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); +} +pub fn operator_ne_1(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } != { b.with(|__s| __s.v) }); +} +pub fn operator_lt_2(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); +} +pub fn operator_gt_3(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); +} +pub fn operator_le_4(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } <= { b.with(|__s| __s.v) }); +} +pub fn operator_ge_5(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } >= { b.with(|__s| __s.v) }); } -pub fn operator_lt_0(a: Ptr, mut b: i32) -> bool { +pub fn operator_lt_6(a: Ptr, mut b: i32) -> bool { return ({ a.with(|__s| __s.v) } < { b }); } -pub fn operator_lt_1(mut a: i32, b: Ptr) -> bool { +pub fn operator_lt_7(mut a: i32, b: Ptr) -> bool { return ({ a } < { b.with(|__s| __s.v) }); } #[derive( @@ -55,16 +119,50 @@ pub struct V { #[offset(0)] pub v: i32, } -pub fn operator_eq_2(mut a: V, mut b: V) -> bool { +impl WeaklyEqualityComparableWith for V { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_eq_8({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_ne_9({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} +impl LessThanComparable for V { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_lt_10({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} +pub fn operator_eq_8(mut a: V, mut b: V) -> bool { return (a.v == b.v); } -pub fn operator_ne_3(mut a: V, mut b: V) -> bool { +pub fn operator_ne_9(mut a: V, mut b: V) -> bool { return (a.v != b.v); } -pub fn operator_lt_4(mut a: V, mut b: V) -> bool { +pub fn operator_lt_10(mut a: V, mut b: V) -> bool { return (a.v < b.v); } -pub fn operator_gt_5(mut a: V, mut b: V) -> bool { +pub fn operator_gt_11(mut a: V, mut b: V) -> bool { return (a.v > b.v); } pub fn main() { @@ -75,45 +173,23 @@ fn main_0() -> i32 { let mut x: V = V { v: 1 }; let mut y: V = V { v: 2 }; let mut z: V = V { v: 1 }; - assert!(({ operator_eq_2(x, z,) })); - assert!(({ operator_ne_3(x, y,) })); - assert!(({ operator_lt_4(x, y,) })); - assert!(({ operator_gt_5(y, x,) })); - assert!(!({ operator_lt_4(y, x,) })); + assert!(({ operator_eq_8(x, z,) })); + assert!(({ operator_ne_9(x, y,) })); + assert!(({ operator_lt_10(x, y,) })); + assert!(({ operator_gt_11(y, x,) })); + assert!(!({ operator_lt_10(y, x,) })); let a: Value = Rc::new(RefCell::new(S { v: 1 })); let b: Value = Rc::new(RefCell::new(S { v: 2 })); let c: Value = Rc::new(RefCell::new(S { v: 1 })); - assert!(({ WeaklyEqualityComparableWith::equal(a.as_pointer(), c.as_pointer(),) })); - assert!(({ WeaklyEqualityComparableWith::not_equal(a.as_pointer(), b.as_pointer(),) })); - assert!(({ LessThanComparable::less(a.as_pointer(), b.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater(b.as_pointer(), a.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::less_equal(a.as_pointer(), c.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater_equal(a.as_pointer(), c.as_pointer(),) })); - assert!(!({ LessThanComparable::less(b.as_pointer(), a.as_pointer(),) })); - assert!(({ operator_lt_0(a.as_pointer(), 5,) })); - assert!(({ operator_lt_1(0, a.as_pointer(),) })); + assert!(({ operator_eq_0(a.as_pointer(), c.as_pointer(),) })); + assert!(({ operator_ne_1(a.as_pointer(), b.as_pointer(),) })); + assert!(({ operator_lt_2(a.as_pointer(), b.as_pointer(),) })); + assert!(({ operator_gt_3(b.as_pointer(), a.as_pointer(),) })); + assert!(({ operator_le_4(a.as_pointer(), c.as_pointer(),) })); + assert!(({ operator_ge_5(a.as_pointer(), c.as_pointer(),) })); + assert!(!({ operator_lt_2(b.as_pointer(), a.as_pointer(),) })); + assert!(({ operator_lt_6(a.as_pointer(), 5,) })); + assert!(({ operator_lt_7(0, a.as_pointer(),) })); return 0; } -impl PartiallyOrderedWith for S { - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } - fn greater(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); - } - fn less_equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } <= { b.with(|__s| __s.v) }); - } - fn greater_equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } >= { b.with(|__s| __s.v) }); - } -} -impl WeaklyEqualityComparableWith for S { - fn equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); - } - fn not_equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } != { b.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index acadd8cc62..b0f91e2428 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -26,13 +26,77 @@ pub struct S { pub v: i32, } impl S { + pub fn operator_eq(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); + } + pub fn operator_ne(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } != { o.with(|__s| __s.v) }); + } + pub fn operator_lt_3(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } < { o.with(|__s| __s.v) }); + } + pub fn operator_gt(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } > { o.with(|__s| __s.v) }); + } + pub fn operator_le(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } <= { o.with(|__s| __s.v) }); + } + pub fn operator_ge(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } >= { o.with(|__s| __s.v) }); + } pub fn operator_lt_7(this: Ptr, mut o: i32) -> bool { return (this.with(|__s| __s.v) < o); } } +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_ne((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for S { - fn less(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } < { o.with(|__s| __s.v) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); + } +} +impl PartiallyOrderedWith for S { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_gt((__lhs).clone(), (__rhs).clone()) }); + } + type LessEqualResult = bool; + fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_le((__lhs).clone(), (__rhs).clone()) }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_ge((__lhs).clone(), (__rhs).clone()) }); } } pub fn main() { @@ -43,36 +107,14 @@ fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(S { v: 1 })); let b: Value = Rc::new(RefCell::new(S { v: 2 })); let c: Value = Rc::new(RefCell::new(S { v: 1 })); - assert!(({ WeaklyEqualityComparableWith::equal(a.as_pointer(), c.as_pointer(),) })); - assert!(({ WeaklyEqualityComparableWith::not_equal(a.as_pointer(), b.as_pointer(),) })); - assert!(({ LessThanComparable::less(a.as_pointer(), b.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater(b.as_pointer(), a.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::less_equal(a.as_pointer(), c.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater_equal(a.as_pointer(), c.as_pointer(),) })); - assert!(!({ LessThanComparable::less(b.as_pointer(), a.as_pointer(),) })); + assert!(({ S::operator_eq(a.as_pointer(), c.as_pointer(),) })); + assert!(({ S::operator_ne(a.as_pointer(), b.as_pointer(),) })); + assert!(({ S::operator_lt_3(a.as_pointer(), b.as_pointer(),) })); + assert!(({ S::operator_gt(b.as_pointer(), a.as_pointer(),) })); + assert!(({ S::operator_le(a.as_pointer(), c.as_pointer(),) })); + assert!(({ S::operator_ge(a.as_pointer(), c.as_pointer(),) })); + assert!(!({ S::operator_lt_3(b.as_pointer(), a.as_pointer(),) })); assert!(({ S::operator_lt_7(a.as_pointer(), 5,) })); return 0; } -impl PartiallyOrderedWith for S { - fn greater(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } > { o.with(|__s| __s.v) }); - } - fn less_equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } <= { o.with(|__s| __s.v) }); - } - fn greater_equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } >= { o.with(|__s| __s.v) }); - } - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } -} -impl WeaklyEqualityComparableWith for S { - fn equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); - } - fn not_equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } != { o.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 76333aa36a..258b5c48f9 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -45,6 +45,90 @@ impl S { return ({ this.with(|__s| __s.v) } >= { (((o.read()) as i32) - (('0' as i8) as i32)) }); } } +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq((__lhs).clone(), (__rhs.read())) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_ne((__lhs).clone(), (__rhs.read())) }); + } +} +impl WeaklyEqualityComparableWith for i32 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs.read()), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_1((__lhs.read()), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); + } +} +impl WeaklyEqualityComparableWith for f64 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); + } +} +impl WeaklyEqualityComparableWith for i64 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); + } +} pub fn operator_eq_0(mut a: i32, b: Ptr) -> bool { return ({ a } == { b.with(|__s| __s.v) }); } diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index c6d3748252..44fa96ac59 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -25,6 +25,85 @@ pub struct X { #[offset(0)] pub v: i32, } +impl WeaklyEqualityComparableWith for X { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_eq_0({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } + type NotEqualResult = i32; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_ne_1({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} +impl LessThanComparable for X { + type Result = i32; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} +impl PartiallyOrderedWith for X { + type LessResult = i32; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } + type GreaterResult = i32; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_gt_3({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } + type LessEqualResult = i32; + fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_le_4({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } + type GreaterEqualResult = i32; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_ge_5({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} pub fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if (a.v == b.v) { 2 } else { 0 }; } @@ -128,6 +207,14 @@ impl Mixed { }; } } +impl LessThanComparable for Mixed { + type Result = i32; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -157,6 +244,97 @@ impl MyBool { return this.with(|__s| __s.value); } } +impl WeaklyEqualityComparableWith for MyBool { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } == { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } != { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl LessThanComparable for MyBool { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl PartiallyOrderedWith for MyBool { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } > { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } <= { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } >= { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl ThreeWayComparable for MyBool { + type Category = std_strong_ordering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &(({ MyBool::to_bool((__lhs).clone()) }) as i32), + &(({ MyBool::to_bool((__rhs).clone()) }) as i32), + )); + } +} #[derive( Copy, Clone, @@ -176,14 +354,26 @@ pub struct Boolish { #[offset(0)] pub v: i32, } -pub fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { +impl LessThanComparable for Boolish { + type Result = MyBool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_lt_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} +pub fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v == b.v)); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } -pub fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v < b.v)); @@ -217,6 +407,100 @@ impl RefBool { return this.with(|__s| __s.value); } } +impl WeaklyEqualityComparableWith for RefBool { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } == { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } != { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl LessThanComparable for RefBool { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl PartiallyOrderedWith for RefBool { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } > { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } <= { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } >= { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl ThreeWayComparable for RefBool { + type Category = std_strong_ordering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &(({ RefBool::to_bool((__lhs).clone()) }) as i32), + &(({ RefBool::to_bool((__rhs).clone()) }) as i32), + )); + } +} thread_local!( pub static ref_true_8: Value = Rc::new(RefCell::new({ let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); @@ -305,14 +589,14 @@ fn main_0() -> i32 { assert!( ({ MyBool::to_bool( - Rc::new(RefCell::new(({ operator_eq_6(b1, Boolish { v: 1 }) }))).as_pointer(), + Rc::new(RefCell::new(({ operator_eq_7(b1, Boolish { v: 1 }) }))).as_pointer(), ) }) ); assert!( - !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_7(b2, b1,) }))).as_pointer(),) }) + !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_6(b2, b1,) }))).as_pointer(),) }) ); - let mut lt: MyBool = ({ operator_lt_7(b1, b2) }); + let mut lt: MyBool = ({ operator_lt_6(b1, b2) }); assert!(lt.value); let bs: Value> = Rc::new(RefCell::new(Box::new([ Boolish { v: 3 }, @@ -342,12 +626,13 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(ris.decay())); let __last: Value> = Rc::new(RefCell::new(ris.decay().offset((2) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - ri2.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(ri2.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 100f191845..6bf0323273 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -6,10 +6,11 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -impl LessThanComparable for S { - fn less(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.data_) } < { y.with(|__s| __s.data_) }); - } +pub fn operator_eq_0(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.data_) } == { y.with(|__s| __s.data_) }); +} +pub fn operator_lt_1(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.data_) } < { y.with(|__s| __s.data_) }); } #[derive( Record, ByteRepr, ZeroInitialization, FnPtrArg, DefaultInitializable, Memberwise, Default, @@ -28,6 +29,14 @@ impl S { field!(this, data_).write(data); } } +impl LessThanComparable for S { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -36,14 +45,9 @@ fn main_0() -> i32 { object!(a, S::constructor_1(1)); object!(b, S::constructor_1(2)); object!(c, S::constructor_1(1)); - assert!(({ WeaklyEqualityComparableWith::equal(a.as_pointer(), c.as_pointer(),) })); - assert!(({ LessThanComparable::less(a.as_pointer(), b.as_pointer(),) })); - assert!(!({ LessThanComparable::less(b.as_pointer(), a.as_pointer(),) })); + assert!(({ operator_eq_0(a.as_pointer(), c.as_pointer(),) })); + assert!(({ operator_lt_1(a.as_pointer(), b.as_pointer(),) })); + assert!(!({ operator_lt_1(b.as_pointer(), a.as_pointer(),) })); return 0; } -impl WeaklyEqualityComparableWith for S { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.data_) } == { y.with(|__s| __s.data_) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index e933c0b1ef..95ad1eedd1 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -70,6 +70,57 @@ impl S { return (this.with(|__s| __s.v) != 0); } } +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) }); + } +} +impl LessThanComparable for S { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); + } +} +impl PartiallyOrderedWith for S { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) }); + } + type LessEqualResult = bool; + fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index e6a1160505..514e28aaaf 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -17,20 +17,16 @@ use std::rc::{Rc, Weak}; TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct S { #[offset(0)] pub v: i32, } -impl ThreeWayComparable for S { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, o: Ptr) -> libcc2rs::StrongOrdering { +impl S { + pub fn operator_cmp(this: Ptr, o: Ptr) -> libcc2rs::StrongOrdering { if ({ this.with(|__s| __s.v) } < { o.with(|__s| __s.v) }) { return (*libcc2rs::strong_ordering_less().upgrade().deref()); } @@ -39,6 +35,68 @@ impl ThreeWayComparable for S { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); + } +} +impl WeaklyEqualityComparableWith for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for S { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for S { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for S { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } pub fn main() { __cpp2rust_init_globals(); @@ -48,22 +106,21 @@ fn main_0() -> i32 { let a: Value = Rc::new(RefCell::new(S { v: 1 })); let b: Value = Rc::new(RefCell::new(S { v: 2 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(a.as_pointer(), b.as_pointer(),) }) + ({ S::operator_cmp(a.as_pointer(), b.as_pointer(),) }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(b.as_pointer(), a.as_pointer(),) }) + ({ S::operator_cmp(b.as_pointer(), a.as_pointer(),) }) )); assert!(libcc2rs::is_lteq( - ({ ThreeWayComparable::three_way(a.as_pointer(), b.as_pointer(),) }) + ({ S::operator_cmp(a.as_pointer(), b.as_pointer(),) }) )); assert!(libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way(b.as_pointer(), a.as_pointer(),) }) + ({ S::operator_cmp(b.as_pointer(), a.as_pointer(),) }) )); - assert!(!({ WeaklyEqualityComparableWith::equal(a.as_pointer(), b.as_pointer(),) })); + assert!(!({ S::operator_eq(a.as_pointer(), b.as_pointer(),) })); assert!({ - let __a = libcc2rs::PartialOrdering::from( - ({ ThreeWayComparable::three_way(a.as_pointer(), b.as_pointer()) }), - ); + let __a = + libcc2rs::PartialOrdering::from(({ S::operator_cmp(a.as_pointer(), b.as_pointer()) })); let __b = libcc2rs::PartialOrdering::from( ({ (*libcc2rs::strong_ordering_less().upgrade().deref()) }), ); @@ -73,9 +130,4 @@ fn main_0() -> i32 { }); return 0; } -impl WeaklyEqualityComparableWith for S { - fn equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index bf4a93e669..3481437b28 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -56,6 +56,83 @@ impl Meters { return this.with(|__s| __s.value); } } +impl WeaklyEqualityComparableWith for Meters { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } == { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } != { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } +} +impl LessThanComparable for Meters { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } +} +impl PartiallyOrderedWith for Meters { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } > { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { + ({ Meters::to_i32((__rhs).clone()) }) + }); + } +} #[derive( Copy, Clone, diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 3a5e4706fa..1d8ae84c68 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -96,7 +96,10 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -133,7 +136,10 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -405,7 +411,10 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -517,7 +526,10 @@ pub fn emplace_from_sibling_18(mut s: Ptr) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/redundant_copy_in_conversion.rs b/tests/unit/out/refcount/redundant_copy_in_conversion.rs index 2d3679ec5b..ef8c32001b 100644 --- a/tests/unit/out/refcount/redundant_copy_in_conversion.rs +++ b/tests/unit/out/refcount/redundant_copy_in_conversion.rs @@ -17,7 +17,14 @@ pub fn sink_0(it: BidirectionalIterator<(Value, Value)>) -> i32 { )>>::from(({ (*it.borrow()).clone() })))) .as_pointer(),) { - (__tmp_0,) => WeaklyEqualityComparableWith::equal(cit.as_pointer(), (__tmp_0).clone()), + (__tmp_0,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + cit.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_0).clone(), + ), + )), } { (*(*({ (*it.borrow()).iter_deref() }).upgrade().deref()) .1 @@ -58,14 +65,24 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_3,) => WeaklyEqualityComparableWith::equal(const_it.as_pointer(), (__tmp_3).clone()), + (__tmp_3,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + const_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_3).clone(), + ), + )), } { 0 } else { 1 }; r += ({ sink_0({ (*it0.borrow()).clone() }) }); - r += if WeaklyEqualityComparableWith::equal(end.as_pointer(), end.as_pointer()) { + r += if ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind(end.as_pointer()), + LvalueRef::, Value)>>>::bind(end.as_pointer()), + )) { 0 } else { 1 @@ -78,9 +95,11 @@ fn main_0() -> i32 { >::from(({ (*middle.borrow()).clone() })), )); assert!(((({ (*const_middle.borrow()).iter_deref() }).read()) == 8_u32)); - assert!(WeaklyEqualityComparableWith::equal( - const_middle.as_pointer(), - middle.as_pointer() + assert!(ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind(const_middle.as_pointer()), + LvalueRef::>>::bind(middle.as_pointer()), + ) )); return 0; } diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index ec68ef0ef9..25b15ed785 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -36,7 +36,10 @@ pub fn size_t_in_rules_3() { let __first: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); let mut __out = (dst.decay()).reinterpret_cast::(); - while >::not_equal(__first.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { object!(__value, u64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -118,7 +121,14 @@ pub fn size_t_in_rules_3() { .as_pointer(), ) { (__tmp_2, __tmp_4) => { - WeaklyEqualityComparableWith::not_equal((__tmp_2).clone(), (__tmp_4).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::, Value)>>>::bind( + (__tmp_2).clone(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_4).clone(), + ), + )) } }); assert!( @@ -258,7 +268,10 @@ pub fn size_t_in_rules_3() { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -281,7 +294,10 @@ pub fn size_t_in_rules_3() { { let __it: Value> = Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { __it.borrow() .iter_deref() .write(Clone::clone(&({ ((*k.borrow()) as u64) }))); @@ -296,10 +312,10 @@ pub fn size_t_in_rules_3() { let __tmp_10: Value = Rc::new(RefCell::new(((*k.borrow()) as u64))); (match (v.decay().offset(1_usize),) { (__tmp_9,) => { - if LessThanComparable::less( - (__tmp_9).clone().clone(), - __tmp_10.as_pointer().clone(), - ) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind((__tmp_9).clone().clone()), + LvalueRef::>::bind(__tmp_10.as_pointer().clone()), + )) { __tmp_10.as_pointer() } else { (__tmp_9).clone() @@ -390,13 +406,17 @@ pub fn size_t_in_rules_3() { Rc::new(RefCell::new(v3.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v3.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - __tmp_19.as_pointer().clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_19.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -407,7 +427,10 @@ pub fn size_t_in_rules_3() { Rc::new(RefCell::new(v3.decay().end())).as_pointer(), ) { (__tmp_18, __tmp_20) => { - WeaklyEqualityComparableWith::not_equal((__tmp_18).clone(), (__tmp_20).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind((__tmp_18).clone()), + LvalueRef::>>::bind((__tmp_20).clone()), + )) } }); assert!( @@ -468,13 +491,24 @@ fn main_0() -> i32 { (::std::mem::size_of::() as u64).wrapping_add((*ul.borrow())), )); let __tmp_22: Value = Rc::new(RefCell::new((sz as u64))); - (if LessThanComparable::less(__tmp_21.as_pointer().clone(), __tmp_22.as_pointer().clone()) { __tmp_21.as_pointer() } else { __tmp_22.as_pointer() } .read()) + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_21.as_pointer().clone()), + LvalueRef::>::bind(__tmp_22.as_pointer().clone()), + )) { + __tmp_21.as_pointer() + } else { + __tmp_22.as_pointer() + } + .read()) }) as usize); let mut hi: usize = (({ let __tmp_23: Value = Rc::new(RefCell::new( (::std::mem::size_of::() as u64).wrapping_add((sz as u64)), )); - (if LessThanComparable::less(__tmp_23.as_pointer().clone(), ul.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_23.as_pointer().clone()), + LvalueRef::>::bind(ul.as_pointer().clone()), + )) { ul.as_pointer() } else { __tmp_23.as_pointer() @@ -486,7 +520,15 @@ fn main_0() -> i32 { let mut bound: usize = (({ let __tmp_24: Value = Rc::new(RefCell::new((4_usize as u64))); let __tmp_25: Value = Rc::new(RefCell::new((sz as u64))); - (if LessThanComparable::less(__tmp_24.as_pointer().clone(), __tmp_25.as_pointer().clone()) { __tmp_24.as_pointer() } else { __tmp_25.as_pointer() } .read()) + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_24.as_pointer().clone()), + LvalueRef::>::bind(__tmp_25.as_pointer().clone()), + )) { + __tmp_24.as_pointer() + } else { + __tmp_25.as_pointer() + } + .read()) }) as usize); assert!((bound == 4_usize)); let mut data: [i32; 8] = [0_i32; 8]; @@ -537,12 +579,28 @@ fn main_0() -> i32 { let mut smin: isize = (({ let __tmp_26: Value = Rc::new(RefCell::new((sm as i64))); let __tmp_27: Value = Rc::new(RefCell::new((sd as i64))); - (if LessThanComparable::less(__tmp_26.as_pointer().clone(), __tmp_27.as_pointer().clone()) { __tmp_26.as_pointer() } else { __tmp_27.as_pointer() } .read()) + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_26.as_pointer().clone()), + LvalueRef::>::bind(__tmp_27.as_pointer().clone()), + )) { + __tmp_26.as_pointer() + } else { + __tmp_27.as_pointer() + } + .read()) }) as isize); let mut smax: isize = (({ let __tmp_28: Value = Rc::new(RefCell::new((sd as i64))); let __tmp_29: Value = Rc::new(RefCell::new((sm as i64))); - (if LessThanComparable::less(__tmp_28.as_pointer().clone(), __tmp_29.as_pointer().clone()) { __tmp_29.as_pointer() } else { __tmp_28.as_pointer() } .read()) + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_28.as_pointer().clone()), + LvalueRef::>::bind(__tmp_29.as_pointer().clone()), + )) { + __tmp_29.as_pointer() + } else { + __tmp_28.as_pointer() + } + .read()) }) as isize); assert!((smin == (-7_i32 as isize))); assert!((smax == 15_isize)); @@ -564,10 +622,10 @@ fn main_0() -> i32 { (({ let __tmp_30: Value = Rc::new(RefCell::new((mx as u64))); let __tmp_31: Value = Rc::new(RefCell::new(1_u64)); - (if LessThanComparable::less( - __tmp_30.as_pointer().clone(), - __tmp_31.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_30.as_pointer().clone()), + LvalueRef::>::bind(__tmp_31.as_pointer().clone()), + )) { __tmp_30.as_pointer() } else { __tmp_31.as_pointer() @@ -577,10 +635,10 @@ fn main_0() -> i32 { (({ let __tmp_32: Value = Rc::new(RefCell::new(((mx).wrapping_sub(3_usize) as u64))); let __tmp_33: Value = Rc::new(RefCell::new((mx as u64))); - (if LessThanComparable::less( - __tmp_32.as_pointer().clone(), - __tmp_33.as_pointer().clone(), - ) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_32.as_pointer().clone()), + LvalueRef::>::bind(__tmp_33.as_pointer().clone()), + )) { __tmp_32.as_pointer() } else { __tmp_33.as_pointer() diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index a9e08862ee..d4cb448b64 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -52,6 +52,14 @@ impl MoveAssignable for Tracked { return (this).clone(); } } +impl LessThanComparable for Tracked { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); + } +} impl Default for Tracked { fn default() -> Self { { @@ -63,12 +71,10 @@ impl Default for Tracked { } } } -impl LessThanComparable for Tracked { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); - } +pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); } -pub fn greater_1(a: Ptr, b: Ptr) -> bool { +pub fn greater_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } > { b.with(|__s| __s.v) }); } #[derive( @@ -96,10 +102,16 @@ impl MoveOnly { } } impl LessThanComparable for MoveOnly { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); +} #[derive( Record, ByteRepr, ZeroInitialization, FnPtrArg, Destructible, Memberwise, Swappable, Default, )] @@ -119,10 +131,19 @@ impl Bag { } } impl LessThanComparable for Bag { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { + return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); +} +pub fn operator_eq_5(a: Ptr, b: Ptr) -> bool { + return ({ (*a.upgrade().deref()).items.len() } == { (*b.upgrade().deref()).items.len() }); +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -237,9 +258,9 @@ fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_6.iter_at(__x); let __b = __tmp_6.iter_at(__y); - if greater_1.call(__a.clone(), __b.clone()) { + if greater_2.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less - } else if greater_1.call(__b, __a) { + } else if greater_2.call(__b, __a) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -291,9 +312,9 @@ fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_8.iter_at(__x); let __b = __tmp_8.iter_at(__y); - if greater_1.call(__a.clone(), __b.clone()) { + if greater_2.call(__a.clone(), __b.clone()) { std::cmp::Ordering::Less - } else if greater_1.call(__b, __a) { + } else if greater_2.call(__b, __a) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -424,12 +445,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin())); let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - bags.decay().offset(1).clone(), - ) - { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(bags.decay().offset(1).clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -438,7 +460,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_21) => { - WeaklyEqualityComparableWith::equal((__tmp_20).clone(), (__tmp_21).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_20).clone()), + LvalueRef::>>::bind((__tmp_21).clone()), + )) } }); assert!(match ( @@ -448,11 +473,19 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); let mut __best = __it.borrow().clone(); - if >::not_equal(__it.as_pointer(), __last.as_pointer()) { + if ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { __it.borrow_mut().iter_inc(); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - { - if LessThanComparable::less(__best.iter_deref(), __it.borrow().iter_deref()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__best.iter_deref()), + LvalueRef::>::bind(__it.borrow().iter_deref()), + )) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -464,24 +497,27 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(2_isize))).as_pointer(), ) { (__tmp_22, __tmp_23) => { - WeaklyEqualityComparableWith::equal((__tmp_22).clone(), (__tmp_23).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::>>::bind((__tmp_22).clone()), + LvalueRef::>>::bind((__tmp_23).clone()), + )) } }); assert!( - ((if LessThanComparable::less( - bags.decay().offset(2).clone(), - bags.decay().offset(0).clone() - ) { + ((if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(bags.decay().offset(2).clone()), + LvalueRef::>::bind(bags.decay().offset(0).clone()) + )) { bags.decay().offset(2) } else { bags.decay().offset(0) }) == (bags.decay().offset(0))) ); assert!( - ((if LessThanComparable::less( - bags.decay().offset(0).clone(), - bags.decay().offset(2).clone() - ) { + ((if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(bags.decay().offset(0).clone()), + LvalueRef::>::bind(bags.decay().offset(2).clone()) + )) { bags.decay().offset(2) } else { bags.decay().offset(0) @@ -525,7 +561,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_26, __tmp_27) => { - WeaklyEqualityComparableWith::equal((__tmp_26).clone(), (__tmp_27).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + LvalueRef::, Value)>>>::bind( + (__tmp_26).clone(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_27).clone(), + ), + )) } }); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); @@ -610,11 +653,6 @@ fn main_0() -> i32 { ); return copies_0.with(|rc| *rc.borrow()); } -impl WeaklyEqualityComparableWith for Bag { - fn equal(a: Ptr, b: Ptr) -> bool { - return ({ (*a.upgrade().deref()).items.len() } == { (*b.upgrade().deref()).items.len() }); - } -} pub fn __cpp2rust_init_globals() { let _ = copies_0.with(|_| ()); } diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 3a312a4201..d088ab67cb 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -43,7 +43,10 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = output.decay(); - while >::not_equal(__first.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { object!(__value, i32, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -66,7 +69,10 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = widened.decay().begin(); - while >::not_equal(__first.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { object!(__value, i64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -99,7 +105,10 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = constructed.decay().begin(); - while >::not_equal(__first.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { object!(__value, Degrees, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -127,7 +136,10 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(wide.decay())); let __last: Value> = Rc::new(RefCell::new(wide.decay().offset((2) as isize))); let mut __out = floating.decay().begin(); - while >::not_equal(__first.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { object!(__value, f64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this diff --git a/tests/unit/out/refcount/stdcopy_ostream.rs b/tests/unit/out/refcount/stdcopy_ostream.rs index 125d536561..22de5b8a9e 100644 --- a/tests/unit/out/refcount/stdcopy_ostream.rs +++ b/tests/unit/out/refcount/stdcopy_ostream.rs @@ -32,7 +32,10 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(__tmp_1)); let __out = &mut (*ofs.borrow_mut()); let mut __bytes: Vec = Vec::new(); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { __bytes.push(__it.borrow().iter_deref().read() as u8); __it.borrow_mut().iter_inc(); } diff --git a/tests/unit/out/refcount/stdmin_fpoint.rs b/tests/unit/out/refcount/stdmin_fpoint.rs index 23a3bcef2f..b741b78918 100644 --- a/tests/unit/out/refcount/stdmin_fpoint.rs +++ b/tests/unit/out/refcount/stdmin_fpoint.rs @@ -13,7 +13,10 @@ pub fn main() { fn main_0() -> i32 { let a0: Value = Rc::new(RefCell::new(3.14_f64)); let a1: Value = Rc::new(RefCell::new(2.71_f64)); - if LessThanComparable::less(a1.as_pointer().clone(), a0.as_pointer().clone()) { + if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(a1.as_pointer().clone()), + LvalueRef::>::bind(a0.as_pointer().clone()), + )) { a1.as_pointer() } else { a0.as_pointer() diff --git a/tests/unit/out/refcount/unboxed_conditional_iterator.rs b/tests/unit/out/refcount/unboxed_conditional_iterator.rs index 393e236257..45b3a51a9c 100644 --- a/tests/unit/out/refcount/unboxed_conditional_iterator.rs +++ b/tests/unit/out/refcount/unboxed_conditional_iterator.rs @@ -59,13 +59,17 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { Rc::new(RefCell::new(items.decay().begin())); let __last: Value> = Rc::new(RefCell::new(items.decay().end())); - while >::not_equal( - __it.as_pointer(), - __last.as_pointer(), - ) && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - sigma.offset((i) as isize).clone(), - ) { + while ConvertibleTo::::convert_value( + >::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind( + __last.as_pointer(), + ), + ), + ) && !ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(sigma.offset((i) as isize).clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -73,9 +77,15 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { assert!( match (Rc::new(RefCell::new(items.decay().end())).as_pointer(),) { (__tmp_0,) => { - WeaklyEqualityComparableWith::not_equal( - it.as_pointer(), - (__tmp_0).clone(), + ConvertibleTo::::convert_value( + WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind( + it.as_pointer(), + ), + LvalueRef::>>::bind( + (__tmp_0).clone(), + ), + ), ) } } @@ -101,7 +111,10 @@ pub fn sum_4(v: Ptr>) -> i32 { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { (__tmp_2,) => { - WeaklyEqualityComparableWith::not_equal(it.as_pointer(), (__tmp_2).clone()) + ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_2).clone()), + )) } } { 'for_body: { diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 2430ac05fb..029b80f447 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -176,7 +176,10 @@ fn main_0() -> i32 { let high: Value = Rc::new(RefCell::new(3)); let mut low: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(2)); - (if LessThanComparable::less(__tmp_0.as_pointer().clone(), high.as_pointer().clone()) { + (if ConvertibleTo::::convert_value(::less( + LvalueRef::>::bind(__tmp_0.as_pointer().clone()), + LvalueRef::>::bind(high.as_pointer().clone()), + )) { __tmp_0.as_pointer() } else { high.as_pointer() diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index 7d9809b4eb..c2476268b5 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -192,7 +192,10 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay().begin())); let __last: Value> = Rc::new(RefCell::new(src.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -706,7 +709,10 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -740,7 +746,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -767,7 +776,10 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((2) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -797,7 +809,10 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -829,7 +844,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 258b666ca4..207b6068ac 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -56,6 +56,86 @@ impl Reading { return ((this.with(|__s| __s.raw_) as i64) * 10_i64); } } +impl WeaklyEqualityComparableWith for Reading { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } == { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } != { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } +} +impl LessThanComparable for Reading { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } +} +impl PartiallyOrderedWith for Reading { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } > { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } <= { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ ({ Reading::to_i64((__lhs).clone()) }) } >= { + ({ Reading::to_i64((__rhs).clone()) }) + }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -66,7 +146,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -83,7 +166,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -100,7 +186,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -118,7 +207,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -142,7 +234,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -184,9 +279,15 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while , Value)>>::not_equal( - __it.as_pointer(), - __last.as_pointer(), + while ConvertibleTo::::convert_value( + , Value)>>::not_equal( + LvalueRef::, Value)>>>::bind( + __it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + __last.as_pointer(), + ), + ), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -229,9 +330,15 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while , Value)>>::not_equal( - __it.as_pointer(), - __last.as_pointer(), + while ConvertibleTo::::convert_value( + , Value)>>::not_equal( + LvalueRef::, Value)>>>::bind( + __it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + __last.as_pointer(), + ), + ), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -265,7 +372,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -286,7 +396,10 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(readings.decay())); let __last: Value> = Rc::new(RefCell::new(readings.decay().offset((2) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index a3c027a626..e236dae83d 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -405,7 +405,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -422,7 +425,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -439,7 +445,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -457,7 +466,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -478,7 +490,10 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) { + while ConvertibleTo::::convert_value(>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index 49f7e8d1f1..fd788950b8 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -188,11 +188,17 @@ pub unsafe fn order_physical_2() { let __n = ps.as_mut_ptr().offset((4) as isize).iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const *mut i32; + let __b = __tmp_0.iter_at(__y) as *const *mut i32; + if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index fd2a3eea1b..9639c65a76 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -98,6 +98,10 @@ impl Counter { (*(&raw const (*this).calls).cast_mut()).prefix_inc(); return (*this).v; } + pub unsafe fn operator_eq(this: *const Self, o: *const Counter) -> bool { + (*(&raw const (*this).calls).cast_mut()).prefix_inc(); + return (((*this).v) == ((*o).v)); + } } #[repr(C)] #[derive( @@ -178,8 +182,8 @@ unsafe fn main_0() -> i32 { assert!(((unsafe { Counter::Get(&raw const c1,) }) == (3))); assert!(((unsafe { Counter::Get(&raw const c2,) }) == (3))); assert!(((unsafe { Counter::Get(&raw const (*pc),) }) == (3))); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const c1, &c2,) })); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const c2, &c1,) })); + assert!((unsafe { Counter::operator_eq(&raw const c1, &c2,) })); + assert!((unsafe { Counter::operator_eq(&raw const c2, &c1,) })); assert!(((c1.calls) == (3))); assert!(((c2.calls) == (2))); let mut t: Tally = Tally { calls: 0 }; @@ -192,10 +196,4 @@ unsafe fn main_0() -> i32 { assert!(((ct.calls) == (10))); return 0; } -impl WeaklyEqualityComparableWithUnsafe for Counter { - unsafe fn equal(this: *const Self, o: *const Counter) -> bool { - (*(&raw const (*this).calls).cast_mut()).prefix_inc(); - return (((*this).v) == ((*o).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index c7b686a2e7..2e7e0b6c25 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -34,7 +34,14 @@ pub unsafe fn sum_1(v: *const Vec) -> i32 { let mut total: i32 = 0; { let mut it: UnsafeRandomAccessIterator = (*v).begin(); - 'loop_: while WeaklyEqualityComparableWithUnsafe::not_equal(&it, &(*v).end()) { + 'loop_: while ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind( + &raw const (*v).end(), + ), + ), + ) { 'for_body: { total += (*it.iter_deref()); } diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index e3052cb205..0f202c981f 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -420,7 +420,16 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { vec_.end() }; let mut __v: Vec = Vec::new(); let mut __it = (__tmp_0).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_1, + ), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index 06a5114584..7fa85d833d 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -26,14 +26,25 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { v.begin() }; let mut __tmp_3 = { v.end() }; let mut __it = (__tmp_2).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &7) - { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind(&raw const __it), + LvalueRefUnsafe::>>::bind(&raw const __tmp_3), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 7), + )) { __it.iter_inc(); } __it }; - assert!(WeaklyEqualityComparableWithUnsafe::not_equal(&it, &v.end())); + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind(&raw const v.end()), + ) + )); assert!(((*it.iter_deref()) == (7))); { let mut __tmp_4 = { v.begin() }; @@ -48,11 +59,17 @@ unsafe fn main_0() -> i32 { let __n = v.end().iter_distance(&__tmp_5); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_5.iter_at(__x) as *const _; - let __b = __tmp_5.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_5.iter_at(__x) as *const i32; + let __b = __tmp_5.iter_at(__y) as *const i32; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/emplace_receiver_alias.rs b/tests/unit/out/unsafe/emplace_receiver_alias.rs index 56d855dadc..27c2a1e575 100644 --- a/tests/unit/out/unsafe/emplace_receiver_alias.rs +++ b/tests/unit/out/unsafe/emplace_receiver_alias.rs @@ -32,7 +32,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { (&mut (*alias))[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_1), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/emplace_receiver_order.rs b/tests/unit/out/unsafe/emplace_receiver_order.rs index 5f7496e063..6f9e918bf5 100644 --- a/tests/unit/out/unsafe/emplace_receiver_order.rs +++ b/tests/unit/out/unsafe/emplace_receiver_order.rs @@ -40,7 +40,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_1), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -67,8 +70,14 @@ unsafe fn main_0() -> i32 { { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_3; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_4) - { + while ConvertibleToUnsafe::::convert_value( + <*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind( + &raw const __tmp_4, + ), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index c673c84678..856e83c0cb 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -22,6 +22,11 @@ use std::rc::Rc; pub struct P { pub x: i32, } +impl P { + pub unsafe fn operator_eq(this: *const Self, o: *const P) -> bool { + return (((*this).x) == ((*o).x)); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -47,14 +52,24 @@ unsafe fn main_0() -> i32 { let mut it: UnsafeRandomAccessIterator = { let mut __tmp_3 = { (v_end).clone() }; let mut __it = (v_begin).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &2) - { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind(&raw const __it), + LvalueRefUnsafe::>>::bind(&raw const __tmp_3), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 2), + )) { __it.iter_inc(); } __it }; - let mut v_result_true: bool = WeaklyEqualityComparableWithUnsafe::not_equal(&it, &v.end()); + let mut v_result_true: bool = + ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind(&raw const v.end()), + )); let mut m: UnsafeMap = UnsafeMap::new(); { let mut __tmp_4: i32; @@ -79,87 +94,158 @@ unsafe fn main_0() -> i32 { }; let mut m_begin: UnsafeBidirectionalIterator<(i32, f64)> = m.begin(); let mut m_end: UnsafeBidirectionalIterator<(i32, f64)> = m.end(); - let mut m_result_true: bool = WeaklyEqualityComparableWithUnsafe::not_equal(&m_begin, &m_end); + let mut m_result_true: bool = + ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const m_begin, + ), + LvalueRefUnsafe::>>::bind( + &raw const m_end, + ), + )); assert!( ((v_result_true) && (m_result_true)) - && (WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_7 = { v.begin() }; - let mut __tmp_8 = { v.begin() }; - let mut __it = (__tmp_7).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_8) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &2) - { - __it.iter_inc(); - } - __it - }, - &v.begin() + && (ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_7 = { v.begin() }; + let mut __tmp_8 = { v.begin() }; + let mut __it = (__tmp_7).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_8, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 2), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind( + &raw const v.begin() + ), + ) )) ); let mut w: Vec = Vec::from([1, 2, 3, 4, 5]); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_9 = { w.begin().iter_add(2_isize) }; - let mut __tmp_10 = { w.end() }; - let mut __it = (__tmp_9).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_10) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &4) - { - __it.iter_inc(); - } - __it - }, - &w.begin().iter_add(3_isize) + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_9 = { w.begin().iter_add(2_isize) }; + let mut __tmp_10 = { w.end() }; + let mut __it = (__tmp_9).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_10, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 4), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind( + &raw const w.begin().iter_add(3_isize) + ), + ) )); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_11 = { w.begin().iter_add(2_isize) }; - let mut __tmp_12 = { w.end() }; - let mut __it = (__tmp_11).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_12) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &1) - { - __it.iter_inc(); - } - __it - }, - &w.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_11 = { w.begin().iter_add(2_isize) }; + let mut __tmp_12 = { w.end() }; + let mut __it = (__tmp_11).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_12, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 1), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind(&raw const w.end()), + ) )); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_13 = { w.begin().iter_add(2_isize) }; - let mut __tmp_14 = { w.begin().iter_add(4_isize) }; - let mut __it = (__tmp_13).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_14) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &5) - { - __it.iter_inc(); - } - __it - }, - &w.begin().iter_add(4_isize) + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_13 = { w.begin().iter_add(2_isize) }; + let mut __tmp_14 = { w.begin().iter_add(4_isize) }; + let mut __it = (__tmp_13).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_14, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const 5), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind( + &raw const w.begin().iter_add(4_isize) + ), + ) )); let mut p: Vec

= Vec::from([P { x: 0 }, P { x: 1 }, P { x: 2 }]); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_15 = { p.begin() }; - let mut __tmp_16 = { p.end() }; - let mut __it = (__tmp_15).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_16) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &(P { x: 1 })) - { - __it.iter_inc(); - } - __it - }, - &p.begin().iter_add(1_isize) + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_15 = { p.begin() }; + let mut __tmp_16 = { p.end() }; + let mut __it = (__tmp_15).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_16, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(

::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const (P { x: 1 })), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind( + &raw const p.begin().iter_add(1_isize) + ), + ) )); return 0; } -impl WeaklyEqualityComparableWithUnsafe for P { - unsafe fn equal(this: *const Self, o: *const P) -> bool { - return (((*this).x) == ((*o).x)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 1572274b47..11efd8725d 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -9,10 +9,13 @@ use std::rc::Rc; pub unsafe fn get_0(v: *const V) -> i32 { return (*v).x; } -pub unsafe fn scaled_1(v: *const V, mut k: i32) -> i32 { +pub unsafe fn operator_eq_1(a: *const V, b: *const V) -> bool { + return (((*a).x) == ((*b).x)); +} +pub unsafe fn scaled_2(v: *const V, mut k: i32) -> i32 { return (((*v).x) * (k)); } -pub unsafe fn scaled_2(v: *const V, mut k: f64) -> f64 { +pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { return (((*v).x as f64) * (k)); } #[repr(C)] @@ -31,7 +34,7 @@ pub unsafe fn scaled_2(v: *const V, mut k: f64) -> f64 { pub struct V { pub x: i32, } -pub unsafe fn get_3(w: *const W_int_) -> i32 { +pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; } #[repr(C)] @@ -50,7 +53,7 @@ pub unsafe fn get_3(w: *const W_int_) -> i32 { pub struct W_int_ { pub x: i32, } -pub unsafe fn get_4(w: *const W_long_) -> i64 { +pub unsafe fn get_5(w: *const W_long_) -> i64 { return (*w).x; } #[repr(C)] @@ -85,7 +88,7 @@ pub struct W_long_ { pub struct D { pub x: i32, } -pub unsafe fn declared_then_defined_5(d: *const D) -> i32 { +pub unsafe fn declared_then_defined_6(d: *const D) -> i32 { return (((*d).x) + (1)); } pub fn main() { @@ -102,28 +105,23 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _a: *const V = &a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &b) + operator_eq_1(_a, &b) }) ); assert!( !(unsafe { let _a: *const V = &a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &c) + operator_eq_1(_a, &c) }) ); - assert!(((unsafe { scaled_1(&c, 2,) }) == (8))); - assert!(((unsafe { scaled_2(&c, 1.5_f64,) }) == (6_f64))); + assert!(((unsafe { scaled_2(&c, 2,) }) == (8))); + assert!(((unsafe { scaled_3(&c, 1.5_f64,) }) == (6_f64))); let mut wi: W_int_ = W_int_ { x: 5 }; let mut wl: W_long_ = W_long_ { x: 6_i64 }; - assert!(((unsafe { get_3(&wi,) }) == (5))); - assert!(((unsafe { get_4(&wl,) }) == (6_i64))); + assert!(((unsafe { get_4(&wi,) }) == (5))); + assert!(((unsafe { get_5(&wl,) }) == (6_i64))); let mut d: D = D { x: 7 }; - assert!(((unsafe { declared_then_defined_5(&d,) }) == (8))); + assert!(((unsafe { declared_then_defined_6(&d,) }) == (8))); return 0; } -impl WeaklyEqualityComparableWithUnsafe for V { - unsafe fn equal(a: *const V, b: *const V) -> bool { - return (((*a).x) == ((*b).x)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index 901f1d1e13..a24e70a1e8 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -20,7 +20,10 @@ pub static mut selected_1: std::cell::LazyCell = std::cell::LazyCell::new(| { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -43,7 +46,10 @@ pub static mut assigned_4: std::cell::LazyCell = std::cell::LazyCell::new(| (*{ let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -65,7 +71,10 @@ pub static mut accumulated_5: std::cell::LazyCell = std::cell::LazyCell::ne (*{ let __a: *const _ = &mut __tmp_4; let __b: *const _ = &mut __tmp_5; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -126,7 +135,10 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_8; let __b: *const _ = &mut __tmp_9; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -142,7 +154,10 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_11; let __b: *const _ = &mut __tmp_12; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -167,7 +182,10 @@ pub static mut mapped_selected_12: std::cell::LazyCell = let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_13; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -187,7 +205,10 @@ static mut value_14: std::cell::LazyCell = std::cell::LazyCell::new(|| un (*{ let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_14; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -228,7 +249,10 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_16; let __b: *const _ = &mut __tmp_17; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -244,7 +268,10 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_19; let __b: *const _ = &mut __tmp_20; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index e7a22f483a..8e180a7086 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -225,35 +225,55 @@ unsafe fn main_0() -> i32 { let mut it: UnsafeBidirectionalIterator<(i16, u32)> = m.find(&1_i16); let mut const_it: UnsafeBidirectionalIterator<(i16, u32)> = >::from(m.find(&10_i16)); - let mut x1: u32 = if WeaklyEqualityComparableWithUnsafe::equal(&it, &end) { - 0_u32 - } else { - (*it.iter_deref()).1 - }; + let mut x1: u32 = + if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind(&raw const end), + )) { + 0_u32 + } else { + (*it.iter_deref()).1 + }; assert!(((x1) == (4_u32))); - let mut x2: u32 = if WeaklyEqualityComparableWithUnsafe::equal( - &const_it, - &>::from((end).clone()), - ) { - 0_u32 - } else { - (*const_it.iter_deref()).1 - }; + let mut x2: u32 = + if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const const_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const >::from((end).clone()), + ), + )) { + 0_u32 + } else { + (*const_it.iter_deref()).1 + }; assert!(((x2) == (0_u32))); - let mut x3: u32 = if WeaklyEqualityComparableWithUnsafe::equal(&it, &m.end()) { - 0_u32 - } else { - (*it.iter_deref()).1 - }; + let mut x3: u32 = + if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind( + &raw const m.end(), + ), + )) { + 0_u32 + } else { + (*it.iter_deref()).1 + }; assert!(((x3) == (4_u32))); - let mut x4: u32 = if WeaklyEqualityComparableWithUnsafe::equal( - &const_it, - &>::from(m.end()), - ) { - 0_u32 - } else { - (*const_it.iter_deref()).1 - }; + let mut x4: u32 = + if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const const_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const >::from(m.end()), + ), + )) { + 0_u32 + } else { + (*const_it.iter_deref()).1 + }; assert!(((x4) == (0_u32))); { let mut __tmp_18: i16; @@ -295,15 +315,27 @@ unsafe fn main_0() -> i32 { assert!((((*const_it4.iter_deref()).1) == (6_u32))); let r: *mut UnsafeMap = &mut m; assert!((((*r).len()) == (4_usize))); - assert!(WeaklyEqualityComparableWithUnsafe::not_equal( - &m.find(&4_i16), - &m.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const m.find(&4_i16) + ), + LvalueRefUnsafe::>>::bind( + &raw const m.end() + ), + ) )); (*r).erase(&(it4).clone()); assert!((((*r).len()) == (3_usize))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &m.find(&4_i16), - &m.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const m.find(&4_i16) + ), + LvalueRefUnsafe::>>::bind( + &raw const m.end() + ), + ) )); { let mut __tmp_21: i16; @@ -334,18 +366,39 @@ unsafe fn main_0() -> i32 { let mut cit: UnsafeBidirectionalIterator<(i16, u32)> = >::from(m.find(&7_i16)); let mut next: UnsafeBidirectionalIterator<(i16, u32)> = m.erase(&(cit).clone()); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &next, - &m.find(&8_i16) + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const next + ), + LvalueRefUnsafe::>>::bind( + &raw const m.find(&8_i16) + ), + ) )); { next = m.erase(&(next).clone()); }; - assert!(WeaklyEqualityComparableWithUnsafe::equal(&next, &m.end())); + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const next + ), + LvalueRefUnsafe::>>::bind( + &raw const m.end() + ), + ) + )); assert!((((*r).len()) == (3_usize))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &m.find(&8_i16), - &m.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const m.find(&8_i16) + ), + LvalueRefUnsafe::>>::bind( + &raw const m.end() + ), + ) )); let mut other_map: UnsafeMap<(i32, i64), ((i32, i64), f64)> = UnsafeMap::new(); assert!(((other_map.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 716f383024..89dd76ab6b 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -34,10 +34,19 @@ impl Key { (&raw mut (*this).k).write((*o).k); (*std::cell::LazyCell::force_mut(&mut *&raw mut moves_1)).prefix_inc(); } + pub unsafe fn operator_lt(this: *const Self, o: *const Key) -> bool { + return (((*this).k) < ((*o).k)); + } } impl LessThanComparableUnsafe for Key { - unsafe fn less(this: *const Self, o: *const Key) -> bool { - return (((*this).k) < ((*o).k)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + return (unsafe { Key::operator_lt(&raw const (*__lhs), __rhs) }); } } pub unsafe fn make_key_3(__return: *mut Key, mut k: i32) { diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index fe4f9c4623..0a6b5aed9c 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -26,10 +26,25 @@ pub struct Key { pub identity: i32, } impl LessThanComparableUnsafe for Key { - unsafe fn less(a: *const Key, b: *const Key) -> bool { - return (((*a).order) < ((*b).order)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + return (unsafe { + let _a: *const Key = __lhs; + operator_lt_1(_a, __rhs) + }); } } +pub unsafe fn operator_lt_1(a: *const Key, b: *const Key) -> bool { + return (((*a).order) < ((*b).order)); +} +pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { + return (((*a).identity) == ((*b).identity)); +} #[repr(C)] #[derive( Copy, @@ -81,7 +96,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & ((unsafe { let _a: *const Key = &distinct_a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &distinct_b) + operator_eq_2(_a, &distinct_b) }) as i32)) != 0; let mut distinct: UnsafeMap = UnsafeMap::new(); @@ -104,20 +119,43 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((a) != (b)) as i32)) != 0; ok = ((ok as i32) & (((((*a).value) == (11)) && (((*b).value) == (22))) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal(&a_it, &distinct.find(&distinct_a))) as i32)) + & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const a_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const distinct.find(&distinct_a), + ), + ))) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal(&b_it, &distinct.find(&distinct_b))) as i32)) + & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const b_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const distinct.find(&distinct_b), + ), + ))) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::not_equal(&b_it, &distinct.end())) as i32)) + & ((ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const b_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const distinct.end(), + ), + ), + )) as i32)) != 0; ok = ((ok as i32) & (((&mut (*a_it.iter_deref()).1 as *mut Mapped) == (a_value)) as i32)) != 0; ok = ((ok as i32) & ((((*a_it.iter_deref()).1.value) == (11)) as i32)) != 0; ok = ((ok as i32) & ((unsafe { let _a: *const Key = &distinct_a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &distinct_b) + operator_eq_2(_a, &distinct_b) }) as i32)) != 0; let mut distinct_count: usize = 0_usize; @@ -146,7 +184,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (!(unsafe { let _a: *const Key = &equivalent_a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &equivalent_b) + operator_eq_2(_a, &equivalent_b) }) as i32)) != 0; let mut equivalent: UnsafeMap = UnsafeMap::new(); @@ -167,20 +205,40 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((equivalent.len()) == (1_usize)) as i32)) != 0; if reused { ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::not_equal(&first_it, &equivalent.end())) - as i32)) + & ((ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const first_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const equivalent.end(), + ), + ), + )) as i32)) != 0; ok = ((ok as i32) & (((first) == (second)) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal( - &first_it, - &equivalent.find(&equivalent_a), + & ((ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const first_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const equivalent.find(&equivalent_a), + ), + ), )) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal( - &first_it, - &equivalent.find(&equivalent_b), + & ((ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const first_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const equivalent.find(&equivalent_b), + ), + ), )) as i32)) != 0; ok = ((ok as i32) @@ -203,7 +261,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (!(unsafe { let _a: *const Key = &equivalent_a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &equivalent_b) + operator_eq_2(_a, &equivalent_b) }) as i32)) != 0; let later_key: Key = Key { @@ -219,9 +277,15 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((equivalent.len()) == (2_usize)) as i32)) != 0; if reused { ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal( - &first_it, - &equivalent.find(&equivalent_a), + & ((ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const first_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const equivalent.find(&equivalent_a), + ), + ), )) as i32)) != 0; ok = ((ok as i32) @@ -261,8 +325,14 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((matching.len()) == (1_usize)) as i32)) != 0; ok = ((ok as i32) & (((matched) == (matched_again)) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal(&matched_it, &matching.find(&matching_b))) - as i32)) + & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const matched_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const matching.find(&matching_b), + ), + ))) as i32)) != 0; ok = ((ok as i32) & (((&mut (*matched_it.iter_deref()).1 as *mut Mapped) == (matched_value)) as i32)) @@ -276,8 +346,14 @@ unsafe fn main_0() -> i32 { != 0; ok = ((ok as i32) & (((matching.len()) == (2_usize)) as i32)) != 0; ok = ((ok as i32) - & ((WeaklyEqualityComparableWithUnsafe::equal(&matched_it, &matching.find(&matching_a))) - as i32)) + & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const matched_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const matching.find(&matching_a), + ), + ))) as i32)) != 0; ok = ((ok as i32) & (((&mut (*matched_it.iter_deref()).1 as *mut Mapped) == (matched_value)) as i32)) @@ -285,11 +361,6 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & ((((*matched_it.iter_deref()).1.value) == (51)) as i32)) != 0; return if ok { 0 } else { 1 }; } -impl WeaklyEqualityComparableWithUnsafe for Key { - unsafe fn equal(a: *const Key, b: *const Key) -> bool { - return (((*a).identity) == ((*b).identity)); - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const default_constructions_0); } diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 8e174ec643..6ad18231c0 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -219,11 +219,7 @@ unsafe fn main_0() -> i32 { & ((((result.1) as i32) == (!(hit) as i32)) as i32)) != 0; - let mut found: bool = - WeaklyEqualityComparableWithUnsafe::equal( - &result.0, - &m.find(&key), - ); + let mut found : bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe:: >>::bind(&raw const result .0 ), LvalueRefUnsafe:: >>::bind(&raw const m .find(&key ) ), )) ; ok = ((ok as i32) & (found as i32)) != 0; ok = ((ok as i32) & ((((*result.0.iter_deref()).0) == (key)) diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 52daa3f512..10f010b582 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -46,11 +46,23 @@ impl Bag { } } impl LessThanComparableUnsafe for Bag { - unsafe fn less(a: *const Bag, b: *const Bag) -> bool { - return (((*a).n) < ((*b).n)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + return (unsafe { + let _a: *const Bag = __lhs; + operator_lt_4(_a, __rhs) + }); } } -pub unsafe fn make_4(__return: *mut Bag, mut n: i32) { +pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { + return (((*a).n) < ((*b).n)); +} +pub unsafe fn make_5(__return: *mut Bag, mut n: i32) { Bag::constructor_1(__return, n); return; } @@ -70,7 +82,10 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = &mut x1; let __b: *const _ = &mut x2; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -79,7 +94,10 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = &mut x3; let __b: *const _ = &mut x4; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -88,7 +106,10 @@ unsafe fn main_0() -> i32 { let mut r3: i32 = (*{ let __a: *const _ = p1; let __b: *const _ = &mut x2; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -97,7 +118,10 @@ unsafe fn main_0() -> i32 { let mut r4: i32 = (*{ let __a: *const _ = p2; let __b: *const _ = &mut x3; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -109,7 +133,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -122,14 +149,20 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { values.as_mut_ptr() }; let mut __tmp_3 = { values.as_mut_ptr().offset((4) as isize) }; let mut __best = __tmp_2.clone(); - if WeaklyEqualityComparableWithUnsafe::not_equal(&__tmp_2, &__tmp_3) { + if ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __tmp_2), + LvalueRefUnsafe::>::bind(&raw const __tmp_3), + )) { let mut __it = __tmp_2; __it.iter_inc(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) { - if LessThanComparableUnsafe::less( - __best.iter_deref() as *const _, - __it.iter_deref() as *const _, - ) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_3), + )) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__best.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), + )) { __best = __it.clone(); } __it.iter_inc(); @@ -142,7 +175,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(0) }); let __b: *const _ = (unsafe { pick_3(1) }); - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -154,7 +190,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(1) }); let __b: *const _ = (unsafe { pick_3(0) }); - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -169,18 +208,21 @@ unsafe fn main_0() -> i32 { let mut __tmp_7: Bag = ZeroInitializationUnsafe::zero_init(); (((*match ( ({ - (unsafe { make_4(&raw mut __tmp_5, 1) }); + (unsafe { make_5(&raw mut __tmp_5, 1) }); &mut __tmp_5 } as *const Bag), ({ - (unsafe { make_4(&raw mut __tmp_7, 2) }); + (unsafe { make_5(&raw mut __tmp_7, 2) }); &mut __tmp_7 } as *const Bag), ) { (__tmp_4, __tmp_6) => { let __a: *const _ = __tmp_4; let __b: *const _ = __tmp_6; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -193,18 +235,21 @@ unsafe fn main_0() -> i32 { let mut __tmp_11: Bag = ZeroInitializationUnsafe::zero_init(); (((*match ( ({ - (unsafe { make_4(&raw mut __tmp_9, 1) }); + (unsafe { make_5(&raw mut __tmp_9, 1) }); &mut __tmp_9 } as *const Bag), ({ - (unsafe { make_4(&raw mut __tmp_11, 2) }); + (unsafe { make_5(&raw mut __tmp_11, 2) }); &mut __tmp_11 } as *const Bag), ) { (__tmp_8, __tmp_10) => { let __a: *const _ = __tmp_8; let __b: *const _ = __tmp_10; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -226,7 +271,10 @@ unsafe fn main_0() -> i32 { (__tmp_12,) => { let __a: *const _ = &mut __tmp_13; let __b: *const _ = __tmp_12; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/min_max_ptr2ptr.rs b/tests/unit/out/unsafe/min_max_ptr2ptr.rs index da37cf5a4b..a60a31f9ac 100644 --- a/tests/unit/out/unsafe/min_max_ptr2ptr.rs +++ b/tests/unit/out/unsafe/min_max_ptr2ptr.rs @@ -22,7 +22,10 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -31,7 +34,10 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -45,7 +51,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -56,7 +65,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -67,7 +79,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -78,7 +93,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index d7e4e1e2f9..321aa443eb 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -22,15 +22,118 @@ use std::rc::Rc; pub struct S { pub v: i32, } +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_eq_0(_a, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_ne_1(_a, __rhs) + }); + } +} impl LessThanComparableUnsafe for S { - unsafe fn less(a: *const S, b: *const S) -> bool { - return (((*a).v) < ((*b).v)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_lt_2(_a, __rhs) + }); + } +} +impl PartiallyOrderedWithUnsafe for S { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_lt_2(_a, __rhs) + }); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_gt_3(_a, __rhs) + }); } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_le_4(_a, __rhs) + }); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: *const S = __lhs; + operator_ge_5(_a, __rhs) + }); + } +} +pub unsafe fn operator_eq_0(a: *const S, b: *const S) -> bool { + return (((*a).v) == ((*b).v)); +} +pub unsafe fn operator_ne_1(a: *const S, b: *const S) -> bool { + return (((*a).v) != ((*b).v)); +} +pub unsafe fn operator_lt_2(a: *const S, b: *const S) -> bool { + return (((*a).v) < ((*b).v)); +} +pub unsafe fn operator_gt_3(a: *const S, b: *const S) -> bool { + return (((*a).v) > ((*b).v)); +} +pub unsafe fn operator_le_4(a: *const S, b: *const S) -> bool { + return (((*a).v) <= ((*b).v)); +} +pub unsafe fn operator_ge_5(a: *const S, b: *const S) -> bool { + return (((*a).v) >= ((*b).v)); } -pub unsafe fn operator_lt_0(a: *const S, mut b: i32) -> bool { +pub unsafe fn operator_lt_6(a: *const S, mut b: i32) -> bool { return (((*a).v) < (b)); } -pub unsafe fn operator_lt_1(mut a: i32, b: *const S) -> bool { +pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { return ((a) < ((*b).v)); } #[repr(C)] @@ -49,16 +152,56 @@ pub unsafe fn operator_lt_1(mut a: i32, b: *const S) -> bool { pub struct V { pub v: i32, } -pub unsafe fn operator_eq_2(mut a: V, mut b: V) -> bool { +impl WeaklyEqualityComparableWithUnsafe for V { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + return (unsafe { + let _a: V = (*__lhs); + operator_eq_8(_a, (*__rhs)) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + return (unsafe { + let _a: V = (*__lhs); + operator_ne_9(_a, (*__rhs)) + }); + } +} +impl LessThanComparableUnsafe for V { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + return (unsafe { + let _a: V = (*__lhs); + operator_lt_10(_a, (*__rhs)) + }); + } +} +pub unsafe fn operator_eq_8(mut a: V, mut b: V) -> bool { return ((a.v) == (b.v)); } -pub unsafe fn operator_ne_3(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_ne_9(mut a: V, mut b: V) -> bool { return ((a.v) != (b.v)); } -pub unsafe fn operator_lt_4(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_lt_10(mut a: V, mut b: V) -> bool { return ((a.v) < (b.v)); } -pub unsafe fn operator_gt_5(mut a: V, mut b: V) -> bool { +pub unsafe fn operator_gt_11(mut a: V, mut b: V) -> bool { return ((a.v) > (b.v)); } pub fn main() { @@ -74,31 +217,31 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _a: V = x; - operator_eq_2(_a, z) + operator_eq_8(_a, z) }) ); assert!( (unsafe { let _a: V = x; - operator_ne_3(_a, y) + operator_ne_9(_a, y) }) ); assert!( (unsafe { let _a: V = x; - operator_lt_4(_a, y) + operator_lt_10(_a, y) }) ); assert!( (unsafe { let _a: V = y; - operator_gt_5(_a, x) + operator_gt_11(_a, x) }) ); assert!( !(unsafe { let _a: V = y; - operator_lt_4(_a, x) + operator_lt_10(_a, x) }) ); let mut a: S = S { v: 1 }; @@ -107,74 +250,52 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _a: *const S = &a; - WeaklyEqualityComparableWithUnsafe::equal(_a, &c) + operator_eq_0(_a, &c) }) ); assert!( (unsafe { let _a: *const S = &a; - WeaklyEqualityComparableWithUnsafe::not_equal(_a, &b) + operator_ne_1(_a, &b) }) ); assert!( (unsafe { let _a: *const S = &a; - LessThanComparableUnsafe::less(_a, &b) + operator_lt_2(_a, &b) }) ); assert!( (unsafe { let _a: *const S = &b; - PartiallyOrderedWithUnsafe::greater(_a, &a) + operator_gt_3(_a, &a) }) ); assert!( (unsafe { let _a: *const S = &a; - PartiallyOrderedWithUnsafe::less_equal(_a, &c) + operator_le_4(_a, &c) }) ); assert!( (unsafe { let _a: *const S = &a; - PartiallyOrderedWithUnsafe::greater_equal(_a, &c) + operator_ge_5(_a, &c) }) ); assert!( !(unsafe { let _a: *const S = &b; - LessThanComparableUnsafe::less(_a, &a) + operator_lt_2(_a, &a) }) ); assert!( (unsafe { let _a: *const S = &a; - operator_lt_0(_a, 5) + operator_lt_6(_a, 5) }) ); - assert!((unsafe { operator_lt_1(0, &a,) })); + assert!((unsafe { operator_lt_7(0, &a,) })); return 0; } -impl PartiallyOrderedWithUnsafe for S { - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } - unsafe fn greater(a: *const S, b: *const S) -> bool { - return (((*a).v) > ((*b).v)); - } - unsafe fn less_equal(a: *const S, b: *const S) -> bool { - return (((*a).v) <= ((*b).v)); - } - unsafe fn greater_equal(a: *const S, b: *const S) -> bool { - return (((*a).v) >= ((*b).v)); - } -} -impl WeaklyEqualityComparableWithUnsafe for S { - unsafe fn equal(a: *const S, b: *const S) -> bool { - return (((*a).v) == ((*b).v)); - } - unsafe fn not_equal(a: *const S, b: *const S) -> bool { - return (((*a).v) != ((*b).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 4e3b54c8b4..691541c89b 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -23,13 +23,95 @@ pub struct S { pub v: i32, } impl S { + pub unsafe fn operator_eq(this: *const Self, o: *const S) -> bool { + return (((*this).v) == ((*o).v)); + } + pub unsafe fn operator_ne(this: *const Self, o: *const S) -> bool { + return (((*this).v) != ((*o).v)); + } + pub unsafe fn operator_lt_3(this: *const Self, o: *const S) -> bool { + return (((*this).v) < ((*o).v)); + } + pub unsafe fn operator_gt(this: *const Self, o: *const S) -> bool { + return (((*this).v) > ((*o).v)); + } + pub unsafe fn operator_le(this: *const Self, o: *const S) -> bool { + return (((*this).v) <= ((*o).v)); + } + pub unsafe fn operator_ge(this: *const Self, o: *const S) -> bool { + return (((*this).v) >= ((*o).v)); + } pub unsafe fn operator_lt_7(this: *const Self, mut o: i32) -> bool { return (((*this).v) < (o)); } } +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_ne(&raw const (*__lhs), __rhs) }); + } +} impl LessThanComparableUnsafe for S { - unsafe fn less(this: *const Self, o: *const S) -> bool { - return (((*this).v) < ((*o).v)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); + } +} +impl PartiallyOrderedWithUnsafe for S { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_gt(&raw const (*__lhs), __rhs) }); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_le(&raw const (*__lhs), __rhs) }); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_ge(&raw const (*__lhs), __rhs) }); } } pub fn main() { @@ -42,36 +124,14 @@ unsafe fn main_0() -> i32 { let mut a: S = S { v: 1 }; let mut b: S = S { v: 2 }; let mut c: S = S { v: 1 }; - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const a, &c,) })); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::not_equal(&raw const a, &b,) })); - assert!((unsafe { LessThanComparableUnsafe::less(&raw const a, &b,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::greater(&raw const b, &a,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::less_equal(&raw const a, &c,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::greater_equal(&raw const a, &c,) })); - assert!(!(unsafe { LessThanComparableUnsafe::less(&raw const b, &a,) })); + assert!((unsafe { S::operator_eq(&raw const a, &c,) })); + assert!((unsafe { S::operator_ne(&raw const a, &b,) })); + assert!((unsafe { S::operator_lt_3(&raw const a, &b,) })); + assert!((unsafe { S::operator_gt(&raw const b, &a,) })); + assert!((unsafe { S::operator_le(&raw const a, &c,) })); + assert!((unsafe { S::operator_ge(&raw const a, &c,) })); + assert!(!(unsafe { S::operator_lt_3(&raw const b, &a,) })); assert!((unsafe { S::operator_lt_7(&raw const a, 5,) })); return 0; } -impl PartiallyOrderedWithUnsafe for S { - unsafe fn greater(this: *const Self, o: *const S) -> bool { - return (((*this).v) > ((*o).v)); - } - unsafe fn less_equal(this: *const Self, o: *const S) -> bool { - return (((*this).v) <= ((*o).v)); - } - unsafe fn greater_equal(this: *const Self, o: *const S) -> bool { - return (((*this).v) >= ((*o).v)); - } - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } -} -impl WeaklyEqualityComparableWithUnsafe for S { - unsafe fn equal(this: *const Self, o: *const S) -> bool { - return (((*this).v) == ((*o).v)); - } - unsafe fn not_equal(this: *const Self, o: *const S) -> bool { - return (((*this).v) != ((*o).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index a19dca88fe..7ae9588e4c 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -42,6 +42,144 @@ impl S { return (((*this).v) >= (((*o) as i32) - (('0' as libc::c_char) as i32))); } } +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i32 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = (*__lhs); + operator_eq_0(_a, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = (*__lhs); + operator_ne_1(_a, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for f64 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const f64); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_eq_0(_a, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const f64); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_ne_1(_a, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i64 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_eq_0(_a, __rhs) + }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_ne_1(_a, __rhs) + }); + } +} pub unsafe fn operator_eq_0(mut a: i32, b: *const S) -> bool { return ((a) == ((*b).v)); } diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index 0f7eec1823..b119f79e51 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -22,6 +22,96 @@ use std::rc::Rc; pub struct X { pub v: i32, } +impl WeaklyEqualityComparableWithUnsafe for X { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }); + } + type NotEqualResult = i32; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_ne_1(_a, (*__rhs)) + }); + } +} +impl LessThanComparableUnsafe for X { + type Result = i32; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }); + } +} +impl PartiallyOrderedWithUnsafe for X { + type LessResult = i32; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }); + } + type GreaterResult = i32; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_gt_3(_a, (*__rhs)) + }); + } + type LessEqualResult = i32; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_le_4(_a, (*__rhs)) + }); + } + type GreaterEqualResult = i32; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return (unsafe { + let _a: X = (*__lhs); + operator_ge_5(_a, (*__rhs)) + }); + } +} pub unsafe fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if ((a.v) == (b.v)) { 2 } else { 0 }; } @@ -108,6 +198,17 @@ impl Mixed { return if (((*this).v) == ((*o).v)) { 9 } else { 0 }; } } +impl LessThanComparableUnsafe for Mixed { + type Result = i32; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Mixed); + let __rhs = (__rhs.as_ptr() as *const Mixed); + return (unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, @@ -134,6 +235,96 @@ impl MyBool { return (*this).value; } } +impl WeaklyEqualityComparableWithUnsafe for MyBool { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + != ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl LessThanComparableUnsafe for MyBool { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl PartiallyOrderedWithUnsafe for MyBool { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + > ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + <= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + >= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl ThreeWayComparableUnsafe for MyBool { + type Category = std_strong_ordering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32), + &((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32), + )); + } +} #[repr(C)] #[derive( Copy, @@ -150,14 +341,28 @@ impl MyBool { pub struct Boolish { pub v: i32, } -pub unsafe fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { +impl LessThanComparableUnsafe for Boolish { + type Result = MyBool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Boolish); + let __rhs = (__rhs.as_ptr() as *const Boolish); + return (unsafe { + let _a: Boolish = (*__lhs); + operator_lt_6(_a, (*__rhs)) + }); + } +} +pub unsafe fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) == (b.v))); __v }; } -pub unsafe fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) < (b.v))); @@ -188,6 +393,96 @@ impl RefBool { return (*this).value; } } +impl WeaklyEqualityComparableWithUnsafe for RefBool { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + != ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl LessThanComparableUnsafe for RefBool { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl PartiallyOrderedWithUnsafe for RefBool { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + > ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + <= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + >= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); + } +} +impl ThreeWayComparableUnsafe for RefBool { + type Category = std_strong_ordering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + return std_strong_ordering::from(std::cmp::Ord::cmp( + &((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32), + &((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32), + )); + } +} pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { let mut __v: RefBool = ZeroInitializationUnsafe::zero_init(); @@ -274,11 +569,17 @@ unsafe fn main_0() -> i32 { let __n = xs.as_mut_ptr().offset((3) as isize).iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const X; + let __b = __tmp_0.iter_at(__y) as *const X; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -310,11 +611,17 @@ unsafe fn main_0() -> i32 { let __n = ms.as_mut_ptr().offset((3) as isize).iter_distance(&__tmp_1); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_1.iter_at(__x) as *const _; - let __b = __tmp_1.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_1.iter_at(__x) as *const Mixed; + let __b = __tmp_1.iter_at(__y) as *const Mixed; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -345,7 +652,7 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b1; - operator_eq_6(_a, Boolish { v: 1 }) + operator_eq_7(_a, Boolish { v: 1 }) }), ) }) @@ -355,14 +662,14 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b2; - operator_lt_7(_a, b1) + operator_lt_6(_a, b1) }), ) }) ); let mut lt: MyBool = (unsafe { let _a: Boolish = b1; - operator_lt_7(_a, b2) + operator_lt_6(_a, b2) }); assert!(lt.value); let mut bs: [Boolish; 3] = [Boolish { v: 3 }, Boolish { v: 1 }, Boolish { v: 2 }]; @@ -371,11 +678,17 @@ unsafe fn main_0() -> i32 { let __n = bs.as_mut_ptr().offset((3) as isize).iter_distance(&__tmp_2); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_2.iter_at(__x) as *const _; - let __b = __tmp_2.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_2.iter_at(__x) as *const Boolish; + let __b = __tmp_2.iter_at(__y) as *const Boolish; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -405,9 +718,13 @@ unsafe fn main_0() -> i32 { (({ let mut __tmp_3 = { ris.as_mut_ptr().offset((2) as isize) }; let mut __it = ris.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &ri2) - { + while ConvertibleToUnsafe::::convert_value(<*mut RefInt>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_3), + )) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const ri2), + )) { __it.iter_inc(); } __it diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index d2172b3b03..c0c0497477 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -6,10 +6,11 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -impl LessThanComparableUnsafe for S { - unsafe fn less(x: *const S, y: *const S) -> bool { - return (((*x).data_) < ((*y).data_)); - } +pub unsafe fn operator_eq_0(x: *const S, y: *const S) -> bool { + return (((*x).data_) == ((*y).data_)); +} +pub unsafe fn operator_lt_1(x: *const S, y: *const S) -> bool { + return (((*x).data_) < ((*y).data_)); } #[repr(C)] #[derive( @@ -27,6 +28,20 @@ impl S { (&raw mut (*this).data_).write(data); } } +impl LessThanComparableUnsafe for S { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _x: *const S = __lhs; + operator_lt_1(_x, __rhs) + }); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -40,26 +55,21 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const S = &a; - WeaklyEqualityComparableWithUnsafe::equal(_x, &c) + operator_eq_0(_x, &c) }) ); assert!( (unsafe { let _x: *const S = &a; - LessThanComparableUnsafe::less(_x, &b) + operator_lt_1(_x, &b) }) ); assert!( !(unsafe { let _x: *const S = &b; - LessThanComparableUnsafe::less(_x, &a) + operator_lt_1(_x, &a) }) ); return 0; } -impl WeaklyEqualityComparableWithUnsafe for S { - unsafe fn equal(x: *const S, y: *const S) -> bool { - return (((*x).data_) == ((*y).data_)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index d14ee5c86c..756601671c 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -65,6 +65,82 @@ impl S { return (((*this).v) != (0)); } } +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + == (unsafe { S::to_i32(&raw const (*__rhs)) })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + != (unsafe { S::to_i32(&raw const (*__rhs)) })); + } +} +impl LessThanComparableUnsafe for S { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + < (unsafe { S::to_i32(&raw const (*__rhs)) })); + } +} +impl PartiallyOrderedWithUnsafe for S { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + < (unsafe { S::to_i32(&raw const (*__rhs)) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + > (unsafe { S::to_i32(&raw const (*__rhs)) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + <= (unsafe { S::to_i32(&raw const (*__rhs)) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { S::to_i32(&raw const (*__lhs)) }) + >= (unsafe { S::to_i32(&raw const (*__rhs)) })); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index ac8c89c5b3..8f5b3c8dbb 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -16,18 +16,14 @@ use std::rc::Rc; TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct S { pub v: i32, } -impl ThreeWayComparableUnsafe for S { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, o: *const S) -> libcc2rs::StrongOrdering { +impl S { + pub unsafe fn operator_cmp(this: *const Self, o: *const S) -> libcc2rs::StrongOrdering { if (((*this).v) < ((*o).v)) { return libcc2rs::STRONG_ORDERING_LESS; } @@ -36,6 +32,89 @@ impl ThreeWayComparableUnsafe for S { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq(this: *const Self, o: *const S) -> bool { + return (((*this).v) == ((*o).v)); + } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return !(unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for S { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for S { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return libcc2rs::is_gt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return libcc2rs::is_lteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return libcc2rs::is_gteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for S { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }); + } } pub fn main() { unsafe { @@ -47,22 +126,20 @@ unsafe fn main_0() -> i32 { let mut a: S = S { v: 1 }; let mut b: S = S { v: 2 }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const a, &b,) }) + (unsafe { S::operator_cmp(&raw const a, &b,) }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const b, &a,) }) + (unsafe { S::operator_cmp(&raw const b, &a,) }) )); assert!(libcc2rs::is_lteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const a, &b,) }) + (unsafe { S::operator_cmp(&raw const a, &b,) }) )); assert!(libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const b, &a,) }) + (unsafe { S::operator_cmp(&raw const b, &a,) }) )); - assert!(!(unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const a, &b,) })); + assert!(!(unsafe { S::operator_eq(&raw const a, &b,) })); assert!({ - let __a = libcc2rs::PartialOrdering::from( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const a, &b) }), - ); + let __a = libcc2rs::PartialOrdering::from((unsafe { S::operator_cmp(&raw const a, &b) })); let __b = libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_LESS); libcc2rs::is_lt(__a) == libcc2rs::is_lt(__b) && libcc2rs::is_eq(__a) == libcc2rs::is_eq(__b) @@ -70,9 +147,4 @@ unsafe fn main_0() -> i32 { }); return 0; } -impl WeaklyEqualityComparableWithUnsafe for S { - unsafe fn equal(this: *const Self, o: *const S) -> bool { - return (((*this).v) == ((*o).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index 2674a4d16b..5188469917 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -50,6 +50,82 @@ impl Meters { return (*this).value; } } +impl WeaklyEqualityComparableWithUnsafe for Meters { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + == (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + != (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } +} +impl LessThanComparableUnsafe for Meters { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } +} +impl PartiallyOrderedWithUnsafe for Meters { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + > (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + <= (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + >= (unsafe { Meters::to_i32(&raw const (*__rhs)) })); + } +} #[repr(C)] #[derive( Copy, diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 3c4e44ba37..9c6f7f5402 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -82,7 +82,10 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { let mut __tmp_2 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_2) { + while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_2), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -114,7 +117,10 @@ pub unsafe fn emplace_local_from_field_4(mut jpg: *mut JPEGData, mut cond: bool) let mut __tmp_3 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) { + while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_3), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -276,7 +282,10 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { let mut __tmp_4 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_4) { + while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_4), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -352,7 +361,10 @@ pub unsafe fn emplace_from_sibling_18(mut s: *mut Bytes) { let mut __tmp_5 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_5) { + while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_5), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs index 3e97994247..cce76c888d 100644 --- a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs +++ b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs @@ -9,10 +9,12 @@ use std::rc::Rc; pub unsafe fn sink_0(mut it: UnsafeBidirectionalIterator<(i32, i32)>) -> i32 { let mut cit: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it).clone()); - return if WeaklyEqualityComparableWithUnsafe::equal( - &cit, - &>::from((it).clone()), - ) { + return if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const cit), + LvalueRefUnsafe::>>::bind( + &raw const >::from((it).clone()), + ), + )) { (*it.iter_deref()).1 } else { 0 @@ -37,16 +39,24 @@ unsafe fn main_0() -> i32 { let mut it0: UnsafeBidirectionalIterator<(i32, i32)> = m.find(&0); let mut const_it: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it0).clone()); - let mut r: i32 = if WeaklyEqualityComparableWithUnsafe::equal( - &const_it, - &>::from((end).clone()), - ) { - 0 - } else { - 1 - }; + let mut r: i32 = + if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const const_it, + ), + LvalueRefUnsafe::>>::bind( + &raw const >::from((end).clone()), + ), + )) { + 0 + } else { + 1 + }; r += (unsafe { sink_0((it0).clone()) }); - r += if WeaklyEqualityComparableWithUnsafe::equal(&end, &end) { + r += if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const end), + LvalueRefUnsafe::>>::bind(&raw const end), + )) { 0 } else { 1 @@ -57,9 +67,13 @@ unsafe fn main_0() -> i32 { let mut const_middle: UnsafeRandomAccessIterator = >::from((middle).clone()); assert!(((*const_middle.iter_deref()) == (8_u32))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &const_middle, - &middle + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const const_middle + ), + LvalueRefUnsafe::>>::bind(&raw const middle), + ) )); return 0; } diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index b9541e72a6..e67c519982 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -36,7 +36,10 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __first = src.as_mut_ptr(); let mut __out = (dst.as_mut_ptr() as *mut usize).cast::(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &__tmp_0) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const __tmp_0), + )) { object_unsafe!(__value, u64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -82,9 +85,15 @@ pub unsafe fn size_t_in_rules_3() { |__k| cpp_move_unsafe!(__k), || 0_u64, )) = 4_u64; - assert!(WeaklyEqualityComparableWithUnsafe::not_equal( - &m.find(&1_u64), - &m.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const m.find(&1_u64) + ), + LvalueRefUnsafe::>>::bind( + &raw const m.end() + ), + ) )); assert!((((*m.begin().iter_deref()).0) == (1_u64))); let mut m2: UnsafeMap = std::mem::take(&mut m); @@ -204,7 +213,10 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_6 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_6) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_6), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -225,7 +237,12 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_8 = { v.begin() }; let mut __tmp_9 = { v.end() }; let mut __it = (__tmp_8).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_9) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind(&raw const __it), + LvalueRefUnsafe::>>::bind(&raw const __tmp_9), + ), + ) { *__it.iter_deref() = Clone::clone(&(k as u64)); __it.iter_inc(); } @@ -240,7 +257,10 @@ pub unsafe fn size_t_in_rules_3() { (*{ let __a: *const _ = &mut v[(1_usize)]; let __b: *const _ = &mut __tmp_10; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -291,19 +311,31 @@ pub unsafe fn size_t_in_rules_3() { v3.push(__a2) } }; - assert!(WeaklyEqualityComparableWithUnsafe::not_equal( - &{ - let mut __tmp_13 = { v3.begin() }; - let mut __tmp_14 = { v3.end() }; - let mut __it = (__tmp_13).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_14) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &(k as u64)) - { - __it.iter_inc(); - } - __it - }, - &v3.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_13 = { v3.begin() }; + let mut __tmp_14 = { v3.end() }; + let mut __it = (__tmp_13).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_14, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const (k as u64)), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind(&raw const v3.end()), + ) )); assert!((((v3.len()) == (5_usize)) && ((big) >= (k))) && (((pk.1) as usize) == (k))); let mut ci: UnsafeRandomAccessIterator = @@ -364,7 +396,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_15; let __b: *const _ = &mut __tmp_16; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -376,7 +411,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_17; let __b: *const _ = &mut ul; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -391,7 +429,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_18; let __b: *const _ = &mut __tmp_19; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -450,7 +491,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_20; let __b: *const _ = &mut __tmp_21; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -463,7 +507,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_22; let __b: *const _ = &mut __tmp_23; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -493,7 +540,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_24; let __b: *const _ = &mut __tmp_25; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -506,7 +556,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_26; let __b: *const _ = &mut __tmp_27; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index 43cdf5c306..5cd37dcea5 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -59,11 +59,17 @@ unsafe fn main_0() -> i32 { let __n = v.end().iter_distance(&__tmp_10); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_10.iter_at(__x) as *const _; - let __b = __tmp_10.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_10.iter_at(__x) as *const i32; + let __b = __tmp_10.iter_at(__y) as *const i32; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index c58ce47980..c3849e9d7e 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -51,6 +51,20 @@ impl MoveAssignableUnsafe for Tracked { return &mut (*this); } } +impl LessThanComparableUnsafe for Tracked { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Tracked); + let __rhs = (__rhs.as_ptr() as *const Tracked); + return (unsafe { + let _a: *const Tracked = __lhs; + operator_lt_1(_a, __rhs) + }); + } +} impl Default for Tracked { fn default() -> Self { unsafe { @@ -62,12 +76,10 @@ impl Default for Tracked { } } } -impl LessThanComparableUnsafe for Tracked { - unsafe fn less(a: *const Tracked, b: *const Tracked) -> bool { - return (((*a).v) < ((*b).v)); - } +pub unsafe fn operator_lt_1(a: *const Tracked, b: *const Tracked) -> bool { + return (((*a).v) < ((*b).v)); } -pub unsafe fn greater_1(a: *const Tracked, b: *const Tracked) -> bool { +pub unsafe fn greater_2(a: *const Tracked, b: *const Tracked) -> bool { return (((*a).v) > ((*b).v)); } #[repr(C)] @@ -92,10 +104,22 @@ impl MoveOnly { } } impl LessThanComparableUnsafe for MoveOnly { - unsafe fn less(a: *const MoveOnly, b: *const MoveOnly) -> bool { - return (((*a).v) < ((*b).v)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const MoveOnly); + let __rhs = (__rhs.as_ptr() as *const MoveOnly); + return (unsafe { + let _a: *const MoveOnly = __lhs; + operator_lt_3(_a, __rhs) + }); } } +pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { + return (((*a).v) < ((*b).v)); +} #[repr(C)] #[derive( FnPtrArg, @@ -118,10 +142,25 @@ impl Bag { } } impl LessThanComparableUnsafe for Bag { - unsafe fn less(a: *const Bag, b: *const Bag) -> bool { - return (((*a).items.len()) < ((*b).items.len())); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + return (unsafe { + let _a: *const Bag = __lhs; + operator_lt_4(_a, __rhs) + }); } } +pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { + return (((*a).items.len()) < ((*b).items.len())); +} +pub unsafe fn operator_eq_5(a: *const Bag, b: *const Bag) -> bool { + return (((*a).items.len()) == ((*b).items.len())); +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -164,11 +203,17 @@ unsafe fn main_0() -> i32 { .iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const Tracked; + let __b = __tmp_0.iter_at(__y) as *const Tracked; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -219,11 +264,17 @@ unsafe fn main_0() -> i32 { let __n = vec_.end().iter_distance(&__tmp_1); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_1.iter_at(__x) as *const _; - let __b = __tmp_1.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_1.iter_at(__x) as *const Tracked; + let __b = __tmp_1.iter_at(__y) as *const Tracked; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -250,9 +301,9 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_2.iter_at(__x) as *const _; let __b = __tmp_2.iter_at(__y) as *const _; - if (greater_1 as unsafe fn(*const Tracked, *const Tracked) -> bool).call(__a, __b) { + if (greater_2 as unsafe fn(*const Tracked, *const Tracked) -> bool).call(__a, __b) { std::cmp::Ordering::Less - } else if (greater_1 as unsafe fn(*const Tracked, *const Tracked) -> bool) + } else if (greater_2 as unsafe fn(*const Tracked, *const Tracked) -> bool) .call(__b, __a) { std::cmp::Ordering::Greater @@ -318,9 +369,9 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_4.iter_at(__x) as *const _; let __b = __tmp_4.iter_at(__y) as *const _; - if (greater_1 as unsafe fn(*const Tracked, *const Tracked) -> bool).call(__a, __b) { + if (greater_2 as unsafe fn(*const Tracked, *const Tracked) -> bool).call(__a, __b) { std::cmp::Ordering::Less - } else if (greater_1 as unsafe fn(*const Tracked, *const Tracked) -> bool) + } else if (greater_2 as unsafe fn(*const Tracked, *const Tracked) -> bool) .call(__b, __a) { std::cmp::Ordering::Greater @@ -369,11 +420,17 @@ unsafe fn main_0() -> i32 { .iter_distance(&__tmp_5); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_5.iter_at(__x) as *const _; - let __b = __tmp_5.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_5.iter_at(__x) as *const Bag; + let __b = __tmp_5.iter_at(__y) as *const Bag; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -413,11 +470,17 @@ unsafe fn main_0() -> i32 { let __n = bag_vec.end().iter_distance(&__tmp_6); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_6.iter_at(__x) as *const _; - let __b = __tmp_6.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_6.iter_at(__x) as *const Bag; + let __b = __tmp_6.iter_at(__y) as *const Bag; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -436,50 +499,86 @@ unsafe fn main_0() -> i32 { && ((bag_vec[(2_usize)].items[(1_usize)].v) == (5)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_7 = { bag_vec.begin() }; - let mut __tmp_8 = { bag_vec.end() }; - let mut __it = (__tmp_7).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_8) - && !WeaklyEqualityComparableWithUnsafe::equal( - &*__it.iter_deref(), - &bags[(1) as usize], - ) - { - __it.iter_inc(); - } - __it - }, - &bag_vec.begin().iter_add(1_isize) + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_7 = { bag_vec.begin() }; + let mut __tmp_8 = { bag_vec.end() }; + let mut __it = (__tmp_7).clone(); + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_8, + ), + ), + ) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&raw const bags[(1) as usize]), + )) { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind( + &raw const bag_vec.begin().iter_add(1_isize) + ), + ) )); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_9 = { bag_vec.begin() }; - let mut __tmp_10 = { bag_vec.end() }; - let mut __best = __tmp_9.clone(); - if WeaklyEqualityComparableWithUnsafe::not_equal(&__tmp_9, &__tmp_10) { - let mut __it = (__tmp_9).clone(); - __it.iter_inc(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_10) { - if LessThanComparableUnsafe::less( - __best.iter_deref() as *const _, - __it.iter_deref() as *const _, - ) { - __best = __it.clone(); - } + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&raw const { + let mut __tmp_9 = { bag_vec.begin() }; + let mut __tmp_10 = { bag_vec.end() }; + let mut __best = __tmp_9.clone(); + if ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __tmp_9, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_10, + ), + ), + ) { + let mut __it = (__tmp_9).clone(); __it.iter_inc(); + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_10, + ), + )) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__best.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), + )) { + __best = __it.clone(); + } + __it.iter_inc(); + } } - } - __best - }, - &bag_vec.begin().iter_add(2_isize) + __best + }), + LvalueRefUnsafe::>>::bind( + &raw const bag_vec.begin().iter_add(2_isize) + ), + ) )); assert!( (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a @@ -490,7 +589,10 @@ unsafe fn main_0() -> i32 { (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if LessThanComparableUnsafe::less(__a, __b) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { __b } else { __a @@ -510,9 +612,15 @@ unsafe fn main_0() -> i32 { || 0_i32, )) = 0; assert!((((*bag_map.find(&bags[(2) as usize]).iter_deref()).1) == (2))); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &bag_map.find(&bags[(1) as usize]), - &bag_map.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &raw const bag_map.find(&bags[(1) as usize]) + ), + LvalueRefUnsafe::>>::bind( + &raw const bag_map.end() + ), + ) )); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut moves: Vec = Vec::new(); @@ -536,11 +644,17 @@ unsafe fn main_0() -> i32 { let __n = moves.end().iter_distance(&__tmp_11); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_11.iter_at(__x) as *const _; - let __b = __tmp_11.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_11.iter_at(__x) as *const MoveOnly; + let __b = __tmp_11.iter_at(__y) as *const MoveOnly; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -603,11 +717,6 @@ unsafe fn main_0() -> i32 { ); return (*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)); } -impl WeaklyEqualityComparableWithUnsafe for Bag { - unsafe fn equal(a: *const Bag, b: *const Bag) -> bool { - return (((*a).items.len()) == ((*b).items.len())); - } -} pub unsafe fn __cpp2rust_init_globals() { std::cell::LazyCell::force(&*&raw const copies_0); } diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 7ca1020bed..0873210463 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -41,7 +41,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = output.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &__tmp_0) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const __tmp_0), + )) { object_unsafe!(__value, i32, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -60,7 +63,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = widened.begin(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const __tmp_1), + )) { object_unsafe!(__value, i64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -89,7 +95,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_4 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = constructed.begin(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &__tmp_4) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const __tmp_4), + )) { object_unsafe!(__value, Degrees, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -110,7 +119,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { wide.as_mut_ptr().offset((2) as isize) }; let mut __first = wide.as_mut_ptr(); let mut __out = floating.begin(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__first, &__tmp_5) { + while ConvertibleToUnsafe::::convert_value(<*mut i64>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __first), + LvalueRefUnsafe::>::bind(&raw const __tmp_5), + )) { object_unsafe!(__value, f64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this diff --git a/tests/unit/out/unsafe/stdcopy_ostream.rs b/tests/unit/out/unsafe/stdcopy_ostream.rs index de2abdc633..49ced1b2aa 100644 --- a/tests/unit/out/unsafe/stdcopy_ostream.rs +++ b/tests/unit/out/unsafe/stdcopy_ostream.rs @@ -37,7 +37,16 @@ unsafe fn main_0() -> i32 { let mut __it = (__tmp_0).clone(); let __out = &mut ofs; let mut __bytes: Vec = Vec::new(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_1, + ), + )) { __bytes.push(*__it.iter_deref() as u8); __it.iter_inc(); } diff --git a/tests/unit/out/unsafe/stdmin_fpoint.rs b/tests/unit/out/unsafe/stdmin_fpoint.rs index d4071745ca..60f0ca193b 100644 --- a/tests/unit/out/unsafe/stdmin_fpoint.rs +++ b/tests/unit/out/unsafe/stdmin_fpoint.rs @@ -18,7 +18,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut a0; let __b: *const _ = &mut a1; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index 48dfc6485f..fa9a190ecf 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -55,19 +55,34 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) let mut __tmp_0 = { items.begin() }; let mut __tmp_1 = { items.end() }; let mut __it = (__tmp_0).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) - && !WeaklyEqualityComparableWithUnsafe::equal( - &*__it.iter_deref(), - &(*sigma.offset((i) as isize)), - ) - { + while ConvertibleToUnsafe::::convert_value(>::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_1, + ), + )) && !ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind( + &raw const (*sigma.offset((i) as isize)), + ), + )) { __it.iter_inc(); } __it }; - assert!(WeaklyEqualityComparableWithUnsafe::not_equal( - &it, - &items.end() + assert!(ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const it + ), + LvalueRefUnsafe::>>::bind( + &raw const items.end() + ), + ) )); (*code.offset((i) as isize)) = ((it.iter_distance(&items.begin())) as u32); { @@ -87,7 +102,14 @@ pub unsafe fn sum_4(v: *mut Vec) -> i32 { let mut s: i32 = 0; { let mut it: UnsafeRandomAccessIterator = (*v).begin(); - 'loop_: while WeaklyEqualityComparableWithUnsafe::not_equal(&it, &(*v).end()) { + 'loop_: while ConvertibleToUnsafe::::convert_value( + WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&raw const it), + LvalueRefUnsafe::>>::bind( + &raw const (*v).end(), + ), + ), + ) { 'for_body: { s += (*it.iter_deref()); } diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 748a99e85b..0a807d1100 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -170,7 +170,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut high; let __b: *const _ = &mut __tmp_0; - if LessThanComparableUnsafe::less(__b, __a) { + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { __b } else { __a diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 44560dac26..ad09acaaef 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -191,7 +191,12 @@ unsafe fn main_0() -> i32 { __tmp_7.iter_distance(&UnsafeRandomAccessIterator::Vec(v2.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_8).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_9) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind(&raw const __it), + LvalueRefUnsafe::>>::bind(&raw const __tmp_9), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -519,7 +524,10 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_20) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_20), + )) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -544,7 +552,16 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_22).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_23) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_23, + ), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -565,7 +582,10 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_25) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_25), + )) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -586,7 +606,10 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_27) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_27), + )) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -607,7 +630,16 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_29).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_30) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_30, + ), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 202b307dc7..2fb259d2d6 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -50,6 +50,82 @@ impl Reading { return (((*this).raw_ as i64) * (10_i64)); } } +impl WeaklyEqualityComparableWithUnsafe for Reading { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + == (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + != (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } +} +impl LessThanComparableUnsafe for Reading { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } +} +impl PartiallyOrderedWithUnsafe for Reading { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + > (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + <= (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + >= (unsafe { Reading::to_i64(&raw const (*__rhs)) })); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -62,7 +138,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_0) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_0), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -81,7 +160,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_1) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_1), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -100,7 +182,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_2) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_2), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -117,7 +202,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_3) { + while ConvertibleToUnsafe::::convert_value(<*const u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_3), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -145,7 +233,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_5) { + while ConvertibleToUnsafe::::convert_value(<*const u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_5), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -184,7 +275,16 @@ unsafe fn main_0() -> i32 { let mut __tmp_10 = { m.end() }; let mut __v: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_9).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_10) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_10, + ), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -208,7 +308,16 @@ unsafe fn main_0() -> i32 { __tmp_11.iter_distance(&UnsafeRandomAccessIterator::Vec(v6.as_mut_ptr())) as usize; let mut __tmp: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_12).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_13) { + while ConvertibleToUnsafe::::convert_value( + >::not_equal( + LvalueRefUnsafe::>>::bind( + &raw const __it, + ), + LvalueRefUnsafe::>>::bind( + &raw const __tmp_13, + ), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -230,7 +339,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_14 = { ints.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_14) { + while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_14), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -246,7 +358,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_15 = { readings.as_mut_ptr().offset((2) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = readings.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_15) { + while ConvertibleToUnsafe::::convert_value(<*mut Reading>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_15), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index 1ba3b4e042..bf36fe931d 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -321,7 +321,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_16 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_16) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_16), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -340,7 +343,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_17 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_17) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_17), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -359,7 +365,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_18 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_18) { + while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_18), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -376,7 +385,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_19 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_19) { + while ConvertibleToUnsafe::::convert_value(<*const u32>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_19), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -398,7 +410,10 @@ unsafe fn main_0() -> i32 { let mut __tmp_20 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_20) { + while ConvertibleToUnsafe::::convert_value(<*const u8>::not_equal( + LvalueRefUnsafe::>::bind(&raw const __it), + LvalueRefUnsafe::>::bind(&raw const __tmp_20), + )) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/void_return.rs b/tests/unit/out/unsafe/void_return.rs index 2a9f3c23a6..2d8962a25f 100644 --- a/tests/unit/out/unsafe/void_return.rs +++ b/tests/unit/out/unsafe/void_return.rs @@ -15,11 +15,17 @@ pub unsafe fn f1_0( let __n = (last).clone().iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const i32; + let __b = __tmp_0.iter_at(__y) as *const i32; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -40,11 +46,17 @@ pub unsafe fn f1_1(mut first: *mut i32, mut last: *mut i32) { let __n = last.iter_distance(&first); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = first.iter_at(__x) as *const _; - let __b = first.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = first.iter_at(__x) as *const i32; + let __b = first.iter_at(__y) as *const i32; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + )) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal From d9038c8a2603200f7dffe3bbd16628b0069c417e Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 21:56:46 +0000 Subject: [PATCH 05/17] Update rules --- rules/algorithm/tgt_unsafe.rs | 34 +++++++++++++-------------- rules/iterator_category/tgt_unsafe.rs | 28 +++++++++++----------- rules/pair/tgt_unsafe.rs | 32 ++++++++++++------------- rules/vector/tgt_unsafe.rs | 8 +++---- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index ede6cfb958..d921c27ddd 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -51,8 +51,8 @@ where let mut __out = a2; while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&a1), ), ) { object_unsafe!(__value, T4, |__this| ConvertibleToUnsafe::convert( @@ -81,13 +81,13 @@ unsafe fn f3< let mut __it = a0; while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const a2), + LvalueRefUnsafe::>::bind(&a2), ), ) { __it.iter_inc(); @@ -125,16 +125,16 @@ unsafe fn f8, T2: LessThanComparableUnsafe>(a0: T let mut __best = a0.clone(); if ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), ), ) { let mut __it = a0; __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) { if ConvertibleToUnsafe::::convert_value(::less( @@ -163,8 +163,8 @@ unsafe fn f10< a1: T1, ) -> T1 { if ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) { a1 } else { @@ -173,8 +173,8 @@ unsafe fn f10< __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) { if !ConvertibleToUnsafe::::convert_value( @@ -197,8 +197,8 @@ unsafe fn f12, T2: Clone>(a0: T1, a1: T1, a2: T2) let mut __it = a0; while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) { *__it.iter_deref() = Clone::clone(&a2); @@ -216,8 +216,8 @@ unsafe fn f13>( let mut __bytes: Vec = Vec::new(); while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) { __bytes.push(*__it.iter_deref() as u8); diff --git a/rules/iterator_category/tgt_unsafe.rs b/rules/iterator_category/tgt_unsafe.rs index 9b3714a888..21a5a7bb2b 100644 --- a/rules/iterator_category/tgt_unsafe.rs +++ b/rules/iterator_category/tgt_unsafe.rs @@ -60,15 +60,15 @@ fn f8, T2>(a0: T1) -> *mut T2 { unsafe fn f9, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } unsafe fn f10, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } @@ -113,29 +113,29 @@ fn f19, T2>(a0: T1, a1: isize) -> *mut T2 unsafe fn f20, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } unsafe fn f21, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } unsafe fn f22, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less_equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } unsafe fn f23, T2>(a0: T1, a1: T1) -> bool { ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater_equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } @@ -162,7 +162,7 @@ unsafe fn f27< a1: T2, ) -> bool { ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index cc7248506d..02554ed816 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -211,12 +211,12 @@ unsafe fn f28< a1: (T1, T2), ) -> bool { !(ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a0.0), - LvalueRefUnsafe::>::bind(&raw const a1.0), + LvalueRefUnsafe::>::bind(&a0.0), + LvalueRefUnsafe::>::bind(&a1.0), )) && ConvertibleToUnsafe::::convert_value( ::equal( - LvalueRefUnsafe::>::bind(&raw const a0.1), - LvalueRefUnsafe::>::bind(&raw const a1.1), + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), ), )) } @@ -226,8 +226,8 @@ unsafe fn f29( a1: (T1, T2), ) -> bool { ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } @@ -236,8 +236,8 @@ unsafe fn f30( a1: (T1, T2), ) -> bool { !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a1), - LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&a1), + LvalueRefUnsafe::>::bind(&a0), )) } @@ -246,8 +246,8 @@ unsafe fn f31( a1: (T1, T2), ) -> bool { ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a1), - LvalueRefUnsafe::>::bind(&raw const a0), + LvalueRefUnsafe::>::bind(&a1), + LvalueRefUnsafe::>::bind(&a0), )) } @@ -256,8 +256,8 @@ unsafe fn f32( a1: (T1, T2), ) -> bool { !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a0), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), )) } @@ -269,12 +269,12 @@ unsafe fn f33< a1: (T1, T2), ) -> bool { ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a0.0), - LvalueRefUnsafe::>::bind(&raw const a1.0), + LvalueRefUnsafe::>::bind(&a0.0), + LvalueRefUnsafe::>::bind(&a1.0), )) && ConvertibleToUnsafe::::convert_value( ::equal( - LvalueRefUnsafe::>::bind(&raw const a0.1), - LvalueRefUnsafe::>::bind(&raw const a1.1), + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), ), ) } diff --git a/rules/vector/tgt_unsafe.rs b/rules/vector/tgt_unsafe.rs index 4aedac640b..f9bf5db6e7 100644 --- a/rules/vector/tgt_unsafe.rs +++ b/rules/vector/tgt_unsafe.rs @@ -170,8 +170,8 @@ unsafe fn f92< let mut __it = a0; while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a1), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); @@ -225,8 +225,8 @@ unsafe fn f101< let mut __it = a2; while ConvertibleToUnsafe::::convert_value( ::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const a3), + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a3), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); From c65a737a6ec6367295261322a22838970c089b80 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 21:56:54 +0000 Subject: [PATCH 06/17] Don't drop as Trait --- rule-preprocessor/src/syntactic.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rule-preprocessor/src/syntactic.rs b/rule-preprocessor/src/syntactic.rs index a3bd5599ab..86272020bd 100644 --- a/rule-preprocessor/src/syntactic.rs +++ b/rule-preprocessor/src/syntactic.rs @@ -385,6 +385,13 @@ impl<'a> FragmentCtx<'a> { return None; } let segment = path.segment()?; + if segment + .syntax() + .descendants_with_tokens() + .any(|element| element.kind() == SyntaxKind::AS_KW) + { + return None; + } let name = match segment.name_ref() { Some(name_ref) => name_ref.text().to_string(), None => segment From c9b04146887fd950a9c6eed38ab6d68443b8117e Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:00:16 +0000 Subject: [PATCH 07/17] Update tests --- .../out/refcount/class.spaceship.rs | 38 +++-- .../out/unsafe/class.spaceship.rs | 4 +- .../refcount/concept.equalitycomparable.rs | 8 +- .../out/unsafe/concept.equalitycomparable.rs | 44 ++--- .../out/refcount/sequence.reqmts.rs | 4 +- .../out/unsafe/sequence.reqmts.rs | 22 +-- .../out/refcount/utility.arg.requirements.rs | 88 +++++----- .../out/unsafe/utility.arg.requirements.rs | 131 +++++---------- .../pairs/out/refcount/pairs.pair.rs | 54 ++++--- .../utilities/pairs/out/unsafe/pairs.pair.rs | 116 ++++++++------ tests/ub/out/refcount/max.rs | 4 +- tests/ub/out/unsafe/max.rs | 4 +- tests/unit/out/refcount/copy_ctor.rs | 10 +- .../refcount/elidable_iterator_copy_cxx11.rs | 18 ++- .../out/refcount/emplace_receiver_alias.rs | 10 +- .../out/refcount/emplace_receiver_order.rs | 20 ++- tests/unit/out/refcount/find.rs | 108 +++++-------- .../out/refcount/global_call_temporaries.rs | 18 +-- tests/unit/out/refcount/max.rs | 48 +++--- tests/unit/out/refcount/min_max_ptr2ptr.rs | 12 +- .../refcount/operator_comparison_nonbool.rs | 18 ++- tests/unit/out/refcount/push_emplace_back.rs | 40 +++-- tests/unit/out/refcount/size_t_ssize_t.rs | 58 ++++--- tests/unit/out/refcount/sort_no_copy.rs | 46 +++--- tests/unit/out/refcount/stdcopy.rs | 40 +++-- tests/unit/out/refcount/stdcopy_ostream.rs | 10 +- tests/unit/out/refcount/stdmin_fpoint.rs | 2 +- .../refcount/unboxed_conditional_iterator.rs | 12 +- tests/unit/out/refcount/unboxed_locals.rs | 2 +- tests/unit/out/refcount/vector.rs | 60 ++++--- .../out/refcount/vector_iter_range_ctor.rs | 112 +++++-------- .../out/refcount/vector_with_allocator.rs | 50 +++--- tests/unit/out/unsafe/cast.rs | 20 ++- .../out/unsafe/container_element_receiver.rs | 6 +- tests/unit/out/unsafe/copy_ctor.rs | 10 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 32 ++-- .../unit/out/unsafe/emplace_receiver_alias.rs | 10 +- .../unit/out/unsafe/emplace_receiver_order.rs | 18 +-- tests/unit/out/unsafe/find.rs | 130 ++++----------- .../out/unsafe/global_call_temporaries.rs | 90 ++++++----- tests/unit/out/unsafe/map.rs | 54 +++---- tests/unit/out/unsafe/map_key_identity.rs | 46 +++--- tests/unit/out/unsafe/map_try_emplace.rs | 2 +- tests/unit/out/unsafe/max.rs | 74 +++++---- tests/unit/out/unsafe/min_max_ptr2ptr.rs | 44 ++--- .../out/unsafe/operator_comparison_nonbool.rs | 70 ++++---- tests/unit/out/unsafe/push_emplace_back.rs | 40 +++-- .../unsafe/redundant_copy_in_conversion.rs | 20 +-- tests/unit/out/unsafe/size_t_ssize_t.rs | 84 +++++----- tests/unit/out/unsafe/sort.rs | 12 +- tests/unit/out/unsafe/sort_no_copy.rs | 150 +++++++----------- tests/unit/out/unsafe/stdcopy.rs | 40 +++-- tests/unit/out/unsafe/stdcopy_ostream.rs | 10 +- tests/unit/out/unsafe/stdmin_fpoint.rs | 2 +- .../unsafe/unboxed_conditional_iterator.rs | 30 +--- tests/unit/out/unsafe/unboxed_locals.rs | 2 +- tests/unit/out/unsafe/vector.rs | 56 ++++--- .../unit/out/unsafe/vector_iter_range_ctor.rs | 110 +++++-------- .../unit/out/unsafe/vector_with_allocator.rs | 50 +++--- tests/unit/out/unsafe/void_return.rs | 24 +-- 60 files changed, 1160 insertions(+), 1287 deletions(-) diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 3f95d1966a..07b918f02c 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -680,34 +680,40 @@ pub fn test_2() { }) )); assert!( - (if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - third.as_pointer().clone() - ), - LvalueRef::>::bind( - half.as_pointer().clone() + (if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + third.as_pointer().clone() + ), + LvalueRef::>::bind( + half.as_pointer().clone() + ), ) - )) { + ) { half.as_pointer() } else { third.as_pointer() } - .with(|__s| __s.denominator) == 2) + .with(|__s| __s.denominator) + == 2) ); assert!( - (if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - half.as_pointer().clone() - ), - LvalueRef::>::bind( - third.as_pointer().clone() + (if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + half.as_pointer().clone() + ), + LvalueRef::>::bind( + third.as_pointer().clone() + ), ) - )) { + ) { half.as_pointer() } else { third.as_pointer() } - .with(|__s| __s.denominator) == 3) + .with(|__s| __s.denominator) + == 3) ); } #[derive( diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 8352e91cb9..88224a90d1 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -565,7 +565,7 @@ pub unsafe fn test_2() { let __a: *const _ = &mut third; let __b: *const _ = &mut half; if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), ), @@ -583,7 +583,7 @@ pub unsafe fn test_2() { let __a: *const _ = &mut third; let __b: *const _ = &mut half; if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), ), diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index ae2302b7c9..d585346d25 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -243,7 +243,7 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().end())); while ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), @@ -251,7 +251,7 @@ pub fn test_3() { __last.as_pointer(), ), )) && !ConvertibleTo::::convert_value( - ::equal( + >::equal( LvalueRef::>::bind( __it.borrow().iter_deref(), ), @@ -286,7 +286,7 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().end())); while ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), @@ -294,7 +294,7 @@ pub fn test_3() { __last.as_pointer(), ), )) && !ConvertibleTo::::convert_value( - ::equal( + >::equal( LvalueRef::>::bind( __it.borrow().iter_deref(), ), diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index a46e6a30ff..87c8fbb8e2 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -227,17 +227,19 @@ pub unsafe fn test_3() { let mut __it = (__tmp_0).clone(); while ConvertibleToUnsafe::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe::>>::bind( - &raw const __it, + &__it, ), LvalueRefUnsafe::>>::bind( - &raw const __tmp_1, + &__tmp_1, ), - )) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 2), - )) { + )) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&2), + ), + ) { __it.iter_inc(); } __it @@ -245,10 +247,10 @@ pub unsafe fn test_3() { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( LvalueRefUnsafe::>>::bind( - &raw const found + &found ), LvalueRefUnsafe::>>::bind( - &raw const lengths.end() + &lengths.end() ), ) )); @@ -256,34 +258,16 @@ pub unsafe fn test_3() { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const { + &{ let mut __tmp_2 = { lengths.begin() }; let mut __tmp_3 = { lengths.end() }; let mut __it = (__tmp_2).clone(); - while ConvertibleToUnsafe::::convert_value(>::not_equal( - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __it), - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __tmp_3), - )) && !ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind( - __it.iter_deref(), - ), - LvalueRefUnsafe::>::bind(&raw const 7), - ), - ) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), ), ) { __it.iter_inc(); } __it } ), LvalueRefUnsafe::>>::bind( - &raw const lengths.end() + &lengths.end() ), ) )); diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 06fc312c01..f9110dac11 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -124,7 +124,7 @@ pub fn test_0() { Rc::new(RefCell::new(ratios.decay().offset((2) as isize))); while ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), @@ -198,7 +198,7 @@ pub fn test_1() { Rc::new(RefCell::new(levels.decay().offset((2) as isize))); while ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index e6f2668b5a..417ee6db18 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -138,25 +138,7 @@ pub unsafe fn test_0() { __tmp_0.iter_distance(&UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ratios.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut p38_insert_range_by_conversion_function_Ratio>::not_equal( - LvalueRefUnsafe::>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>::bind( - &raw const __tmp_1, - ), - ), - ) { - __tmp.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __tmp.as_mut_ptr().add(__tmp.len() - 1), - (LvalueRefUnsafe::< - Const, - >::bind(__it.iter_deref()),), - ); - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_by_conversion_function_Ratio as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_1 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } longs.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr().add(__off)) }; @@ -201,7 +183,7 @@ pub unsafe fn test_1() { __tmp_2.iter_distance(&UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = levels.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_best_conversion_function_Level >::not_equal(LvalueRefUnsafe::>::bind(&raw const __it), LvalueRefUnsafe::>::bind(&raw const __tmp_3 )), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_best_conversion_function_Level as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_3 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } ints.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr().add(__off)) }; diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 1b78e55e5a..77405151a6 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -63,14 +63,16 @@ pub fn test_1() { minor: 0, })); assert!( - (if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - old_version.as_pointer().clone() - ), - LvalueRef::>::bind( - new_version.as_pointer().clone() + (if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + old_version.as_pointer().clone() + ), + LvalueRef::>::bind( + new_version.as_pointer().clone() + ), ) - )) { + ) { new_version.as_pointer() } else { old_version.as_pointer() @@ -79,14 +81,16 @@ pub fn test_1() { == 2) ); assert!( - (if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - new_version.as_pointer().clone() - ), - LvalueRef::>::bind( - old_version.as_pointer().clone() + (if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + new_version.as_pointer().clone() + ), + LvalueRef::>::bind( + old_version.as_pointer().clone() + ), ) - )) { + ) { new_version.as_pointer() } else { old_version.as_pointer() @@ -128,7 +132,7 @@ pub fn test_1() { let mut __best = __it.borrow().clone(); if ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), @@ -139,7 +143,7 @@ pub fn test_1() { __it.borrow_mut().iter_inc(); while ConvertibleTo::::convert_value(>::not_equal( + > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind( __it.as_pointer(), ), @@ -148,7 +152,7 @@ pub fn test_1() { ), )) { if ConvertibleTo::::convert_value( - ::less( + ::less( LvalueRef::>::bind( __best.iter_deref(), ), @@ -397,14 +401,16 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 5, })); - if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - (__tmp_5.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_6.as_pointer()).clone(), + if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + (__tmp_5.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_6.as_pointer()).clone(), + ), ), - )) { + ) { (__tmp_6.as_pointer()) } else { (__tmp_5.as_pointer()) @@ -422,14 +428,16 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 30, })); - if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - (__tmp_7.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_8.as_pointer()).clone(), + if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + (__tmp_7.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_8.as_pointer()).clone(), + ), ), - )) { + ) { (__tmp_7.as_pointer()) } else { (__tmp_8.as_pointer()) @@ -447,14 +455,16 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 4, })); - if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind( - (__tmp_9.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_10.as_pointer()).clone(), + if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind( + (__tmp_9.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_10.as_pointer()).clone(), + ), ), - )) { + ) { (__tmp_10.as_pointer()) } else { (__tmp_9.as_pointer()) @@ -595,7 +605,7 @@ pub fn test_4() { ); assert!( ({ - ( (*(*if ConvertibleTo::::convert_value(<(Value, Value) >::less(LvalueRef::, Value) >>::bind(low .as_pointer() .clone()), LvalueRef::, Value) >>::bind(high .as_pointer() .clone()))) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) + ( (*(*if ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( LvalueRef::, Value) >>::bind(low .as_pointer() .clone()), LvalueRef::, Value) >>::bind(high .as_pointer() .clone()), )) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) }) ); } diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index 95c5e4bd0d..ae2525da3c 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -56,10 +56,12 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -72,10 +74,12 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -97,13 +101,15 @@ pub unsafe fn test_1() { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const table29_member_operator_Version; let __b = __tmp_0.iter_at(__y) as *const table29_member_operator_Version; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less } else if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), ), @@ -124,54 +130,7 @@ pub unsafe fn test_1() { assert!(((versions[(0_usize)].major) == (1)) && ((versions[(0_usize)].minor) == (9))); assert!(((versions[(1_usize)].major) == (2)) && ((versions[(1_usize)].minor) == (0))); assert!(((versions[(2_usize)].major) == (2)) && ((versions[(2_usize)].minor) == (1))); - assert!( - (((*{ - let mut __tmp_1 = { versions.begin() }; - let mut __tmp_2 = { versions.end() }; - let mut __best = __tmp_1.clone(); - if ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __tmp_1), - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __tmp_2), - ), - ) { - let mut __it = (__tmp_1).clone(); - __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value(>::not_equal( - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __it), - LvalueRefUnsafe::< - Const>, - >::bind(&raw const __tmp_2), - )) { - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind( - __best.iter_deref(), - ), - LvalueRefUnsafe::>::bind( - __it.iter_deref(), - ), - ), - ) { - __best = __it.clone(); - } - __it.iter_inc(); - } - } - __best - } - .iter_deref()) - .minor) - == (1)) - ); + assert!(( ( ( * { let mut __tmp_1 = { versions .begin() };let mut __tmp_2 = { versions .end() }; let mut __best = __tmp_1 .clone(); if ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_1 ), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ), ) { let mut __it = (__tmp_1 ).clone(); __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ), ) { if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), )) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . minor ) == ( 1 ) ) ); let mut downloads: UnsafeMap< table29_member_operator_Version, (table29_member_operator_Version, i32), @@ -363,7 +322,7 @@ pub unsafe fn test_3() { let __a: *const _ = (&mut __tmp_3); let __b: *const _ = (&mut __tmp_4); if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), ), @@ -386,7 +345,7 @@ pub unsafe fn test_3() { let __a: *const _ = (&mut __tmp_5); let __b: *const _ = (&mut __tmp_6); if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), ), @@ -409,7 +368,7 @@ pub unsafe fn test_3() { let __a: *const _ = (&mut __tmp_7); let __b: *const _ = (&mut __tmp_8); if ConvertibleToUnsafe::::convert_value( - ::less( + ::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), ), @@ -469,52 +428,38 @@ pub unsafe fn test_4() { ((pairs_spec_p3_members_order_pairs_Rank { value: 2 }), 5); assert!(ConvertibleToUnsafe::::convert_value( <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind( - &raw const low - ), - LvalueRefUnsafe::>::bind( - &raw const high - ), + LvalueRefUnsafe::>::bind(&low), + LvalueRefUnsafe::>::bind(&high), ) )); assert!(ConvertibleToUnsafe::::convert_value( <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&high), LvalueRefUnsafe::>::bind( - &raw const high - ), - LvalueRefUnsafe::>::bind( - &raw const high_later + &high_later ), ) )); assert!(ConvertibleToUnsafe::::convert_value( <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(&low), LvalueRefUnsafe::>::bind( - &raw const low - ), - LvalueRefUnsafe::>::bind( - &raw const high_later + &high_later ), ) )); assert!(!ConvertibleToUnsafe::::convert_value( <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind( - &raw const high - ), - LvalueRefUnsafe::>::bind( - &raw const low - ), + LvalueRefUnsafe::>::bind(&high), + LvalueRefUnsafe::>::bind(&low), ) )); assert!(!ConvertibleToUnsafe::::convert_value( <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( LvalueRefUnsafe::>::bind( - &raw const high_later - ), - LvalueRefUnsafe::>::bind( - &raw const high + &high_later ), + LvalueRefUnsafe::>::bind(&high), ) )); assert!( @@ -522,12 +467,8 @@ pub unsafe fn test_4() { pairs_spec_p3_members_order_pairs_Rank, i32 ) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind( - &raw const high - ), - LvalueRefUnsafe::>::bind( - &raw const low - ), + LvalueRefUnsafe::>::bind(&high), + LvalueRefUnsafe::>::bind(&low), ))) ); assert!( @@ -537,7 +478,7 @@ pub unsafe fn test_4() { if ConvertibleToUnsafe::::convert_value(<( pairs_spec_p3_members_order_pairs_Rank, i32, - )>::less( + ) as LessThanComparableUnsafe>::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { diff --git a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs index 4d75a753ae..3350d167b6 100644 --- a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs @@ -156,23 +156,29 @@ pub fn test_4() { Rc::new(RefCell::new(0)), ))); assert!( - !(ConvertibleTo::::convert_value(::equal( + !(ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - LvalueRef::>::bind((*b.borrow()).0.as_pointer()) - )) && ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - LvalueRef::>::bind((*b.borrow()).1.as_pointer()) - ))) + LvalueRef::>::bind((*b.borrow()).0.as_pointer()), + )) && ConvertibleTo::::convert_value( + ::equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*b.borrow()).1.as_pointer()), + ) + )) ); assert!( ({ - !(!(ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - )))) + !(!(ConvertibleTo::::convert_value( + ::equal( + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + ), + ) && ConvertibleTo::::convert_value( + ::equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + ), + ))) }) ); assert!(ConvertibleTo::::convert_value(<( @@ -324,10 +330,12 @@ pub fn test_7() { ))); assert!( ({ - ConvertibleTo::::convert_value(>::equal( - LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), - LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), + ), + ) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), )) @@ -335,12 +343,14 @@ pub fn test_7() { ); (*y.borrow_mut()) = 5; assert!( - !(ConvertibleTo::::convert_value(>::equal( - LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), - LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()) - )) && ConvertibleTo::::convert_value(::equal( + !(ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), + ) + ) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), - LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()) + LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), ))) ); } diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index 2260933e01..fd2e3dbfa4 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -172,94 +172,102 @@ pub unsafe fn test_4() { let mut b: (i32, i32) = (1, 3); let mut c: (i32, i32) = (2, 0); assert!( - !(ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a.0), - LvalueRefUnsafe::>::bind(&raw const b.0) - )) && ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a.1), - LvalueRefUnsafe::>::bind(&raw const b.1) - ),)) + !(ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&a.0), + LvalueRefUnsafe::>::bind(&b.0), + ) + ) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&a.1), + LvalueRefUnsafe::>::bind(&b.1), + ), + )) ); assert!( - !(!(ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a.0), - LvalueRefUnsafe::>::bind(&raw const a.0) - )) && ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const a.1), - LvalueRefUnsafe::>::bind(&raw const a.1) - ),))) + !(!(ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&a.0), + LvalueRefUnsafe::>::bind(&a.0), + ) + ) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&a.1), + LvalueRefUnsafe::>::bind(&a.1), + ), + ))) ); assert!(ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a), - LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&b), ) )); assert!( !(ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const b), - LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&a), ) )) ); assert!(ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const b), - LvalueRefUnsafe::>::bind(&raw const c), + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), ) )); assert!(!ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a), - LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&a), ) )); assert!( !(!ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const b), - LvalueRefUnsafe::>::bind(&raw const c), + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), ) )) ); assert!(ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const b), - LvalueRefUnsafe::>::bind(&raw const c), + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), ) )); assert!( !(ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a), - LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&a), ) )) ); assert!(!ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const c), - LvalueRefUnsafe::>::bind(&raw const a), + LvalueRefUnsafe::>::bind(&c), + LvalueRefUnsafe::>::bind(&a), ) )); assert!( !(!ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a), - LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&b), ) )) ); let mut ordered: bool = (ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const a), - LvalueRefUnsafe::>::bind(&raw const b), + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&b), ), )) && (ConvertibleToUnsafe::::convert_value( <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&raw const b), - LvalueRefUnsafe::>::bind(&raw const c), + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), ), )); assert!(ordered); @@ -308,23 +316,31 @@ pub unsafe fn test_7() { let mut to_x: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut x), 0); let mut to_y: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut y), 0); assert!( - ConvertibleToUnsafe::::convert_value(<*mut i32>::equal( - LvalueRefUnsafe::>>::bind(&raw const to_x.0), - LvalueRefUnsafe::>>::bind(&raw const to_y.0) - )) && ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const to_x.1), - LvalueRefUnsafe::>::bind(&raw const to_y.1) - ),) + ConvertibleToUnsafe::::convert_value( + as WeaklyEqualityComparableWithUnsafe>::equal( + LvalueRefUnsafe::>>::bind(&to_x.0), + LvalueRefUnsafe::>>::bind(&to_y.0), + ) + ) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&to_x.1), + LvalueRefUnsafe::>::bind(&to_y.1), + ), + ) ); y = 5; assert!( - !(ConvertibleToUnsafe::::convert_value(<*mut i32>::equal( - LvalueRefUnsafe::>>::bind(&raw const to_x.0), - LvalueRefUnsafe::>>::bind(&raw const to_y.0) - )) && ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&raw const to_x.1), - LvalueRefUnsafe::>::bind(&raw const to_y.1) - ),)) + !(ConvertibleToUnsafe::::convert_value( + as WeaklyEqualityComparableWithUnsafe>::equal( + LvalueRefUnsafe::>>::bind(&to_x.0), + LvalueRefUnsafe::>>::bind(&to_y.0), + ) + ) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&to_x.1), + LvalueRefUnsafe::>::bind(&to_y.1), + ), + )) ); } pub unsafe fn test_8() { diff --git a/tests/ub/out/refcount/max.rs b/tests/ub/out/refcount/max.rs index 706563f24c..1f16e3f9ca 100644 --- a/tests/ub/out/refcount/max.rs +++ b/tests/ub/out/refcount/max.rs @@ -14,7 +14,7 @@ fn main_0() -> i32 { let a: Ptr = ({ let __tmp_0: Value = Rc::new(RefCell::new(2)); let __tmp_1: Value = Rc::new(RefCell::new(1)); - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), )) { @@ -26,7 +26,7 @@ fn main_0() -> i32 { let b: Ptr = ({ let __tmp_2: Value = Rc::new(RefCell::new(1)); let __tmp_3: Value = Rc::new(RefCell::new(2)); - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_2.as_pointer().clone()), LvalueRef::>::bind(__tmp_3.as_pointer().clone()), )) { diff --git a/tests/ub/out/unsafe/max.rs b/tests/ub/out/unsafe/max.rs index cf6a7a0189..f6abed652f 100644 --- a/tests/ub/out/unsafe/max.rs +++ b/tests/ub/out/unsafe/max.rs @@ -19,7 +19,7 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -35,7 +35,7 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index 82a59a2dd4..a59fcd59ac 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -473,10 +473,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(vec_.decay().begin())); let __last: Value> = Rc::new(RefCell::new(vec_.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index 6efbc29b4d..3a644061f9 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -28,13 +28,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_2.as_pointer().clone()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/emplace_receiver_alias.rs b/tests/unit/out/refcount/emplace_receiver_alias.rs index 51d28dd1c2..65d2f0b55b 100644 --- a/tests/unit/out/refcount/emplace_receiver_alias.rs +++ b/tests/unit/out/refcount/emplace_receiver_alias.rs @@ -36,10 +36,12 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( (alias).decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/emplace_receiver_order.rs b/tests/unit/out/refcount/emplace_receiver_order.rs index 69e28f4a85..ff6f034eb6 100644 --- a/tests/unit/out/refcount/emplace_receiver_order.rs +++ b/tests/unit/out/refcount/emplace_receiver_order.rs @@ -43,10 +43,12 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -72,10 +74,12 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 29a98c29e0..dbd0aeaf2a 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -58,13 +58,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(({ (*v_begin.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new(({ (*v_end.borrow()).clone() }))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_3.as_pointer().clone()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_3.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -115,47 +119,7 @@ fn main_0() -> i32 { m_end.as_pointer(), ), )); - assert!( - ((v_result_true) && (m_result_true)) - && (match ( - Rc::new(RefCell::new( - ({ - let __tmp_9: Value = Rc::new(RefCell::new(2)); - { - let __it: Value> = - Rc::new(RefCell::new(v.decay().begin())); - let __last: Value> = - Rc::new(RefCell::new(v.decay().begin())); - while ConvertibleTo::::convert_value( - >::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_9.as_pointer().clone()), - )) { - __it.borrow_mut().iter_inc(); - } - __it.borrow().clone() - } - }) - )) - .as_pointer(), - Rc::new(RefCell::new(v.decay().begin())).as_pointer(), - ) { - (__tmp_8, __tmp_10) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( - LvalueRef::>>::bind((__tmp_8).clone()), - LvalueRef::>>::bind((__tmp_10).clone()), - )) - } - }) - ); + assert!(( ( v_result_true ) && ( m_result_true ) ) && ( match (Rc::new(RefCell::new(({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(v .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(v .decay() .begin() )); while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), )) && !ConvertibleTo::::convert_value(>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(v .decay() .begin() )).as_pointer(),) { (__tmp_8, __tmp_10,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef:: >>::bind((__tmp_8 ).clone()), LvalueRef:: >>::bind((__tmp_10 ).clone()), )) } } ) ); let w: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5]))); assert!(match ( Rc::new(RefCell::new( @@ -167,16 +131,18 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(w.decay().end())); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind( __last.as_pointer(), ), ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_12.as_pointer().clone()), - )) { + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_12.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -203,16 +169,18 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(w.decay().end())); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind( __last.as_pointer(), ), ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_15.as_pointer().clone()), - )) { + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -239,16 +207,18 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind( __last.as_pointer(), ), ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_18.as_pointer().clone()), - )) { + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_18.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -280,14 +250,16 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(p.decay().end())); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), ), - ) && !ConvertibleTo::::convert_value(

::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), - )) { + ) && !ConvertibleTo::::convert_value( +

>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index 2b19008931..18b14ca25d 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -18,7 +18,7 @@ thread_local!( ({ __tmp_0 = Rc::new(RefCell::new(0)); __tmp_1 = Rc::new(RefCell::new(0)); - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), )) { @@ -46,7 +46,7 @@ thread_local!( let __rhs = { __tmp_2 = Rc::new(RefCell::new(6)); __tmp_3 = Rc::new(RefCell::new(5)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_2.as_pointer().clone()), LvalueRef::>::bind(__tmp_3.as_pointer().clone()), )) { @@ -71,7 +71,7 @@ thread_local!( let __rhs = { __tmp_4 = Rc::new(RefCell::new(1)); __tmp_5 = Rc::new(RefCell::new(2)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_4.as_pointer().clone()), LvalueRef::>::bind(__tmp_5.as_pointer().clone()), )) { @@ -140,7 +140,7 @@ thread_local!( __tmp_7 = Rc::new(RefCell::new(Box::new([{ __tmp_8 = Rc::new(RefCell::new(4)); __tmp_9 = Rc::new(RefCell::new(3)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_8.as_pointer().clone()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), )) { @@ -156,7 +156,7 @@ thread_local!( value: { __tmp_11 = Rc::new(RefCell::new(5)); __tmp_12 = Rc::new(RefCell::new(6)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_11.as_pointer().clone()), LvalueRef::>::bind(__tmp_12.as_pointer().clone()), )) { @@ -183,7 +183,7 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_13 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_13.as_pointer().clone()), LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), )) { @@ -205,7 +205,7 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_14 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), LvalueRef::>::bind(__tmp_14.as_pointer().clone()), )) { @@ -245,7 +245,7 @@ thread_local!( __tmp_15 = Rc::new(RefCell::new(Box::new([{ __tmp_16 = Rc::new(RefCell::new(7)); __tmp_17 = Rc::new(RefCell::new(8)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_16.as_pointer().clone()), LvalueRef::>::bind(__tmp_17.as_pointer().clone()), )) { @@ -261,7 +261,7 @@ thread_local!( value: { __tmp_19 = Rc::new(RefCell::new(10)); __tmp_20 = Rc::new(RefCell::new(9)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_19.as_pointer().clone()), LvalueRef::>::bind(__tmp_20.as_pointer().clone()), )) { diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 64b1b8e7b2..f8368dba61 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -78,7 +78,7 @@ fn main_0() -> i32 { let x4: Value = Rc::new(RefCell::new(20)); let mut p1: Ptr = (x1.as_pointer()); let mut p2: Ptr = (x2.as_pointer()); - let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(x1.as_pointer().clone()), LvalueRef::>::bind(x2.as_pointer().clone()), )) { @@ -87,7 +87,7 @@ fn main_0() -> i32 { x1.as_pointer() } .read()); - let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(x4.as_pointer().clone()), LvalueRef::>::bind(x3.as_pointer().clone()), )) { @@ -96,7 +96,7 @@ fn main_0() -> i32 { x3.as_pointer() } .read()); - let mut r3: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r3: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((p1).clone().clone()), LvalueRef::>::bind(x2.as_pointer().clone()), )) { @@ -105,7 +105,7 @@ fn main_0() -> i32 { (p1).clone() } .read()); - let mut r4: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r4: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(x3.as_pointer().clone()), LvalueRef::>::bind((p2).clone().clone()), )) { @@ -117,7 +117,7 @@ fn main_0() -> i32 { let mut r5: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(30)); let __tmp_1: Value = Rc::new(RefCell::new(40)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), )) { @@ -133,16 +133,20 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(values.decay())); let __last: Value> = Rc::new(RefCell::new(values.decay().offset((4) as isize))); let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { - __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value(>::not_equal( + if ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), - )) { - if ConvertibleTo::::convert_value(::less( + ), + ) { + __it.borrow_mut().iter_inc(); + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), )) { @@ -157,7 +161,7 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(0,) }), ({ pick_3(1,) }),) { (__tmp_2, __tmp_3) => { - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((__tmp_2).clone().clone()), LvalueRef::>::bind((__tmp_3).clone().clone()), )) { @@ -174,7 +178,7 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(1,) }), ({ pick_3(0,) }),) { (__tmp_4, __tmp_5) => { - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((__tmp_5).clone().clone()), LvalueRef::>::bind((__tmp_4).clone().clone()), )) { @@ -204,7 +208,7 @@ fn main_0() -> i32 { }, ) { (__tmp_6, __tmp_8) => { - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((__tmp_6).clone().clone()), LvalueRef::>::bind((__tmp_8).clone().clone()), )) { @@ -230,7 +234,7 @@ fn main_0() -> i32 { }, ) { (__tmp_10, __tmp_12) => { - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((__tmp_12).clone().clone()), LvalueRef::>::bind((__tmp_10).clone().clone()), )) { @@ -254,10 +258,12 @@ fn main_0() -> i32 { let __tmp_15: Value = Rc::new(RefCell::new((largest as u64))); (match (Rc::new(RefCell::new((({ size_of_2(i) }) as u64))).as_pointer(),) { (__tmp_14,) => { - if ConvertibleTo::::convert_value(::less( - LvalueRef::>::bind(__tmp_15.as_pointer().clone()), - LvalueRef::>::bind((__tmp_14).clone().clone()), - )) { + if ConvertibleTo::::convert_value( + ::less( + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), + LvalueRef::>::bind((__tmp_14).clone().clone()), + ), + ) { (__tmp_14).clone() } else { __tmp_15.as_pointer() diff --git a/tests/unit/out/refcount/min_max_ptr2ptr.rs b/tests/unit/out/refcount/min_max_ptr2ptr.rs index 6017ada47d..26d3f22ede 100644 --- a/tests/unit/out/refcount/min_max_ptr2ptr.rs +++ b/tests/unit/out/refcount/min_max_ptr2ptr.rs @@ -17,7 +17,7 @@ fn main_0() -> i32 { let pb: Value> = Rc::new(RefCell::new((b.as_pointer()))); let mut ppa: Ptr> = (pa.as_pointer()); let mut ppb: Ptr> = (pb.as_pointer()); - let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((ppa.read()).clone()), LvalueRef::>::bind((ppb.read()).clone()), )) { @@ -26,7 +26,7 @@ fn main_0() -> i32 { (ppa.read()) } .read()); - let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((ppb.read()).clone()), LvalueRef::>::bind((ppa.read()).clone()), )) { @@ -42,7 +42,7 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value(>::less( + (if ConvertibleTo::::convert_value( as LessThanComparable>::less( LvalueRef::>>::bind(high.as_pointer().clone()), LvalueRef::>>::bind(low.as_pointer().clone()), )) { @@ -57,7 +57,7 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value(>::less( + (if ConvertibleTo::::convert_value( as LessThanComparable>::less( LvalueRef::>>::bind(low.as_pointer().clone()), LvalueRef::>>::bind(high.as_pointer().clone()), )) { @@ -72,7 +72,7 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value(>::less( + (if ConvertibleTo::::convert_value( as LessThanComparable>::less( LvalueRef::>>::bind(low.as_pointer().clone()), LvalueRef::>>::bind(high.as_pointer().clone()), )) { @@ -87,7 +87,7 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value(>::less( + (if ConvertibleTo::::convert_value( as LessThanComparable>::less( LvalueRef::>>::bind(high.as_pointer().clone()), LvalueRef::>>::bind(low.as_pointer().clone()), )) { diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 44fa96ac59..2d8b029f5a 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -626,13 +626,17 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(ris.decay())); let __last: Value> = Rc::new(RefCell::new(ris.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(ri2.as_pointer().clone()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(ri2.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 1d8ae84c68..997c3be8a8 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -96,10 +96,12 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -136,10 +138,12 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -411,10 +415,12 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -526,10 +532,12 @@ pub fn emplace_from_sibling_18(mut s: Ptr) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index 25b15ed785..4e33114a42 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -36,10 +36,12 @@ pub fn size_t_in_rules_3() { let __first: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); let mut __out = (dst.decay()).reinterpret_cast::(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { object!(__value, u64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -268,10 +270,12 @@ pub fn size_t_in_rules_3() { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -294,10 +298,12 @@ pub fn size_t_in_rules_3() { { let __it: Value> = Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { __it.borrow() .iter_deref() .write(Clone::clone(&({ ((*k.borrow()) as u64) }))); @@ -312,7 +318,7 @@ pub fn size_t_in_rules_3() { let __tmp_10: Value = Rc::new(RefCell::new(((*k.borrow()) as u64))); (match (v.decay().offset(1_usize),) { (__tmp_9,) => { - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind((__tmp_9).clone().clone()), LvalueRef::>::bind(__tmp_10.as_pointer().clone()), )) { @@ -407,16 +413,18 @@ pub fn size_t_in_rules_3() { let __last: Value> = Rc::new(RefCell::new(v3.decay().end())); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind( __last.as_pointer(), ), ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_19.as_pointer().clone()), - )) { + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_19.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -491,7 +499,7 @@ fn main_0() -> i32 { (::std::mem::size_of::() as u64).wrapping_add((*ul.borrow())), )); let __tmp_22: Value = Rc::new(RefCell::new((sz as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_21.as_pointer().clone()), LvalueRef::>::bind(__tmp_22.as_pointer().clone()), )) { @@ -505,7 +513,7 @@ fn main_0() -> i32 { let __tmp_23: Value = Rc::new(RefCell::new( (::std::mem::size_of::() as u64).wrapping_add((sz as u64)), )); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_23.as_pointer().clone()), LvalueRef::>::bind(ul.as_pointer().clone()), )) { @@ -520,7 +528,7 @@ fn main_0() -> i32 { let mut bound: usize = (({ let __tmp_24: Value = Rc::new(RefCell::new((4_usize as u64))); let __tmp_25: Value = Rc::new(RefCell::new((sz as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_24.as_pointer().clone()), LvalueRef::>::bind(__tmp_25.as_pointer().clone()), )) { @@ -579,7 +587,7 @@ fn main_0() -> i32 { let mut smin: isize = (({ let __tmp_26: Value = Rc::new(RefCell::new((sm as i64))); let __tmp_27: Value = Rc::new(RefCell::new((sd as i64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_26.as_pointer().clone()), LvalueRef::>::bind(__tmp_27.as_pointer().clone()), )) { @@ -592,7 +600,7 @@ fn main_0() -> i32 { let mut smax: isize = (({ let __tmp_28: Value = Rc::new(RefCell::new((sd as i64))); let __tmp_29: Value = Rc::new(RefCell::new((sm as i64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_28.as_pointer().clone()), LvalueRef::>::bind(__tmp_29.as_pointer().clone()), )) { @@ -622,7 +630,7 @@ fn main_0() -> i32 { (({ let __tmp_30: Value = Rc::new(RefCell::new((mx as u64))); let __tmp_31: Value = Rc::new(RefCell::new(1_u64)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_30.as_pointer().clone()), LvalueRef::>::bind(__tmp_31.as_pointer().clone()), )) { @@ -635,7 +643,7 @@ fn main_0() -> i32 { (({ let __tmp_32: Value = Rc::new(RefCell::new(((mx).wrapping_sub(3_usize) as u64))); let __tmp_33: Value = Rc::new(RefCell::new((mx as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_32.as_pointer().clone()), LvalueRef::>::bind(__tmp_33.as_pointer().clone()), )) { diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index d4cb448b64..40919f4c87 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -445,13 +445,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin())); let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(bags.decay().offset(1).clone()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(bags.decay().offset(1).clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -473,16 +477,20 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { - __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value(>::not_equal( + if ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), - )) { - if ConvertibleTo::::convert_value(::less( + ), + ) { + __it.borrow_mut().iter_inc(); + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), )) { @@ -504,9 +512,9 @@ fn main_0() -> i32 { } }); assert!( - ((if ConvertibleTo::::convert_value(::less( + ((if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(bags.decay().offset(2).clone()), - LvalueRef::>::bind(bags.decay().offset(0).clone()) + LvalueRef::>::bind(bags.decay().offset(0).clone()), )) { bags.decay().offset(2) } else { @@ -514,9 +522,9 @@ fn main_0() -> i32 { }) == (bags.decay().offset(0))) ); assert!( - ((if ConvertibleTo::::convert_value(::less( + ((if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(bags.decay().offset(0).clone()), - LvalueRef::>::bind(bags.decay().offset(2).clone()) + LvalueRef::>::bind(bags.decay().offset(2).clone()), )) { bags.decay().offset(2) } else { diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index d088ab67cb..50b7043c9c 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -43,10 +43,12 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = output.decay(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { object!(__value, i32, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -69,10 +71,12 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = widened.decay().begin(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { object!(__value, i64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -105,10 +109,12 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = constructed.decay().begin(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { object!(__value, Degrees, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -136,10 +142,12 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(wide.decay())); let __last: Value> = Rc::new(RefCell::new(wide.decay().offset((2) as isize))); let mut __out = floating.decay().begin(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { object!(__value, f64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this diff --git a/tests/unit/out/refcount/stdcopy_ostream.rs b/tests/unit/out/refcount/stdcopy_ostream.rs index 22de5b8a9e..4da0406cce 100644 --- a/tests/unit/out/refcount/stdcopy_ostream.rs +++ b/tests/unit/out/refcount/stdcopy_ostream.rs @@ -32,10 +32,12 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(__tmp_1)); let __out = &mut (*ofs.borrow_mut()); let mut __bytes: Vec = Vec::new(); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { __bytes.push(__it.borrow().iter_deref().read() as u8); __it.borrow_mut().iter_inc(); } diff --git a/tests/unit/out/refcount/stdmin_fpoint.rs b/tests/unit/out/refcount/stdmin_fpoint.rs index b741b78918..71c056fe36 100644 --- a/tests/unit/out/refcount/stdmin_fpoint.rs +++ b/tests/unit/out/refcount/stdmin_fpoint.rs @@ -13,7 +13,7 @@ pub fn main() { fn main_0() -> i32 { let a0: Value = Rc::new(RefCell::new(3.14_f64)); let a1: Value = Rc::new(RefCell::new(2.71_f64)); - if ConvertibleTo::::convert_value(::less( + if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(a1.as_pointer().clone()), LvalueRef::>::bind(a0.as_pointer().clone()), )) { diff --git a/tests/unit/out/refcount/unboxed_conditional_iterator.rs b/tests/unit/out/refcount/unboxed_conditional_iterator.rs index 45b3a51a9c..60eaf593c2 100644 --- a/tests/unit/out/refcount/unboxed_conditional_iterator.rs +++ b/tests/unit/out/refcount/unboxed_conditional_iterator.rs @@ -60,16 +60,18 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { let __last: Value> = Rc::new(RefCell::new(items.decay().end())); while ConvertibleTo::::convert_value( - >::not_equal( + as WeaklyEqualityComparableWith>::not_equal( LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind( __last.as_pointer(), ), ), - ) && !ConvertibleTo::::convert_value(::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(sigma.offset((i) as isize).clone()), - )) { + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(sigma.offset((i) as isize).clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 029b80f447..745a28a397 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -176,7 +176,7 @@ fn main_0() -> i32 { let high: Value = Rc::new(RefCell::new(3)); let mut low: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(2)); - (if ConvertibleTo::::convert_value(::less( + (if ConvertibleTo::::convert_value(::less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(high.as_pointer().clone()), )) { diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index c2476268b5..b1fb8c5a22 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -192,10 +192,12 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay().begin())); let __last: Value> = Rc::new(RefCell::new(src.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -709,10 +711,12 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -746,10 +750,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -776,10 +782,12 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -809,10 +817,12 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -844,10 +854,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 207b6068ac..d33bd0f131 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -146,10 +146,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -166,10 +168,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -186,10 +190,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -207,10 +213,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -234,10 +242,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -279,26 +289,7 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while ConvertibleTo::::convert_value( - , Value)>>::not_equal( - LvalueRef::, Value)>>>::bind( - __it.as_pointer(), - ), - LvalueRef::, Value)>>>::bind( - __last.as_pointer(), - ), - ), - ) { - let __i = __v.borrow().len(); - __v.borrow_mut().push(ZeroInitialization::zero_init()); - ConstructibleFrom::construct( - __v.as_pointer().decay().offset(__i), - (LvalueRef::, Value)>>::bind( - __it.borrow().iter_deref(), - ),), - ); - __it.borrow_mut().iter_inc(); - } + while ConvertibleTo::::convert_value(, Value) > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( __v.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ ((*v6.borrow()).len() == 3_usize) })); @@ -330,26 +321,7 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while ConvertibleTo::::convert_value( - , Value)>>::not_equal( - LvalueRef::, Value)>>>::bind( - __it.as_pointer(), - ), - LvalueRef::, Value)>>>::bind( - __last.as_pointer(), - ), - ), - ) { - let __i = temp_vec.borrow().len(); - temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); - ConstructibleFrom::construct( - temp_vec.as_pointer().decay().offset(__i), - (LvalueRef::, Value)>>::bind( - __it.borrow().iter_deref(), - ),), - ); - __it.borrow_mut().iter_inc(); - } + while ConvertibleTo::::convert_value(, Value) > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( temp_vec.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } v6.as_pointer() .with_mut(|v: &mut Vec<(Value, Value)>| { v.splice( @@ -372,10 +344,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -396,10 +370,12 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(readings.decay())); let __last: Value> = Rc::new(RefCell::new(readings.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index e236dae83d..89866c6e53 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -405,10 +405,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -425,10 +427,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -445,10 +449,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -466,10 +472,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -490,10 +498,12 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while ConvertibleTo::::convert_value(>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - )) { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index fd788950b8..f76c89f894 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -190,15 +190,19 @@ pub unsafe fn order_physical_2() { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const *mut i32; let __b = __tmp_0.iter_at(__y) as *const *mut i32; - if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index 2e7e0b6c25..fc72cdc5d2 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -36,10 +36,8 @@ pub unsafe fn sum_1(v: *const Vec) -> i32 { let mut it: UnsafeRandomAccessIterator = (*v).begin(); 'loop_: while ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind( - &raw const (*v).end(), - ), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&(*v).end()), ), ) { 'for_body: { diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index 0f202c981f..220e91c76c 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -421,13 +421,9 @@ unsafe fn main_0() -> i32 { let mut __v: Vec = Vec::new(); let mut __it = (__tmp_0).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_1, - ), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_1), ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index 7fa85d833d..e4f3892491 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -27,22 +27,24 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { v.end() }; let mut __it = (__tmp_2).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind(&raw const __it), - LvalueRefUnsafe::>>::bind(&raw const __tmp_3), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_3), ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 7), - )) { + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&7), + ), + ) { __it.iter_inc(); } __it }; assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind(&raw const v.end()), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&v.end()), ) )); assert!(((*it.iter_deref()) == (7))); @@ -61,15 +63,17 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_5.iter_at(__x) as *const i32; let __b = __tmp_5.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/emplace_receiver_alias.rs b/tests/unit/out/unsafe/emplace_receiver_alias.rs index 27c2a1e575..559098fe0a 100644 --- a/tests/unit/out/unsafe/emplace_receiver_alias.rs +++ b/tests/unit/out/unsafe/emplace_receiver_alias.rs @@ -32,10 +32,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { (&mut (*alias))[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_1), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/emplace_receiver_order.rs b/tests/unit/out/unsafe/emplace_receiver_order.rs index 6f9e918bf5..cdce826975 100644 --- a/tests/unit/out/unsafe/emplace_receiver_order.rs +++ b/tests/unit/out/unsafe/emplace_receiver_order.rs @@ -40,10 +40,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_1), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -71,11 +73,9 @@ unsafe fn main_0() -> i32 { let mut __v: Vec = Vec::new(); let mut __it = __tmp_3; while ConvertibleToUnsafe::::convert_value( - <*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind( - &raw const __tmp_4, - ), + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_4), ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 856e83c0cb..3f0ce39708 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -53,22 +53,24 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { (v_end).clone() }; let mut __it = (v_begin).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind(&raw const __it), - LvalueRefUnsafe::>>::bind(&raw const __tmp_3), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_3), ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 2), - )) { + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&2), + ), + ) { __it.iter_inc(); } __it }; let mut v_result_true: bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind(&raw const v.end()), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&v.end()), )); let mut m: UnsafeMap = UnsafeMap::new(); { @@ -96,153 +98,77 @@ unsafe fn main_0() -> i32 { let mut m_end: UnsafeBidirectionalIterator<(i32, f64)> = m.end(); let mut m_result_true: bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const m_begin, - ), - LvalueRefUnsafe::>>::bind( - &raw const m_end, - ), + LvalueRefUnsafe::>>::bind(&m_begin), + LvalueRefUnsafe::>>::bind(&m_end), )); assert!( ((v_result_true) && (m_result_true)) && (ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_7 = { v.begin() }; let mut __tmp_8 = { v.begin() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_8, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 2), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ), ) { __it.iter_inc(); } __it }), - LvalueRefUnsafe::>>::bind( - &raw const v.begin() - ), + LvalueRefUnsafe::>>::bind(&v.begin()), ) )) ); let mut w: Vec = Vec::from([1, 2, 3, 4, 5]); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_9 = { w.begin().iter_add(2_isize) }; let mut __tmp_10 = { w.end() }; let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_10, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 4), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( - &raw const w.begin().iter_add(3_isize) + &w.begin().iter_add(3_isize) ), ) )); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_11 = { w.begin().iter_add(2_isize) }; let mut __tmp_12 = { w.end() }; let mut __it = (__tmp_11).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_12, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 1), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), ), ) { __it.iter_inc(); } __it }), - LvalueRefUnsafe::>>::bind(&raw const w.end()), + LvalueRefUnsafe::>>::bind(&w.end()), ) )); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_13 = { w.begin().iter_add(2_isize) }; let mut __tmp_14 = { w.begin().iter_add(4_isize) }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_14, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const 5), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( - &raw const w.begin().iter_add(4_isize) + &w.begin().iter_add(4_isize) ), ) )); let mut p: Vec

= Vec::from([P { x: 0 }, P { x: 1 }, P { x: 2 }]); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_15 = { p.begin() }; let mut __tmp_16 = { p.end() }; let mut __it = (__tmp_15).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_16, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(

::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const (P { x: 1 })), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( +

>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), ), @@ -270,7 +278,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(p.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_22) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_20).clone()), LvalueRef::>>::bind((__tmp_22).clone()), )) diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index da0920398f..2e174ab1a3 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -37,6 +37,14 @@ pub struct V { #[offset(0)] pub x: i32, } +impl Cpp17EqualityComparable for V { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); } diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 7ab48ae425..197df3e0cf 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -230,7 +230,7 @@ fn main_0() -> i32 { }), ), )); - let mut x1: u32 = if ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + let mut x1: u32 = if ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind(it.as_pointer()), LvalueRef::, Value)>>>::bind(end.as_pointer()), )) { @@ -247,7 +247,7 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_20,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + (__tmp_20,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), @@ -269,7 +269,7 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_21,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + (__tmp_21,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( it.as_pointer(), ), @@ -294,7 +294,7 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_22,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + (__tmp_22,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), @@ -437,7 +437,7 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_31, __tmp_33) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( (__tmp_31).clone(), ), @@ -504,7 +504,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_40,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( next.as_pointer(), ), @@ -524,7 +524,7 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_42,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( next.as_pointer(), ), @@ -553,7 +553,7 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_43, __tmp_45) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( (__tmp_43).clone(), ), diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index 8a16161983..c6f957ef32 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -30,18 +30,26 @@ pub struct Key { #[offset(4)] pub identity: i32, } +impl Cpp17EqualityComparable for Key { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for Key { type Result = bool; fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); + return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); } } -pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { +pub fn operator_lt_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.order) } < { b.with(|__s| __s.order) }); } -pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { +pub fn operator_eq_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.identity) } == { b.with(|__s| __s.identity) }); } #[derive( @@ -94,7 +102,7 @@ fn main_0() -> i32 { identity: 7, })); ok = { - ((ok as i32) & ((operator_eq_2(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) + ((ok as i32) & ((operator_eq_1(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) != 0 }; let distinct: Value, Value)>> = Rc::new(RefCell::new(Map::new())); @@ -125,10 +133,40 @@ fn main_0() -> i32 { != 0 }; ok = { - ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.find(&distinct_a .as_pointer() )) )).as_pointer(),) { (__tmp_0,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(a_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_0 ).clone()), )) } } ) ) as i32 ) ) != 0 + ((ok as i32) + & ((match (Rc::new(RefCell::new(distinct.as_pointer().with( + |__m: &Map, Value)>| __m.find(&distinct_a.as_pointer()), + ))) + .as_pointer(),) + { + (__tmp_0,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + LvalueRef::, Value)>>>::bind( + a_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_0).clone(), + ), + )), + }) as i32)) + != 0 }; ok = { - ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.find(&distinct_b .as_pointer() )) )).as_pointer(),) { (__tmp_1,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(b_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_1 ).clone()), )) } } ) ) as i32 ) ) != 0 + ((ok as i32) + & ((match (Rc::new(RefCell::new(distinct.as_pointer().with( + |__m: &Map, Value)>| __m.find(&distinct_b.as_pointer()), + ))) + .as_pointer(),) + { + (__tmp_1,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + LvalueRef::, Value)>>>::bind( + b_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_1).clone(), + ), + )), + }) as i32)) + != 0 }; ok = { ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.end()) )).as_pointer(),) { (__tmp_2,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( LvalueRef::, Value) > >>::bind(b_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_2 ).clone()), )) } } ) ) as i32 ) ) != 0 @@ -149,7 +187,7 @@ fn main_0() -> i32 { != 0 }; ok = { - ((ok as i32) & ((operator_eq_2(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) + ((ok as i32) & ((operator_eq_1(distinct_a.as_pointer(), distinct_b.as_pointer())) as i32)) != 0 }; let mut distinct_count: usize = 0_usize; @@ -192,7 +230,7 @@ fn main_0() -> i32 { })); ok = { ((ok as i32) - & (!({ operator_eq_2(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) + & (!({ operator_eq_1(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) != 0 }; let equivalent: Value, Value)>> = @@ -257,16 +295,16 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_4,) => ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::equal( + (__tmp_4,) => { + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::< Const, Value)>>, >::bind(first_it.as_pointer()), LvalueRef::< Const, Value)>>, >::bind((__tmp_4).clone()), - ), - ), + )) + } }) as i32)) != 0 }; @@ -280,16 +318,16 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_5,) => ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::equal( + (__tmp_5,) => { + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::< Const, Value)>>, >::bind(first_it.as_pointer()), LvalueRef::< Const, Value)>>, >::bind((__tmp_5).clone()), - ), - ), + )) + } }) as i32)) != 0 }; @@ -332,7 +370,7 @@ fn main_0() -> i32 { } ok = { ((ok as i32) - & (!({ operator_eq_2(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) + & (!({ operator_eq_1(equivalent_a.as_pointer(), equivalent_b.as_pointer()) }) as i32)) != 0 }; let later_key: Value = Rc::new(RefCell::new(Key { @@ -359,16 +397,16 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_6,) => ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::equal( + (__tmp_6,) => { + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::< Const, Value)>>, >::bind(first_it.as_pointer()), LvalueRef::< Const, Value)>>, >::bind((__tmp_6).clone()), - ), - ), + )) + } }) as i32)) != 0 }; @@ -428,7 +466,22 @@ fn main_0() -> i32 { ok = { ((ok as i32) & (((*matching.borrow()).len() == 1_usize) as i32)) != 0 }; ok = { ((ok as i32) & (({ (matched).clone() } == { (matched_again).clone() }) as i32)) != 0 }; ok = { - ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(matching .as_pointer() .with(|__m: &Map, Value)>| __m.find(&matching_b .as_pointer() )) )).as_pointer(),) { (__tmp_7,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(matched_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_7 ).clone()), )) } } ) ) as i32 ) ) != 0 + ((ok as i32) + & ((match (Rc::new(RefCell::new(matching.as_pointer().with( + |__m: &Map, Value)>| __m.find(&matching_b.as_pointer()), + ))) + .as_pointer(),) + { + (__tmp_7,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + LvalueRef::, Value)>>>::bind( + matched_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_7).clone(), + ), + )), + }) as i32)) + != 0 }; ok = { ((ok as i32) @@ -455,7 +508,22 @@ fn main_0() -> i32 { }; ok = { ((ok as i32) & (((*matching.borrow()).len() == 2_usize) as i32)) != 0 }; ok = { - ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(matching .as_pointer() .with(|__m: &Map, Value)>| __m.find(&matching_a .as_pointer() )) )).as_pointer(),) { (__tmp_8,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(matched_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_8 ).clone()), )) } } ) ) as i32 ) ) != 0 + ((ok as i32) + & ((match (Rc::new(RefCell::new(matching.as_pointer().with( + |__m: &Map, Value)>| __m.find(&matching_a.as_pointer()), + ))) + .as_pointer(),) + { + (__tmp_8,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + LvalueRef::, Value)>>>::bind( + matched_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_8).clone(), + ), + )), + }) as i32)) + != 0 }; ok = { ((ok as i32) diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 79b1fd3c54..5ac115dcaa 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -307,7 +307,7 @@ fn main_0() -> i32 { as i32)) != 0 }; - let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef::, Value) > >>::bind(({ (*result.borrow()) .0 .as_pointer() })), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), )) } } ; + let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value) > >>::bind(({ (*result.borrow()) .0 .as_pointer() })), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), )) } } ; ok = { ((ok as i32) & (found as i32)) != 0 }; ok = { ((ok as i32) diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index cf8cb14339..8ddc525e41 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -25,13 +25,15 @@ pub struct S { #[offset(0)] pub v: i32, } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -119,7 +121,7 @@ pub struct V { #[offset(0)] pub v: i32, } -impl WeaklyEqualityComparableWith for V { +impl Cpp17EqualityComparable for V { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); @@ -130,6 +132,8 @@ impl WeaklyEqualityComparableWith for V { }) }); } +} +impl WeaklyEqualityComparableWith for V { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index b0f91e2428..ff6dddc8e0 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -48,13 +48,15 @@ impl S { return (this.with(|__s| __s.v) < o); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 258b5c48f9..9ef437fe2c 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -45,13 +45,23 @@ impl S { return ({ this.with(|__s| __s.v) } >= { (((o.read()) as i32) - (('0' as i8) as i32)) }); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs.read())) }); } +} +impl Cpp17EqualityComparable for i32 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs.read()), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -60,12 +70,6 @@ impl WeaklyEqualityComparableWith for S { } } impl WeaklyEqualityComparableWith for i32 { - type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs.read()), (__rhs).clone()) }); - } type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -73,13 +77,23 @@ impl WeaklyEqualityComparableWith for i32 { return ({ operator_ne_1((__lhs.read()), (__rhs).clone()) }); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); } +} +impl Cpp17EqualityComparable for f64 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -88,12 +102,6 @@ impl WeaklyEqualityComparableWith for S { } } impl WeaklyEqualityComparableWith for f64 { - type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); - } type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -101,13 +109,23 @@ impl WeaklyEqualityComparableWith for f64 { return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); } +} +impl Cpp17EqualityComparable for i64 { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -116,12 +134,6 @@ impl WeaklyEqualityComparableWith for S { } } impl WeaklyEqualityComparableWith for i64 { - type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); - } type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 2d8b029f5a..daf0504920 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -25,7 +25,7 @@ pub struct X { #[offset(0)] pub v: i32, } -impl WeaklyEqualityComparableWith for X { +impl Cpp17EqualityComparable for X { type EqualResult = i32; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); @@ -36,6 +36,8 @@ impl WeaklyEqualityComparableWith for X { }) }); } +} +impl WeaklyEqualityComparableWith for X { type NotEqualResult = i32; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); @@ -207,6 +209,14 @@ impl Mixed { }; } } +impl Cpp17EqualityComparable for Mixed { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for Mixed { type Result = i32; fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { @@ -244,7 +254,7 @@ impl MyBool { return this.with(|__s| __s.value); } } -impl WeaklyEqualityComparableWith for MyBool { +impl Cpp17EqualityComparable for MyBool { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -256,6 +266,8 @@ impl WeaklyEqualityComparableWith for MyBool { (({ MyBool::to_bool((__rhs).clone()) }) as i32) }); } +} +impl WeaklyEqualityComparableWith for MyBool { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -354,26 +366,41 @@ pub struct Boolish { #[offset(0)] pub v: i32, } +impl Cpp17EqualityComparable for Boolish { + type EqualResult = MyBool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + operator_eq_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }); + } +} impl LessThanComparable for Boolish { type Result = MyBool; fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ - operator_lt_6({ (*__lhs.upgrade().deref()) }, { + operator_lt_7({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) }); } } -pub fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v == b.v)); Rc::try_unwrap(__v).ok().unwrap().into_inner() }; } -pub fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { +pub fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let __v: Value = Rc::new(RefCell::new(ZeroInitialization::zero_init())); MyBool::constructor_1(__v.as_pointer(), (a.v < b.v)); @@ -407,7 +434,7 @@ impl RefBool { return this.with(|__s| __s.value); } } -impl WeaklyEqualityComparableWith for RefBool { +impl Cpp17EqualityComparable for RefBool { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -419,6 +446,8 @@ impl WeaklyEqualityComparableWith for RefBool { (({ RefBool::to_bool((__rhs).clone()) }) as i32) }); } +} +impl WeaklyEqualityComparableWith for RefBool { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -532,6 +561,17 @@ impl RefInt { return ref_true_8.with(|v| v.as_pointer()); } } +impl Cpp17EqualityComparable for RefInt { + type EqualResult = LvalueRef; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return LvalueRef::bind(({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -589,14 +629,14 @@ fn main_0() -> i32 { assert!( ({ MyBool::to_bool( - Rc::new(RefCell::new(({ operator_eq_7(b1, Boolish { v: 1 }) }))).as_pointer(), + Rc::new(RefCell::new(({ operator_eq_6(b1, Boolish { v: 1 }) }))).as_pointer(), ) }) ); assert!( - !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_6(b2, b1,) }))).as_pointer(),) }) + !({ MyBool::to_bool(Rc::new(RefCell::new(({ operator_lt_7(b2, b1,) }))).as_pointer(),) }) ); - let mut lt: MyBool = ({ operator_lt_6(b1, b2) }); + let mut lt: MyBool = ({ operator_lt_7(b1, b2) }); assert!(lt.value); let bs: Value> = Rc::new(RefCell::new(Box::new([ Boolish { v: 3 }, @@ -631,12 +671,12 @@ fn main_0() -> i32 { LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(ri2.as_pointer().clone()), - ), - ) { + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(ri2.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 6bf0323273..b0796a7a03 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -29,6 +29,14 @@ impl S { field!(this, data_).write(data); } } +impl Cpp17EqualityComparable for S { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for S { type Result = bool; fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 95ad1eedd1..a4cde16240 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -70,13 +70,15 @@ impl S { return (this.with(|__s| __s.v) != 0); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index b74cfdd244..fcc0e067e9 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -56,22 +56,62 @@ impl S { return ((this.with(|__s| __s.v) * o) + 1); } } -pub fn operator_div_0(a: Ptr, b: Ptr) -> i32 { +impl Cpp17EqualityComparable for S { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) }); + } +} +impl Cpp17EqualityComparable for i32 { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) }); + } +} +impl Cpp17EqualityComparable for S { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) }); + } +} +impl Cpp17EqualityComparable for i64 { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_1((__lhs.read()), (__rhs).clone()) }); + } +} +impl Cpp17EqualityComparable for S { + type EqualResult = i32; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) }); + } +} +pub fn operator_div_2(a: Ptr, b: Ptr) -> i32 { return ({ a.with(|__s| __s.v) } / { b.with(|__s| __s.v) }); } -pub fn operator_div_1(mut a: S, mut b: i32) -> i32 { +pub fn operator_div_3(mut a: S, mut b: i32) -> i32 { return ((a.v / b) + 1); } -pub fn operator_rem_2(mut a: S, mut b: S) -> i32 { +pub fn operator_rem_4(mut a: S, mut b: S) -> i32 { return (a.v % b.v); } -pub fn operator_rem_3(a: Ptr, mut b: i32) -> i32 { +pub fn operator_rem_5(a: Ptr, mut b: i32) -> i32 { return (({ a.with(|__s| __s.v) } % { b }) + 1); } -pub fn operator_eq_4(mut a: i32, mut b: S) -> i32 { +pub fn operator_eq_0(mut a: i32, mut b: S) -> i32 { return if (a == b.v) { 4 } else { 0 }; } -pub fn operator_eq_5(mut a: i64, b: Ptr) -> i32 { +pub fn operator_eq_1(mut a: i64, b: Ptr) -> i32 { return if ({ a } == { (b.with(|__s| __s.v) as i64) }) { 5 } else { @@ -93,12 +133,12 @@ fn main_0() -> i32 { assert!((({ S::operator_sub(s.as_pointer(), { (*t.borrow()) },) }) == 2)); assert!((({ S::operator_mul_6(s.as_pointer(), t.as_pointer(),) }) == 24)); assert!((({ S::operator_mul_7(s.as_pointer(), 2,) }) == 13)); - assert!((({ operator_div_0(s.as_pointer(), t.as_pointer(),) }) == 1)); - assert!((({ operator_div_1({ (*s.borrow()) }, 4,) }) == 2)); - assert!((({ operator_rem_2({ (*s.borrow()) }, { (*t.borrow()) },) }) == 2)); - assert!((({ operator_rem_3(s.as_pointer(), 4,) }) == 3)); - assert!((({ operator_eq_4(6, { (*s.borrow()) },) }) == 4)); - assert!((({ operator_eq_5(6_i64, s.as_pointer(),) }) == 5)); + assert!((({ operator_div_2(s.as_pointer(), t.as_pointer(),) }) == 1)); + assert!((({ operator_div_3({ (*s.borrow()) }, 4,) }) == 2)); + assert!((({ operator_rem_4({ (*s.borrow()) }, { (*t.borrow()) },) }) == 2)); + assert!((({ operator_rem_5(s.as_pointer(), 4,) }) == 3)); + assert!((({ operator_eq_0(6, { (*s.borrow()) },) }) == 4)); + assert!((({ operator_eq_1(6_i64, s.as_pointer(),) }) == 5)); return 0; } pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 514e28aaaf..11c787a918 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -39,13 +39,15 @@ impl S { return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); } } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index 3481437b28..a4ca61d62d 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -56,7 +56,7 @@ impl Meters { return this.with(|__s| __s.value); } } -impl WeaklyEqualityComparableWith for Meters { +impl Cpp17EqualityComparable for Meters { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -68,6 +68,8 @@ impl WeaklyEqualityComparableWith for Meters { ({ Meters::to_i32((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for Meters { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/unit/out/refcount/redundant_copy_in_conversion.rs b/tests/unit/out/refcount/redundant_copy_in_conversion.rs index ef8c32001b..ba61cee2c9 100644 --- a/tests/unit/out/refcount/redundant_copy_in_conversion.rs +++ b/tests/unit/out/refcount/redundant_copy_in_conversion.rs @@ -17,7 +17,7 @@ pub fn sink_0(it: BidirectionalIterator<(Value, Value)>) -> i32 { )>>::from(({ (*it.borrow()).clone() })))) .as_pointer(),) { - (__tmp_0,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + (__tmp_0,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( cit.as_pointer(), ), @@ -65,7 +65,7 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_3,) => ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + (__tmp_3,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), @@ -79,7 +79,7 @@ fn main_0() -> i32 { 1 }; r += ({ sink_0({ (*it0.borrow()).clone() }) }); - r += if ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + r += if ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind(end.as_pointer()), LvalueRef::, Value)>>>::bind(end.as_pointer()), )) { @@ -96,7 +96,7 @@ fn main_0() -> i32 { )); assert!(((({ (*const_middle.borrow()).iter_deref() }).read()) == 8_u32)); assert!(ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::equal( + Cpp17EqualityComparable::equal( LvalueRef::>>::bind(const_middle.as_pointer()), LvalueRef::>>::bind(middle.as_pointer()), ) diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index 4e33114a42..84043a5d38 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -420,7 +420,7 @@ pub fn size_t_in_rules_3() { ), ), ) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_19.as_pointer().clone()), ), diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 40919f4c87..8ac37d492b 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -130,18 +130,26 @@ impl Bag { field!(this, items).write(Vec::new()); } } +impl Cpp17EqualityComparable for Bag { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_4((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for Bag { type Result = bool; fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); + return ({ operator_lt_5((__lhs).clone(), (__rhs).clone()) }); } } -pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { +pub fn operator_lt_5(a: Ptr, b: Ptr) -> bool { return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); } -pub fn operator_eq_5(a: Ptr, b: Ptr) -> bool { +pub fn operator_eq_4(a: Ptr, b: Ptr) -> bool { return ({ (*a.upgrade().deref()).items.len() } == { (*b.upgrade().deref()).items.len() }); } pub fn main() { @@ -450,12 +458,12 @@ fn main_0() -> i32 { LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(bags.decay().offset(1).clone()), - ), - ) { + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(bags.decay().offset(1).clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -464,7 +472,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_21) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_20).clone()), LvalueRef::>>::bind((__tmp_21).clone()), )) @@ -505,7 +513,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(2_isize))).as_pointer(), ) { (__tmp_22, __tmp_23) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_22).clone()), LvalueRef::>>::bind((__tmp_23).clone()), )) @@ -569,7 +577,7 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_26, __tmp_27) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value)>>>::bind( (__tmp_26).clone(), ), diff --git a/tests/unit/out/refcount/unboxed_conditional_iterator.rs b/tests/unit/out/refcount/unboxed_conditional_iterator.rs index 60eaf593c2..4ec2948cee 100644 --- a/tests/unit/out/refcount/unboxed_conditional_iterator.rs +++ b/tests/unit/out/refcount/unboxed_conditional_iterator.rs @@ -67,7 +67,7 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { ), ), ) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(sigma.offset((i) as isize).clone()), ), diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index d33bd0f131..cf580172f9 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -56,7 +56,7 @@ impl Reading { return ((this.with(|__s| __s.raw_) as i64) * 10_i64); } } -impl WeaklyEqualityComparableWith for Reading { +impl Cpp17EqualityComparable for Reading { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -68,6 +68,8 @@ impl WeaklyEqualityComparableWith for Reading { ({ Reading::to_i64((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for Reading { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 9639c65a76..5ac48621af 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -103,6 +103,17 @@ impl Counter { return (((*this).v) == ((*o).v)); } } +impl Cpp17EqualityComparableUnsafe for Counter { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Counter); + let __rhs = (__rhs.as_ptr() as *const Counter); + return (unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index e4f3892491..06fd5a8abf 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -32,7 +32,7 @@ unsafe fn main_0() -> i32 { LvalueRefUnsafe::>>::bind(&__tmp_3), ), ) && !ConvertibleToUnsafe::::convert_value( - >::equal( + >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7), ), diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 3f0ce39708..755c9a0f33 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -27,6 +27,17 @@ impl P { return (((*this).x) == ((*o).x)); } } +impl Cpp17EqualityComparableUnsafe for P { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const P); + let __rhs = (__rhs.as_ptr() as *const P); + return (unsafe { P::operator_eq(&raw const (*__lhs), __rhs) }); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -58,7 +69,7 @@ unsafe fn main_0() -> i32 { LvalueRefUnsafe::>>::bind(&__tmp_3), ), ) && !ConvertibleToUnsafe::::convert_value( - >::equal( + >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2), ), @@ -103,27 +114,25 @@ unsafe fn main_0() -> i32 { )); assert!( ((v_result_true) && (m_result_true)) - && (ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_7 = { v.begin() }; - let mut __tmp_8 = { v.begin() }; - let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ), ) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind(&v.begin()), - ) - )) + && (ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_7 = { v.begin() }; + let mut __tmp_8 = { v.begin() }; + let mut __it = (__tmp_7).clone(); + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind(&v.begin()), + ))) ); let mut w: Vec = Vec::from([1, 2, 3, 4, 5]); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_9 = { w.begin().iter_add(2_isize) }; let mut __tmp_10 = { w.end() }; let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( @@ -132,24 +141,24 @@ unsafe fn main_0() -> i32 { ) )); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_11 = { w.begin().iter_add(2_isize) }; let mut __tmp_12 = { w.end() }; let mut __it = (__tmp_11).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&w.end()), ) )); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_13 = { w.begin().iter_add(2_isize) }; let mut __tmp_14 = { w.begin().iter_add(4_isize) }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( @@ -159,12 +168,12 @@ unsafe fn main_0() -> i32 { )); let mut p: Vec

= Vec::from([P { x: 0 }, P { x: 1 }, P { x: 2 }]); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_15 = { p.begin() }; let mut __tmp_16 = { p.end() }; let mut __it = (__tmp_15).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 11efd8725d..fc4ec140a9 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -34,6 +34,20 @@ pub unsafe fn scaled_3(v: *const V, mut k: f64) -> f64 { pub struct V { pub x: i32, } +impl Cpp17EqualityComparableUnsafe for V { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + return (unsafe { + let _a: *const V = __lhs; + operator_eq_1(_a, __rhs) + }); + } +} pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; } diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 6d9de3db75..c75104abee 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -226,7 +226,7 @@ unsafe fn main_0() -> i32 { let mut const_it: UnsafeBidirectionalIterator<(i16, u32)> = >::from(m.find(&10_i16)); let mut x1: u32 = - if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&it), LvalueRefUnsafe::>>::bind(&end), )) { @@ -236,7 +236,7 @@ unsafe fn main_0() -> i32 { }; assert!(((x1) == (4_u32))); let mut x2: u32 = - if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( &>::from((end).clone()), @@ -248,7 +248,7 @@ unsafe fn main_0() -> i32 { }; assert!(((x2) == (0_u32))); let mut x3: u32 = - if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&it), LvalueRefUnsafe::>>::bind(&m.end()), )) { @@ -258,7 +258,7 @@ unsafe fn main_0() -> i32 { }; assert!(((x3) == (4_u32))); let mut x4: u32 = - if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( &>::from(m.end()), @@ -320,7 +320,7 @@ unsafe fn main_0() -> i32 { (*r).erase(&(it4).clone()); assert!((((*r).len()) == (3_usize))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind( &m.find(&4_i16) ), @@ -357,7 +357,7 @@ unsafe fn main_0() -> i32 { >::from(m.find(&7_i16)); let mut next: UnsafeBidirectionalIterator<(i16, u32)> = m.erase(&(cit).clone()); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&next), LvalueRefUnsafe::>>::bind( &m.find(&8_i16) @@ -368,14 +368,14 @@ unsafe fn main_0() -> i32 { next = m.erase(&(next).clone()); }; assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&next), LvalueRefUnsafe::>>::bind(&m.end()), ) )); assert!((((*r).len()) == (3_usize))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind( &m.find(&8_i16) ), diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 86ef2ec38a..a1e3d15c38 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -25,6 +25,20 @@ pub struct Key { pub order: i32, pub identity: i32, } +impl Cpp17EqualityComparableUnsafe for Key { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + return (unsafe { + let _a: *const Key = __lhs; + operator_eq_1(_a, __rhs) + }); + } +} impl LessThanComparableUnsafe for Key { type Result = bool; unsafe fn less( @@ -35,14 +49,14 @@ impl LessThanComparableUnsafe for Key { let __rhs = (__rhs.as_ptr() as *const Key); return (unsafe { let _a: *const Key = __lhs; - operator_lt_1(_a, __rhs) + operator_lt_2(_a, __rhs) }); } } -pub unsafe fn operator_lt_1(a: *const Key, b: *const Key) -> bool { +pub unsafe fn operator_lt_2(a: *const Key, b: *const Key) -> bool { return (((*a).order) < ((*b).order)); } -pub unsafe fn operator_eq_2(a: *const Key, b: *const Key) -> bool { +pub unsafe fn operator_eq_1(a: *const Key, b: *const Key) -> bool { return (((*a).identity) == ((*b).identity)); } #[repr(C)] @@ -96,7 +110,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & ((unsafe { let _a: *const Key = &distinct_a; - operator_eq_2(_a, &distinct_b) + operator_eq_1(_a, &distinct_b) }) as i32)) != 0; let mut distinct: UnsafeMap = UnsafeMap::new(); @@ -119,7 +133,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((a) != (b)) as i32)) != 0; ok = ((ok as i32) & (((((*a).value) == (11)) && (((*b).value) == (22))) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&a_it), LvalueRefUnsafe::>>::bind( &distinct.find(&distinct_a), @@ -127,7 +141,7 @@ unsafe fn main_0() -> i32 { ))) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&b_it), LvalueRefUnsafe::>>::bind( &distinct.find(&distinct_b), @@ -149,7 +163,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & ((unsafe { let _a: *const Key = &distinct_a; - operator_eq_2(_a, &distinct_b) + operator_eq_1(_a, &distinct_b) }) as i32)) != 0; let mut distinct_count: usize = 0_usize; @@ -178,7 +192,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (!(unsafe { let _a: *const Key = &equivalent_a; - operator_eq_2(_a, &equivalent_b) + operator_eq_1(_a, &equivalent_b) }) as i32)) != 0; let mut equivalent: UnsafeMap = UnsafeMap::new(); @@ -212,28 +226,24 @@ unsafe fn main_0() -> i32 { != 0; ok = ((ok as i32) & (((first) == (second)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &first_it, - ), - LvalueRefUnsafe::>>::bind( - &equivalent.find(&equivalent_a), - ), + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &first_it, ), - )) as i32)) + LvalueRefUnsafe::>>::bind( + &equivalent.find(&equivalent_a), + ), + ))) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &first_it, - ), - LvalueRefUnsafe::>>::bind( - &equivalent.find(&equivalent_b), - ), + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &first_it, ), - )) as i32)) + LvalueRefUnsafe::>>::bind( + &equivalent.find(&equivalent_b), + ), + ))) as i32)) != 0; ok = ((ok as i32) & (((&mut (*first_it.iter_deref()).1 as *mut Mapped) == (first_value)) as i32)) @@ -255,7 +265,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (!(unsafe { let _a: *const Key = &equivalent_a; - operator_eq_2(_a, &equivalent_b) + operator_eq_1(_a, &equivalent_b) }) as i32)) != 0; let later_key: Key = Key { @@ -271,16 +281,14 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((equivalent.len()) == (2_usize)) as i32)) != 0; if reused { ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &first_it, - ), - LvalueRefUnsafe::>>::bind( - &equivalent.find(&equivalent_a), - ), + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::>>::bind( + &first_it, ), - )) as i32)) + LvalueRefUnsafe::>>::bind( + &equivalent.find(&equivalent_a), + ), + ))) as i32)) != 0; ok = ((ok as i32) & (((&mut (*first_it.iter_deref()).1 as *mut Mapped) == (first_value)) as i32)) @@ -319,7 +327,7 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((matching.len()) == (1_usize)) as i32)) != 0; ok = ((ok as i32) & (((matched) == (matched_again)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( &matching.find(&matching_b), @@ -338,7 +346,7 @@ unsafe fn main_0() -> i32 { != 0; ok = ((ok as i32) & (((matching.len()) == (2_usize)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( &matching.find(&matching_a), diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 119de50a7a..9f184fe05b 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -219,7 +219,29 @@ unsafe fn main_0() -> i32 { & ((((result.1) as i32) == (!(hit) as i32)) as i32)) != 0; - let mut found : bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe:: >>::bind(&result .0 ), LvalueRefUnsafe:: >>::bind(&m .find(&key ) ), )) ; + let mut found: bool = + ConvertibleToUnsafe::::convert_value( + Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::< + Const< + UnsafeBidirectionalIterator< + (i32, i32), + >, + >, + >::bind( + &result.0 + ), + LvalueRefUnsafe::< + Const< + UnsafeBidirectionalIterator< + (i32, i32), + >, + >, + >::bind( + &m.find(&key) + ), + ), + ); ok = ((ok as i32) & (found as i32)) != 0; ok = ((ok as i32) & ((((*result.0.iter_deref()).0) == (key)) diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 321aa443eb..45871f4182 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -22,7 +22,7 @@ use std::rc::Rc; pub struct S { pub v: i32, } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -35,6 +35,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { operator_eq_0(_a, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -152,7 +154,7 @@ pub unsafe fn operator_lt_7(mut a: i32, b: *const S) -> bool { pub struct V { pub v: i32, } -impl WeaklyEqualityComparableWithUnsafe for V { +impl Cpp17EqualityComparableUnsafe for V { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -165,6 +167,8 @@ impl WeaklyEqualityComparableWithUnsafe for V { operator_eq_8(_a, (*__rhs)) }); } +} +impl WeaklyEqualityComparableWithUnsafe for V { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 691541c89b..9199da3513 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -45,7 +45,7 @@ impl S { return (((*this).v) < (o)); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -55,6 +55,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index 7ae9588e4c..f278efaae9 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -42,7 +42,7 @@ impl S { return (((*this).v) >= (((*o) as i32) - (('0' as libc::c_char) as i32))); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -52,17 +52,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) }); } - type NotEqualResult = bool; - unsafe fn not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) }); - } } -impl WeaklyEqualityComparableWithUnsafe for i32 { +impl Cpp17EqualityComparableUnsafe for i32 { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -75,6 +66,19 @@ impl WeaklyEqualityComparableWithUnsafe for i32 { operator_eq_0(_a, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i32 { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -88,7 +92,7 @@ impl WeaklyEqualityComparableWithUnsafe for i32 { }); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -98,17 +102,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { let __rhs = (__rhs.as_ptr() as *const f64); return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); } - type NotEqualResult = bool; - unsafe fn not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); - } } -impl WeaklyEqualityComparableWithUnsafe for f64 { +impl Cpp17EqualityComparableUnsafe for f64 { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -121,6 +116,19 @@ impl WeaklyEqualityComparableWithUnsafe for f64 { operator_eq_0(_a, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for f64 { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -134,7 +142,7 @@ impl WeaklyEqualityComparableWithUnsafe for f64 { }); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -144,17 +152,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { let __rhs = (__rhs.as_ptr() as *const i64); return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); } - type NotEqualResult = bool; - unsafe fn not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); - } } -impl WeaklyEqualityComparableWithUnsafe for i64 { +impl Cpp17EqualityComparableUnsafe for i64 { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -167,6 +166,19 @@ impl WeaklyEqualityComparableWithUnsafe for i64 { operator_eq_0(_a, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for i64 { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index f05f26c54c..53db0128e1 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -22,7 +22,7 @@ use std::rc::Rc; pub struct X { pub v: i32, } -impl WeaklyEqualityComparableWithUnsafe for X { +impl Cpp17EqualityComparableUnsafe for X { type EqualResult = i32; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -35,6 +35,8 @@ impl WeaklyEqualityComparableWithUnsafe for X { operator_eq_0(_a, (*__rhs)) }); } +} +impl WeaklyEqualityComparableWithUnsafe for X { type NotEqualResult = i32; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -198,6 +200,17 @@ impl Mixed { return if (((*this).v) == ((*o).v)) { 9 } else { 0 }; } } +impl Cpp17EqualityComparableUnsafe for Mixed { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Mixed); + let __rhs = (__rhs.as_ptr() as *const Mixed); + return (unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) }); + } +} impl LessThanComparableUnsafe for Mixed { type Result = i32; unsafe fn less( @@ -235,7 +248,7 @@ impl MyBool { return (*this).value; } } -impl WeaklyEqualityComparableWithUnsafe for MyBool { +impl Cpp17EqualityComparableUnsafe for MyBool { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -246,6 +259,8 @@ impl WeaklyEqualityComparableWithUnsafe for MyBool { return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); } +} +impl WeaklyEqualityComparableWithUnsafe for MyBool { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -341,6 +356,20 @@ impl ThreeWayComparableUnsafe for MyBool { pub struct Boolish { pub v: i32, } +impl Cpp17EqualityComparableUnsafe for Boolish { + type EqualResult = MyBool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Boolish); + let __rhs = (__rhs.as_ptr() as *const Boolish); + return (unsafe { + let _a: Boolish = (*__lhs); + operator_eq_6(_a, (*__rhs)) + }); + } +} impl LessThanComparableUnsafe for Boolish { type Result = MyBool; unsafe fn less( @@ -351,18 +380,18 @@ impl LessThanComparableUnsafe for Boolish { let __rhs = (__rhs.as_ptr() as *const Boolish); return (unsafe { let _a: Boolish = (*__lhs); - operator_lt_6(_a, (*__rhs)) + operator_lt_7(_a, (*__rhs)) }); } } -pub unsafe fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool { +pub unsafe fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) == (b.v))); __v }; } -pub unsafe fn operator_lt_6(mut a: Boolish, mut b: Boolish) -> MyBool { +pub unsafe fn operator_lt_7(mut a: Boolish, mut b: Boolish) -> MyBool { return { let mut __v: MyBool = ZeroInitializationUnsafe::zero_init(); MyBool::constructor_1(&raw mut __v, ((a.v) < (b.v))); @@ -393,7 +422,7 @@ impl RefBool { return (*this).value; } } -impl WeaklyEqualityComparableWithUnsafe for RefBool { +impl Cpp17EqualityComparableUnsafe for RefBool { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -404,6 +433,8 @@ impl WeaklyEqualityComparableWithUnsafe for RefBool { return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); } +} +impl WeaklyEqualityComparableWithUnsafe for RefBool { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -511,6 +542,19 @@ impl RefInt { return &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut ref_true_8)); } } +impl Cpp17EqualityComparableUnsafe for RefInt { + type EqualResult = LvalueRefUnsafe; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const RefInt); + let __rhs = (__rhs.as_ptr() as *const RefInt); + return LvalueRefUnsafe::bind( + &mut (*(unsafe { RefInt::operator_eq(&raw const (*__lhs), __rhs) })), + ); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -658,7 +702,7 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b1; - operator_eq_7(_a, Boolish { v: 1 }) + operator_eq_6(_a, Boolish { v: 1 }) }), ) }) @@ -668,14 +712,14 @@ unsafe fn main_0() -> i32 { MyBool::to_bool( &(unsafe { let _a: Boolish = b2; - operator_lt_6(_a, b1) + operator_lt_7(_a, b1) }), ) }) ); let mut lt: MyBool = (unsafe { let _a: Boolish = b1; - operator_lt_6(_a, b2) + operator_lt_7(_a, b2) }); assert!(lt.value); let mut bs: [Boolish; 3] = [Boolish { v: 3 }, Boolish { v: 1 }, Boolish { v: 2 }]; @@ -734,7 +778,7 @@ unsafe fn main_0() -> i32 { LvalueRefUnsafe::>::bind(&__tmp_3), ), ) && !ConvertibleToUnsafe::::convert_value( - >::equal( + >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&ri2), ), diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index c0c0497477..dca006b330 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -28,6 +28,20 @@ impl S { (&raw mut (*this).data_).write(data); } } +impl Cpp17EqualityComparableUnsafe for S { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _x: *const S = __lhs; + operator_eq_0(_x, __rhs) + }); + } +} impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index 756601671c..7565b4f1c1 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -65,7 +65,7 @@ impl S { return (((*this).v) != (0)); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -76,6 +76,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { return ((unsafe { S::to_i32(&raw const (*__lhs)) }) == (unsafe { S::to_i32(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 1f690397e0..6a1fafdb74 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -45,22 +45,83 @@ impl S { return ((((*this).v) * (o)) + (1)); } } -pub unsafe fn operator_div_0(a: *const S, b: *const S) -> i32 { +impl Cpp17EqualityComparableUnsafe for S { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) }); + } +} +impl Cpp17EqualityComparableUnsafe for i32 { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i32 = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }); + } +} +impl Cpp17EqualityComparableUnsafe for S { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + return (unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) }); + } +} +impl Cpp17EqualityComparableUnsafe for i64 { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + return (unsafe { + let _a: i64 = (*__lhs); + operator_eq_1(_a, __rhs) + }); + } +} +impl Cpp17EqualityComparableUnsafe for S { + type EqualResult = i32; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + return (unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) }); + } +} +pub unsafe fn operator_div_2(a: *const S, b: *const S) -> i32 { return (((*a).v) / ((*b).v)); } -pub unsafe fn operator_div_1(mut a: S, mut b: i32) -> i32 { +pub unsafe fn operator_div_3(mut a: S, mut b: i32) -> i32 { return (((a.v) / (b)) + (1)); } -pub unsafe fn operator_rem_2(mut a: S, mut b: S) -> i32 { +pub unsafe fn operator_rem_4(mut a: S, mut b: S) -> i32 { return ((a.v) % (b.v)); } -pub unsafe fn operator_rem_3(a: *const S, mut b: i32) -> i32 { +pub unsafe fn operator_rem_5(a: *const S, mut b: i32) -> i32 { return ((((*a).v) % (b)) + (1)); } -pub unsafe fn operator_eq_4(mut a: i32, mut b: S) -> i32 { +pub unsafe fn operator_eq_0(mut a: i32, mut b: S) -> i32 { return if ((a) == (b.v)) { 4 } else { 0 }; } -pub unsafe fn operator_eq_5(mut a: i64, b: *const S) -> i32 { +pub unsafe fn operator_eq_1(mut a: i64, b: *const S) -> i32 { return if ((a) == ((*b).v as i64)) { 5 } else { 0 }; } pub fn main() { @@ -83,29 +144,29 @@ unsafe fn main_0() -> i32 { assert!( ((unsafe { let _a: *const S = &s; - operator_div_0(_a, &t) + operator_div_2(_a, &t) }) == (1)) ); assert!( ((unsafe { let _a: S = s; - operator_div_1(_a, 4) + operator_div_3(_a, 4) }) == (2)) ); assert!( ((unsafe { let _a: S = s; - operator_rem_2(_a, t) + operator_rem_4(_a, t) }) == (2)) ); assert!( ((unsafe { let _a: *const S = &s; - operator_rem_3(_a, 4) + operator_rem_5(_a, 4) }) == (3)) ); - assert!(((unsafe { operator_eq_4(6, s,) }) == (4))); - assert!(((unsafe { operator_eq_5(6_i64, &s,) }) == (5))); + assert!(((unsafe { operator_eq_0(6, s,) }) == (4))); + assert!(((unsafe { operator_eq_1(6_i64, &s,) }) == (5))); return 0; } pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 8f5b3c8dbb..8e3904bb57 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -36,7 +36,7 @@ impl S { return (((*this).v) == ((*o).v)); } } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -46,6 +46,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index 5188469917..2afb6bf0c2 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -50,7 +50,7 @@ impl Meters { return (*this).value; } } -impl WeaklyEqualityComparableWithUnsafe for Meters { +impl Cpp17EqualityComparableUnsafe for Meters { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -61,6 +61,8 @@ impl WeaklyEqualityComparableWithUnsafe for Meters { return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) == (unsafe { Meters::to_i32(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for Meters { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs index 9cd13c38d0..59b8b1c221 100644 --- a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs +++ b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs @@ -9,7 +9,7 @@ use std::rc::Rc; pub unsafe fn sink_0(mut it: UnsafeBidirectionalIterator<(i32, i32)>) -> i32 { let mut cit: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it).clone()); - return if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + return if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&cit), LvalueRefUnsafe::>>::bind( &>::from((it).clone()), @@ -40,7 +40,7 @@ unsafe fn main_0() -> i32 { let mut const_it: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it0).clone()); let mut r: i32 = - if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( &>::from((end).clone()), @@ -51,7 +51,7 @@ unsafe fn main_0() -> i32 { 1 }; r += (unsafe { sink_0((it0).clone()) }); - r += if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + r += if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&end), LvalueRefUnsafe::>>::bind(&end), )) { @@ -66,7 +66,7 @@ unsafe fn main_0() -> i32 { >::from((middle).clone()); assert!(((*const_middle.iter_deref()) == (8_u32))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&const_middle), LvalueRefUnsafe::>>::bind(&middle), ) diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index 369bca8144..e356bc779e 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -319,7 +319,7 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_13 = { v3.begin() }; let mut __tmp_14 = { v3.end() }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&v3.end()), diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 8587c74a2f..19e6f6c79d 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -141,6 +141,20 @@ impl Bag { (&raw mut (*this).items).write(Vec::new()); } } +impl Cpp17EqualityComparableUnsafe for Bag { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + return (unsafe { + let _a: *const Bag = __lhs; + operator_eq_4(_a, __rhs) + }); + } +} impl LessThanComparableUnsafe for Bag { type Result = bool; unsafe fn less( @@ -151,14 +165,14 @@ impl LessThanComparableUnsafe for Bag { let __rhs = (__rhs.as_ptr() as *const Bag); return (unsafe { let _a: *const Bag = __lhs; - operator_lt_4(_a, __rhs) + operator_lt_5(_a, __rhs) }); } } -pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { +pub unsafe fn operator_lt_5(a: *const Bag, b: *const Bag) -> bool { return (((*a).items.len()) < ((*b).items.len())); } -pub unsafe fn operator_eq_5(a: *const Bag, b: *const Bag) -> bool { +pub unsafe fn operator_eq_4(a: *const Bag, b: *const Bag) -> bool { return (((*a).items.len()) == ((*b).items.len())); } pub fn main() { @@ -512,12 +526,12 @@ unsafe fn main_0() -> i32 { ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_7 = { bag_vec.begin() }; let mut __tmp_8 = { bag_vec.end() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( @@ -526,7 +540,7 @@ unsafe fn main_0() -> i32 { ) )); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_9 = { bag_vec.begin() }; let mut __tmp_10 = { bag_vec.end() }; @@ -581,7 +595,7 @@ unsafe fn main_0() -> i32 { )) = 0; assert!((((*bag_map.find(&bags[(2) as usize]).iter_deref()).1) == (2))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind( &bag_map.find(&bags[(1) as usize]) ), diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index 3e73e5b8ff..39b69fb06d 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -55,7 +55,7 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) let mut __tmp_0 = { items.begin() }; let mut __tmp_1 = { items.end() }; let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), ), ) { __it.iter_inc(); } __it }; assert!(ConvertibleToUnsafe::::convert_value( diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 910e681fa0..5d573b0e70 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -50,7 +50,7 @@ impl Reading { return (((*this).raw_ as i64) * (10_i64)); } } -impl WeaklyEqualityComparableWithUnsafe for Reading { +impl Cpp17EqualityComparableUnsafe for Reading { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -61,6 +61,8 @@ impl WeaklyEqualityComparableWithUnsafe for Reading { return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) == (unsafe { Reading::to_i64(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for Reading { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, From f7aafd2120f7ce194a683c186281dfa269992793 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:29:52 +0000 Subject: [PATCH 09/17] Update tests --- .../out/refcount/concept.convertible.rs | 4 +- .../out/unsafe/concept.convertible.rs | 4 +- .../refcount/operator_comparison_defaulted.rs | 692 +++++++++++++--- .../refcount/operator_comparison_nonbool.rs | 8 +- tests/unit/out/refcount/operator_friend.rs | 406 +++++++--- tests/unit/out/refcount/operator_traits.rs | 272 +++++-- .../unsafe/operator_comparison_defaulted.rs | 766 +++++++++++++++--- .../out/unsafe/operator_comparison_nonbool.rs | 8 +- tests/unit/out/unsafe/operator_friend.rs | 494 ++++++++--- tests/unit/out/unsafe/operator_traits.rs | 359 ++++++-- 10 files changed, 2458 insertions(+), 555 deletions(-) diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index 88c8318f65..6b4b422c59 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -169,14 +169,14 @@ impl PartiallyOrderedWith for p1_convertible_to_Ratio { } } impl ThreeWayComparable for p1_convertible_to_Ratio { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; fn three_way( __lhs: LvalueRef>, __rhs: LvalueRef>, ) -> Self::Category { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }), &({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }), )); diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index ab7b5ab97a..75f2a8a771 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -152,14 +152,14 @@ impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { } } impl ThreeWayComparableUnsafe for p1_convertible_to_Ratio { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; unsafe fn three_way( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, ) -> Self::Category { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }), &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) }), )); diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index e954888897..5fb5fc8445 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -27,6 +27,28 @@ pub struct Eq { #[offset(4)] pub b: i32, } +impl Eq { + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }) + && ({ this.with(|__s| __s.b) } == { _a0.with(|__s| __s.b) }); + } +} +impl Cpp17EqualityComparable for Eq { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Eq { + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -38,11 +60,8 @@ pub struct Eq { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct Cmp { @@ -51,9 +70,8 @@ pub struct Cmp { #[offset(4)] pub b: i32, } -impl ThreeWayComparable for Cmp { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl Cmp { + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( @@ -74,6 +92,77 @@ impl ThreeWayComparable for Cmp { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }) + && ({ this.with(|__s| __s.b) } == { _a0.with(|__s| __s.b) }); + } +} +impl Cpp17EqualityComparable for Cmp { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Cmp { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Cmp { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for Cmp { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for Cmp { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } #[derive( Copy, @@ -86,20 +175,19 @@ impl ThreeWayComparable for Cmp { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct Both { #[offset(0)] pub a: i32, } -impl ThreeWayComparable for Both { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl Both { + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }); + } + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( @@ -112,6 +200,76 @@ impl ThreeWayComparable for Both { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } +impl Cpp17EqualityComparable for Both { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Both { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Both { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for Both { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for Both { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -123,11 +281,8 @@ impl ThreeWayComparable for Both { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(OrdOnly::operator_cmp)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct OrdOnly { @@ -148,6 +303,52 @@ impl OrdOnly { return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } } +impl LessThanComparable for OrdOnly { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for OrdOnly { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} #[derive( Copy, Clone, @@ -159,20 +360,16 @@ impl OrdOnly { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct Inner { #[offset(0)] pub x: i32, } -impl ThreeWayComparable for Inner { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl Inner { + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( @@ -184,6 +381,79 @@ impl ThreeWayComparable for Inner { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.x) } == { _a0.with(|__s| __s.x) }); + } +} +impl Cpp17EqualityComparable for Inner { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Inner { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Inner { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for Inner { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for Inner { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } #[derive( Copy, @@ -196,11 +466,8 @@ impl ThreeWayComparable for Inner { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct Outer { @@ -210,12 +477,11 @@ pub struct Outer { #[offset(4)] pub y: i32, } -impl ThreeWayComparable for Outer { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl Outer { + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new( - ({ ThreeWayComparable::three_way(field_ptr!(this, i), field_ptr!(_a0, i)) }), + ({ Inner::operator_cmp(field_ptr!(this, i), field_ptr!(_a0, i)) }), )); if !(libcc2rs::is_eq(({ (*cmp.borrow()) }))) { return (*cmp.borrow_mut()); @@ -232,6 +498,80 @@ impl ThreeWayComparable for Outer { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ Inner::operator_eq(field_ptr!(this, i), field_ptr!(_a0, i)) }) + && ({ this.with(|__s| __s.y) } == { _a0.with(|__s| __s.y) }); + } +} +impl Cpp17EqualityComparable for Outer { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Outer { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Outer { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for Outer { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for Outer { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } #[derive( Copy, @@ -252,9 +592,14 @@ pub struct Secondary { #[offset(0)] pub a: i32, } -impl ThreeWayComparable for Secondary { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl Secondary { + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }); + } + pub fn operator_ne(this: Ptr, _a0: Ptr) -> bool { + return !({ Secondary::operator_eq((this).clone(), (_a0).clone()) }); + } + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( @@ -266,10 +611,93 @@ impl ThreeWayComparable for Secondary { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_lt(this: Ptr, _a0: Ptr) -> bool { + return libcc2rs::is_lt(({ Secondary::operator_cmp((this).clone(), (_a0).clone()) })); + } + pub fn operator_ge(this: Ptr, _a0: Ptr) -> bool { + return libcc2rs::is_gteq(({ Secondary::operator_cmp((this).clone(), (_a0).clone()) })); + } +} +impl Cpp17EqualityComparable for Secondary { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Secondary { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone()) }); + } } impl LessThanComparable for Secondary { - fn less(this: Ptr, _a0: Ptr) -> bool { - return libcc2rs::is_lt(({ ThreeWayComparable::three_way((this).clone(), (_a0).clone()) })); + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); + } +} +impl PartiallyOrderedWith for Secondary { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone()) }); + } +} +impl ThreeWayComparable for Secondary { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }); } } #[derive( @@ -282,11 +710,8 @@ impl LessThanComparable for Secondary { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(8)] pub struct PtrMember { @@ -294,9 +719,8 @@ pub struct PtrMember { #[byte_size(8)] pub p: Ptr, } -impl ThreeWayComparable for PtrMember { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { +impl PtrMember { + pub fn operator_cmp(this: Ptr, _a0: Ptr) -> libcc2rs::StrongOrdering { { let cmp: Value = Rc::new(RefCell::new( libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( @@ -310,6 +734,91 @@ impl ThreeWayComparable for PtrMember { } return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.p.clone()) } == { _a0.with(|__s| __s.p.clone()) }); + } +} +impl Cpp17EqualityComparable for PtrMember { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for PtrMember { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for PtrMember { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for PtrMember { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for PtrMember { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } pub fn main() { __cpp2rust_init_globals(); @@ -319,22 +828,22 @@ fn main_0() -> i32 { let e1: Value = Rc::new(RefCell::new(Eq { a: 1, b: 2 })); let e2: Value = Rc::new(RefCell::new(Eq { a: 1, b: 2 })); let e3: Value = Rc::new(RefCell::new(Eq { a: 1, b: 3 })); - assert!(({ WeaklyEqualityComparableWith::equal(e1.as_pointer(), e2.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(e1.as_pointer(), e3.as_pointer(),) })); + assert!(({ Eq::operator_eq(e1.as_pointer(), e2.as_pointer(),) })); + assert!(!({ Eq::operator_eq(e1.as_pointer(), e3.as_pointer(),) })); let c1: Value = Rc::new(RefCell::new(Cmp { a: 1, b: 2 })); let c2: Value = Rc::new(RefCell::new(Cmp { a: 1, b: 3 })); let c3: Value = Rc::new(RefCell::new(Cmp { a: 2, b: 0 })); let c4: Value = Rc::new(RefCell::new(Cmp { a: 1, b: 9 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(c1.as_pointer(), c2.as_pointer(),) }) + ({ Cmp::operator_cmp(c1.as_pointer(), c2.as_pointer(),) }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(c3.as_pointer(), c4.as_pointer(),) }) + ({ Cmp::operator_cmp(c3.as_pointer(), c4.as_pointer(),) }) )); - assert!(({ WeaklyEqualityComparableWith::equal(c1.as_pointer(), c1.as_pointer(),) })); + assert!(({ Cmp::operator_eq(c1.as_pointer(), c1.as_pointer(),) })); assert!({ let __a = libcc2rs::PartialOrdering::from( - ({ ThreeWayComparable::three_way(c1.as_pointer(), c2.as_pointer()) }), + ({ Cmp::operator_cmp(c1.as_pointer(), c2.as_pointer()) }), ); let __b = libcc2rs::PartialOrdering::from( ({ (*libcc2rs::strong_ordering_less().upgrade().deref()) }), @@ -346,9 +855,9 @@ fn main_0() -> i32 { let b1: Value = Rc::new(RefCell::new(Both { a: 1 })); let b2: Value = Rc::new(RefCell::new(Both { a: 2 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(b1.as_pointer(), b2.as_pointer(),) }) + ({ Both::operator_cmp(b1.as_pointer(), b2.as_pointer(),) }) )); - assert!(({ WeaklyEqualityComparableWith::equal(b2.as_pointer(), b2.as_pointer(),) })); + assert!(({ Both::operator_eq(b2.as_pointer(), b2.as_pointer(),) })); let o1: Value = Rc::new(RefCell::new(OrdOnly { a: 1 })); let o2: Value = Rc::new(RefCell::new(OrdOnly { a: 2 })); assert!(libcc2rs::is_lt( @@ -378,12 +887,12 @@ fn main_0() -> i32 { y: 9, })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(x1.as_pointer(), x2.as_pointer(),) }) + ({ Outer::operator_cmp(x1.as_pointer(), x2.as_pointer(),) }) )); - assert!(({ WeaklyEqualityComparableWith::equal(x1.as_pointer(), x3.as_pointer(),) })); + assert!(({ Outer::operator_eq(x1.as_pointer(), x3.as_pointer(),) })); assert!({ let __a = libcc2rs::PartialOrdering::from( - ({ ThreeWayComparable::three_way(x2.as_pointer(), x1.as_pointer()) }), + ({ Outer::operator_cmp(x2.as_pointer(), x1.as_pointer()) }), ); let __b = libcc2rs::PartialOrdering::from( ({ (*libcc2rs::strong_ordering_greater().upgrade().deref()) }), @@ -394,10 +903,10 @@ fn main_0() -> i32 { }); let s1: Value = Rc::new(RefCell::new(Secondary { a: 1 })); let s2: Value = Rc::new(RefCell::new(Secondary { a: 2 })); - assert!(({ WeaklyEqualityComparableWith::not_equal(s1.as_pointer(), s2.as_pointer(),) })); - assert!(({ LessThanComparable::less(s1.as_pointer(), s2.as_pointer(),) })); - assert!(({ PartiallyOrderedWith::greater_equal(s2.as_pointer(), s1.as_pointer(),) })); - assert!(!({ LessThanComparable::less(s2.as_pointer(), s1.as_pointer(),) })); + assert!(({ Secondary::operator_ne(s1.as_pointer(), s2.as_pointer(),) })); + assert!(({ Secondary::operator_lt(s1.as_pointer(), s2.as_pointer(),) })); + assert!(({ Secondary::operator_ge(s2.as_pointer(), s1.as_pointer(),) })); + assert!(!({ Secondary::operator_lt(s2.as_pointer(), s1.as_pointer(),) })); let arr: Value> = Rc::new(RefCell::new(Box::new([0, 0]))); let p1: Value = Rc::new(RefCell::new(PtrMember { p: arr.decay() })); let p2: Value = Rc::new(RefCell::new(PtrMember { @@ -405,12 +914,12 @@ fn main_0() -> i32 { })); let p3: Value = Rc::new(RefCell::new(PtrMember { p: arr.decay() })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(p1.as_pointer(), p2.as_pointer(),) }) + ({ PtrMember::operator_cmp(p1.as_pointer(), p2.as_pointer(),) }) )); - assert!(({ WeaklyEqualityComparableWith::equal(p1.as_pointer(), p3.as_pointer(),) })); + assert!(({ PtrMember::operator_eq(p1.as_pointer(), p3.as_pointer(),) })); assert!({ let __a = libcc2rs::PartialOrdering::from( - ({ ThreeWayComparable::three_way(p2.as_pointer(), p1.as_pointer()) }), + ({ PtrMember::operator_cmp(p2.as_pointer(), p1.as_pointer()) }), ); let __b = libcc2rs::PartialOrdering::from( ({ (*libcc2rs::strong_ordering_greater().upgrade().deref()) }), @@ -421,61 +930,4 @@ fn main_0() -> i32 { }); return 0; } -impl PartiallyOrderedWith for Secondary { - fn greater_equal(this: Ptr, _a0: Ptr) -> bool { - return libcc2rs::is_gteq( - ({ ThreeWayComparable::three_way((this).clone(), (_a0).clone()) }), - ); - } - fn less(lhs: Ptr, rhs: Ptr) -> bool { - ::less(lhs, rhs) - } - fn greater(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_gt(ThreeWayComparable::three_way(lhs, rhs)) - } - fn less_equal(lhs: Ptr, rhs: Ptr) -> bool { - libcc2rs::is_lteq(ThreeWayComparable::three_way(lhs, rhs)) - } -} -impl WeaklyEqualityComparableWith for Both { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }); - } -} -impl WeaklyEqualityComparableWith for Cmp { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }) - && ({ this.with(|__s| __s.b) } == { _a0.with(|__s| __s.b) }); - } -} -impl WeaklyEqualityComparableWith for Eq { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }) - && ({ this.with(|__s| __s.b) } == { _a0.with(|__s| __s.b) }); - } -} -impl WeaklyEqualityComparableWith for Inner { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.x) } == { _a0.with(|__s| __s.x) }); - } -} -impl WeaklyEqualityComparableWith for Outer { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ WeaklyEqualityComparableWith::equal(field_ptr!(this, i), field_ptr!(_a0, i)) }) - && ({ this.with(|__s| __s.y) } == { _a0.with(|__s| __s.y) }); - } -} -impl WeaklyEqualityComparableWith for PtrMember { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.p.clone()) } == { _a0.with(|__s| __s.p.clone()) }); - } -} -impl WeaklyEqualityComparableWith for Secondary { - fn equal(this: Ptr, _a0: Ptr) -> bool { - return ({ this.with(|__s| __s.a) } == { _a0.with(|__s| __s.a) }); - } - fn not_equal(this: Ptr, _a0: Ptr) -> bool { - return !({ WeaklyEqualityComparableWith::equal((this).clone(), (_a0).clone()) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index daf0504920..61912f30aa 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -334,14 +334,14 @@ impl PartiallyOrderedWith for MyBool { } } impl ThreeWayComparable for MyBool { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; fn three_way( __lhs: LvalueRef>, __rhs: LvalueRef>, ) -> Self::Category { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &(({ MyBool::to_bool((__lhs).clone()) }) as i32), &(({ MyBool::to_bool((__rhs).clone()) }) as i32), )); @@ -517,14 +517,14 @@ impl PartiallyOrderedWith for RefBool { } } impl ThreeWayComparable for RefBool { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; fn three_way( __lhs: LvalueRef>, __rhs: LvalueRef>, ) -> Self::Category { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &(({ RefBool::to_bool((__lhs).clone()) }) as i32), &(({ RefBool::to_bool((__rhs).clone()) }) as i32), )); diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 161dd73e09..38d80092ec 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -6,6 +6,10 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; +pub fn operator_eq_0(_a0: Ptr, _a1: Ptr) -> bool { + return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }) + && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); +} #[derive( Copy, Clone, @@ -27,20 +31,42 @@ pub struct Defaulted { #[offset(4)] pub b: i32, } -impl ThreeWayComparable for DefaultedOrd { - type Category = libcc2rs::StrongOrdering; - fn three_way(_a0: Ptr, _a1: Ptr) -> libcc2rs::StrongOrdering { - { - let cmp: Value = - Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( - std::cmp::Ord::cmp(&(_a0.with(|__s| __s.a)), &(_a1.with(|__s| __s.a))), - ))); - if !(libcc2rs::is_eq(({ (*cmp.borrow()) }))) { - return (*cmp.borrow_mut()); - } +impl Cpp17EqualityComparable for Defaulted { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Defaulted { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn operator_cmp_1(_a0: Ptr, _a1: Ptr) -> libcc2rs::StrongOrdering { + { + let cmp: Value = + Rc::new(RefCell::new(libcc2rs::StrongOrdering::from( + std::cmp::Ord::cmp(&(_a0.with(|__s| __s.a)), &(_a1.with(|__s| __s.a))), + ))); + if !(libcc2rs::is_eq(({ (*cmp.borrow()) }))) { + return (*cmp.borrow_mut()); } - return (*libcc2rs::strong_ordering_equal().upgrade().deref()); } + return (*libcc2rs::strong_ordering_equal().upgrade().deref()); +} +pub fn operator_eq_2(_a0: Ptr, _a1: Ptr) -> bool { + return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }); } #[derive( Copy, @@ -53,23 +79,103 @@ impl ThreeWayComparable for DefaultedOrd { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct DefaultedOrd { #[offset(0)] pub a: i32, } -impl LessThanComparable for Inline { - fn less(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.a) } < { y.with(|__s| __s.a) }); +impl Cpp17EqualityComparable for DefaultedOrd { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); } } -pub fn operator_add_0(x: Ptr, y: Ptr) -> Inline { +impl WeaklyEqualityComparableWith for DefaultedOrd { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for DefaultedOrd { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for DefaultedOrd { + type LessResult = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for DefaultedOrd { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn operator_eq_3(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); +} +pub fn operator_lt_4(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.a) } < { y.with(|__s| __s.a) }); +} +pub fn operator_add_5(x: Ptr, y: Ptr) -> Inline { return Inline { a: ({ x.with(|__s| __s.a) } + { y.with(|__s| __s.a) }), }; @@ -93,6 +199,36 @@ pub struct Inline { #[offset(0)] pub a: i32, } +impl Cpp17EqualityComparable for Inline { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Inline { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Inline { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -112,11 +248,43 @@ pub struct OutOfLine { #[offset(0)] pub a: i32, } -impl LessThanComparable for Tmpl_int_ { - fn less(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.v) } < { y.with(|__s| __s.v) }); +impl Cpp17EqualityComparable for OutOfLine { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_6((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for OutOfLine { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_ne_7((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_eq_6(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); +} +pub fn operator_ne_7(x: Ptr, y: Ptr) -> bool { + return !({ operator_eq_6((x).clone(), (y).clone()) }); +} +pub fn operator_eq_8(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.v) } == { y.with(|__s| __s.v) }); +} +pub fn operator_lt_9(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.v) } < { y.with(|__s| __s.v) }); +} +pub fn operator_eq_10(x: Ptr, y: Ptr) -> bool { + return ({ (x.with(|__s| __s.v) as i64) } == { y.with(|__s| __s.v) }); +} #[derive( Copy, Clone, @@ -136,6 +304,45 @@ pub struct Tmpl_int_ { #[offset(0)] pub v: i32, } +impl Cpp17EqualityComparable for Tmpl_int_ { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Tmpl_int_ { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Tmpl_int_ { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_9((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn operator_eq_11(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.v) } == { y.with(|__s| __s.v) }); +} +pub fn operator_lt_12(x: Ptr, y: Ptr) -> bool { + return ({ x.with(|__s| __s.v) } < { y.with(|__s| __s.v) }); +} #[derive( Copy, Clone, @@ -155,6 +362,42 @@ pub struct Tmpl_long_ { #[offset(0)] pub v: i64, } +impl Cpp17EqualityComparable for Tmpl_long_ { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Tmpl_long_ { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Tmpl_long_ { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_12((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn operator_eq_13(_a0: Ptr, _a1: Ptr) -> bool { + return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); +} #[derive( Copy, Clone, @@ -174,6 +417,28 @@ pub struct TmplDefaulted_int_ { #[offset(0)] pub v: i32, } +impl Cpp17EqualityComparable for TmplDefaulted_int_ { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for TmplDefaulted_int_ { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -182,22 +447,21 @@ fn main_0() -> i32 { let d1: Value = Rc::new(RefCell::new(Defaulted { a: 1, b: 2 })); let d2: Value = Rc::new(RefCell::new(Defaulted { a: 1, b: 2 })); let d3: Value = Rc::new(RefCell::new(Defaulted { a: 1, b: 3 })); - assert!(({ WeaklyEqualityComparableWith::equal(d1.as_pointer(), d2.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(d1.as_pointer(), d3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(d1.as_pointer(), d3.as_pointer(),) })); + assert!(({ operator_eq_0(d1.as_pointer(), d2.as_pointer(),) })); + assert!(!({ operator_eq_0(d1.as_pointer(), d3.as_pointer(),) })); + assert!(!({ operator_eq_0(d1.as_pointer(), d3.as_pointer(),) })); let o1: Value = Rc::new(RefCell::new(DefaultedOrd { a: 1 })); let o2: Value = Rc::new(RefCell::new(DefaultedOrd { a: 2 })); assert!(libcc2rs::is_lt( - ({ ThreeWayComparable::three_way(o1.as_pointer(), o2.as_pointer(),) }) + ({ operator_cmp_1(o1.as_pointer(), o2.as_pointer(),) }) )); assert!(libcc2rs::is_gt( - ({ ThreeWayComparable::three_way(o2.as_pointer(), o1.as_pointer(),) }) + ({ operator_cmp_1(o2.as_pointer(), o1.as_pointer(),) }) )); - assert!(({ WeaklyEqualityComparableWith::equal(o1.as_pointer(), o1.as_pointer(),) })); + assert!(({ operator_eq_2(o1.as_pointer(), o1.as_pointer(),) })); assert!({ - let __a = libcc2rs::PartialOrdering::from( - ({ ThreeWayComparable::three_way(o1.as_pointer(), o2.as_pointer()) }), - ); + let __a = + libcc2rs::PartialOrdering::from(({ operator_cmp_1(o1.as_pointer(), o2.as_pointer()) })); let __b = libcc2rs::PartialOrdering::from( ({ (*libcc2rs::strong_ordering_less().upgrade().deref()) }), ); @@ -208,85 +472,41 @@ fn main_0() -> i32 { let i1: Value = Rc::new(RefCell::new(Inline { a: 1 })); let i2: Value = Rc::new(RefCell::new(Inline { a: 2 })); let i3: Value = Rc::new(RefCell::new(Inline { a: 1 })); - assert!(({ WeaklyEqualityComparableWith::equal(i1.as_pointer(), i3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(i1.as_pointer(), i2.as_pointer(),) })); - assert!(({ LessThanComparable::less(i1.as_pointer(), i2.as_pointer(),) })); - assert!(!({ LessThanComparable::less(i2.as_pointer(), i1.as_pointer(),) })); + assert!(({ operator_eq_3(i1.as_pointer(), i3.as_pointer(),) })); + assert!(!({ operator_eq_3(i1.as_pointer(), i2.as_pointer(),) })); + assert!(({ operator_lt_4(i1.as_pointer(), i2.as_pointer(),) })); + assert!(!({ operator_lt_4(i2.as_pointer(), i1.as_pointer(),) })); assert!( ({ let _x: Value = Rc::new(RefCell::new( - ({ operator_add_0(i1.as_pointer(), i2.as_pointer()) }), + ({ operator_add_5(i1.as_pointer(), i2.as_pointer()) }), )); let _y: Value = Rc::new(RefCell::new(Inline { a: 3 })); - WeaklyEqualityComparableWith::equal(_x.as_pointer(), _y.as_pointer()) + operator_eq_3(_x.as_pointer(), _y.as_pointer()) }) ); let f1: Value = Rc::new(RefCell::new(OutOfLine { a: 4 })); let f2: Value = Rc::new(RefCell::new(OutOfLine { a: 4 })); let f3: Value = Rc::new(RefCell::new(OutOfLine { a: 5 })); - assert!(({ WeaklyEqualityComparableWith::equal(f1.as_pointer(), f2.as_pointer(),) })); - assert!(({ WeaklyEqualityComparableWith::not_equal(f1.as_pointer(), f3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(f1.as_pointer(), f3.as_pointer(),) })); + assert!(({ operator_eq_6(f1.as_pointer(), f2.as_pointer(),) })); + assert!(({ operator_ne_7(f1.as_pointer(), f3.as_pointer(),) })); + assert!(!({ operator_eq_6(f1.as_pointer(), f3.as_pointer(),) })); let t1: Value = Rc::new(RefCell::new(Tmpl_int_ { v: 1 })); let t2: Value = Rc::new(RefCell::new(Tmpl_int_ { v: 2 })); let t3: Value = Rc::new(RefCell::new(Tmpl_int_ { v: 1 })); - assert!(({ WeaklyEqualityComparableWith::equal(t1.as_pointer(), t3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(t1.as_pointer(), t2.as_pointer(),) })); - assert!(({ LessThanComparable::less(t1.as_pointer(), t2.as_pointer(),) })); + assert!(({ operator_eq_8(t1.as_pointer(), t3.as_pointer(),) })); + assert!(!({ operator_eq_8(t1.as_pointer(), t2.as_pointer(),) })); + assert!(({ operator_lt_9(t1.as_pointer(), t2.as_pointer(),) })); let u1: Value = Rc::new(RefCell::new(Tmpl_long_ { v: 1_i64 })); let u2: Value = Rc::new(RefCell::new(Tmpl_long_ { v: 2_i64 })); - assert!(({ WeaklyEqualityComparableWith::equal(t1.as_pointer(), u1.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(t1.as_pointer(), u2.as_pointer(),) })); + assert!(({ operator_eq_10(t1.as_pointer(), u1.as_pointer(),) })); + assert!(!({ operator_eq_10(t1.as_pointer(), u2.as_pointer(),) })); let v1: Value = Rc::new(RefCell::new(TmplDefaulted_int_ { v: 7 })); let v2: Value = Rc::new(RefCell::new(TmplDefaulted_int_ { v: 7 })); let v3: Value = Rc::new(RefCell::new(TmplDefaulted_int_ { v: 8 })); - assert!(({ WeaklyEqualityComparableWith::equal(v1.as_pointer(), v2.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(v1.as_pointer(), v3.as_pointer(),) })); - assert!(!({ WeaklyEqualityComparableWith::equal(v1.as_pointer(), v3.as_pointer(),) })); + assert!(({ operator_eq_13(v1.as_pointer(), v2.as_pointer(),) })); + assert!(!({ operator_eq_13(v1.as_pointer(), v3.as_pointer(),) })); + assert!(!({ operator_eq_13(v1.as_pointer(), v3.as_pointer(),) })); return 0; } -impl WeaklyEqualityComparableWith for Defaulted { - fn equal(_a0: Ptr, _a1: Ptr) -> bool { - return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }) - && ({ _a0.with(|__s| __s.b) } == { _a1.with(|__s| __s.b) }); - } -} -impl WeaklyEqualityComparableWith for DefaultedOrd { - fn equal(_a0: Ptr, _a1: Ptr) -> bool { - return ({ _a0.with(|__s| __s.a) } == { _a1.with(|__s| __s.a) }); - } -} -impl WeaklyEqualityComparableWith for Inline { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); - } -} -impl WeaklyEqualityComparableWith for OutOfLine { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); - } - fn not_equal(x: Ptr, y: Ptr) -> bool { - return !({ WeaklyEqualityComparableWith::equal((x).clone(), (y).clone()) }); - } -} -impl WeaklyEqualityComparableWith for TmplDefaulted_int_ { - fn equal(_a0: Ptr, _a1: Ptr) -> bool { - return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); - } -} -impl WeaklyEqualityComparableWith for Tmpl_int_ { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ x.with(|__s| __s.v) } == { y.with(|__s| __s.v) }); - } -} -impl WeaklyEqualityComparableWith for Tmpl_long_ { - fn equal(lhs: Ptr, rhs: Ptr) -> bool { - >::equal(rhs, lhs) - } -} -impl WeaklyEqualityComparableWith for Tmpl_int_ { - fn equal(x: Ptr, y: Ptr) -> bool { - return ({ (x.with(|__s| __s.v) as i64) } == { y.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index d826279b55..d8caa71307 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -25,11 +25,19 @@ pub struct Lt { #[offset(0)] pub v: i32, } -impl LessThanComparable for Lt { - fn less(this: Ptr, o: Ptr) -> bool { +impl Lt { + pub fn operator_lt(this: Ptr, o: Ptr) -> bool { return ({ this.with(|__s| __s.v) } < { o.with(|__s| __s.v) }); } } +impl LessThanComparable for Lt { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Lt::operator_lt((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -49,6 +57,27 @@ pub struct Eq { #[offset(0)] pub v: i32, } +impl Eq { + pub fn operator_eq(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); + } +} +impl Cpp17EqualityComparable for Eq { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Eq { + type NotEqualResult = bool; + fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, @@ -60,25 +89,91 @@ pub struct Eq { TriviallyDefaultConstructible, TriviallyCopyable, Default, - LessThanComparable, - PartiallyOrderedWith, + Conversions, )] -#[three_way(ThreeWayComparable::three_way)] -#[derive(Conversions)] #[conversions(copy, move)] #[byte_size(4)] pub struct Cmp { #[offset(0)] pub v: i32, } -impl ThreeWayComparable for Cmp { - type Category = libcc2rs::StrongOrdering; - fn three_way(this: Ptr, o: Ptr) -> libcc2rs::StrongOrdering { +impl Cmp { + pub fn operator_cmp(this: Ptr, o: Ptr) -> libcc2rs::StrongOrdering { return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &(this.with(|__s| __s.v)), &(o.with(|__s| __s.v)), )); } + pub fn operator_eq(this: Ptr, o: Ptr) -> bool { + return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); + } +} +impl Cpp17EqualityComparable for Cmp { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Cmp { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Cmp { + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl PartiallyOrderedWith for Cmp { + type LessResult = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterResult = bool; + fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type LessEqualResult = bool; + fn less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::LessEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } + type GreaterEqualResult = bool; + fn greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::GreaterEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); + } +} +impl ThreeWayComparable for Cmp { + type Category = libcc2rs::StrongOrdering; + fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }); + } } #[derive( Copy, @@ -99,11 +194,45 @@ pub struct Free { #[offset(0)] pub v: i32, } +impl Cpp17EqualityComparable for Free { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Free { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); + } +} impl LessThanComparable for Free { - fn less(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); + type Result = bool; + fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); } } +pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); +} +pub fn operator_eq_0(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); +} +pub fn operator_eq_2(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); +} +pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { + return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); +} #[derive( Copy, Clone, @@ -123,6 +252,39 @@ pub struct Wrapped_int_ { #[offset(0)] pub v: i32, } +impl Cpp17EqualityComparable for Wrapped_int_ { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for Wrapped_int_ { + type NotEqualResult = bool; + fn not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::NotEqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); + } +} +impl LessThanComparable for Wrapped_int_ { + type Result = bool; + fn less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Result { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -157,12 +319,17 @@ fn main_0() -> i32 { ({ let __it: Value> = Rc::new(RefCell::new(eqs.decay().begin())); let __last: Value> = Rc::new(RefCell::new(eqs.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - two.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(two.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -175,12 +342,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new({ let __it: Value> = Rc::new(RefCell::new(eqs.decay().begin())); let __last: Value> = Rc::new(RefCell::new(eqs.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - nine.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value( + >::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(nine.as_pointer().clone()), + ), + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -189,7 +361,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(eqs.decay().end())).as_pointer(), ) { (__tmp_1, __tmp_2) => { - WeaklyEqualityComparableWith::equal((__tmp_1).clone(), (__tmp_2).clone()) + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + LvalueRef::>>::bind((__tmp_1).clone()), + LvalueRef::>>::bind((__tmp_2).clone()), + )) } }); let cmps: Value> = Rc::new(RefCell::new(Vec::from([ @@ -214,12 +389,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(cmps.decay().begin())); let __last: Value> = Rc::new(RefCell::new(cmps.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - three.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(three.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -244,12 +424,17 @@ fn main_0() -> i32 { Rc::new(RefCell::new(frees.decay().begin())); let __last: Value> = Rc::new(RefCell::new(frees.decay().end())); - while >::not_equal(__it.as_pointer(), __last.as_pointer()) - && !WeaklyEqualityComparableWith::equal( - __it.borrow().iter_deref(), - ftwo.as_pointer().clone(), - ) - { + while ConvertibleTo::::convert_value( + as WeaklyEqualityComparableWith>::not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ), + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(ftwo.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -293,19 +478,4 @@ fn main_0() -> i32 { ); return 0; } -impl WeaklyEqualityComparableWith for Cmp { - fn equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); - } -} -impl WeaklyEqualityComparableWith for Eq { - fn equal(this: Ptr, o: Ptr) -> bool { - return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); - } -} -impl WeaklyEqualityComparableWith for Free { - fn equal(a: Ptr, b: Ptr) -> bool { - return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); - } -} pub fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index 960e505af4..07dca2df96 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -23,6 +23,33 @@ pub struct Eq { pub a: i32, pub b: i32, } +impl Eq { + pub unsafe fn operator_eq(this: *const Self, _a0: *const Eq) -> bool { + return (((*this).a) == ((*_a0).a)) && (((*this).b) == ((*_a0).b)); + } +} +impl Cpp17EqualityComparableUnsafe for Eq { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Eq { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, @@ -33,19 +60,15 @@ pub struct Eq { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct Cmp { pub a: i32, pub b: i32, } -impl ThreeWayComparableUnsafe for Cmp { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const Cmp) -> libcc2rs::StrongOrdering { +impl Cmp { + pub unsafe fn operator_cmp(this: *const Self, _a0: *const Cmp) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).a), &((*_a0).a))); @@ -62,6 +85,91 @@ impl ThreeWayComparableUnsafe for Cmp { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq(this: *const Self, _a0: *const Cmp) -> bool { + return (((*this).a) == ((*_a0).a)) && (((*this).b) == ((*_a0).b)); + } +} +impl Cpp17EqualityComparableUnsafe for Cmp { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Cmp { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for Cmp { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for Cmp { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for Cmp { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }); + } } #[repr(C)] #[derive( @@ -73,18 +181,17 @@ impl ThreeWayComparableUnsafe for Cmp { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct Both { pub a: i32, } -impl ThreeWayComparableUnsafe for Both { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const Both) -> libcc2rs::StrongOrdering { +impl Both { + pub unsafe fn operator_eq(this: *const Self, _a0: *const Both) -> bool { + return (((*this).a) == ((*_a0).a)); + } + pub unsafe fn operator_cmp(this: *const Self, _a0: *const Both) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).a), &((*_a0).a))); @@ -95,6 +202,88 @@ impl ThreeWayComparableUnsafe for Both { return libcc2rs::STRONG_ORDERING_EQUAL; } } +impl Cpp17EqualityComparableUnsafe for Both { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return (unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Both { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return !(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for Both { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for Both { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return libcc2rs::is_gt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return libcc2rs::is_lteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return libcc2rs::is_gteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for Both { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + return (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, @@ -105,11 +294,8 @@ impl ThreeWayComparableUnsafe for Both { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(OrdOnly::operator_cmp)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct OrdOnly { pub a: i32, @@ -126,6 +312,55 @@ impl OrdOnly { return libcc2rs::STRONG_ORDERING_EQUAL; } } +impl LessThanComparableUnsafe for OrdOnly { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for OrdOnly { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + return libcc2rs::is_gt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + return libcc2rs::is_lteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + return libcc2rs::is_gteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} #[repr(C)] #[derive( Copy, @@ -136,18 +371,14 @@ impl OrdOnly { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct Inner { pub x: i32, } -impl ThreeWayComparableUnsafe for Inner { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const Inner) -> libcc2rs::StrongOrdering { +impl Inner { + pub unsafe fn operator_cmp(this: *const Self, _a0: *const Inner) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).x), &((*_a0).x))); @@ -157,6 +388,91 @@ impl ThreeWayComparableUnsafe for Inner { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq(this: *const Self, _a0: *const Inner) -> bool { + return (((*this).x) == ((*_a0).x)); + } +} +impl Cpp17EqualityComparableUnsafe for Inner { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return (unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Inner { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return !(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for Inner { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for Inner { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return libcc2rs::is_gt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return libcc2rs::is_lteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return libcc2rs::is_gteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for Inner { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + return (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }); + } } #[repr(C)] #[derive( @@ -168,23 +484,19 @@ impl ThreeWayComparableUnsafe for Inner { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct Outer { pub i: Inner, pub y: i32, } -impl ThreeWayComparableUnsafe for Outer { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const Outer) -> libcc2rs::StrongOrdering { +impl Outer { + pub unsafe fn operator_cmp(this: *const Self, _a0: *const Outer) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = (unsafe { let _arg0: *const Inner = &(*_a0).i; - ThreeWayComparableUnsafe::three_way(&raw const (*this).i, _arg0) + Inner::operator_cmp(&raw const (*this).i, _arg0) }); if !(libcc2rs::is_eq(cmp)) { return cmp; @@ -199,6 +511,94 @@ impl ThreeWayComparableUnsafe for Outer { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq(this: *const Self, _a0: *const Outer) -> bool { + return (unsafe { + let _arg0: *const Inner = &(*_a0).i; + Inner::operator_eq(&raw const (*this).i, _arg0) + }) && (((*this).y) == ((*_a0).y)); + } +} +impl Cpp17EqualityComparableUnsafe for Outer { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return (unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Outer { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return !(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for Outer { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for Outer { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return libcc2rs::is_gt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return libcc2rs::is_lteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return libcc2rs::is_gteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for Outer { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + return (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }); + } } #[repr(C)] #[derive( @@ -216,9 +616,17 @@ impl ThreeWayComparableUnsafe for Outer { pub struct Secondary { pub a: i32, } -impl ThreeWayComparableUnsafe for Secondary { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const Secondary) -> libcc2rs::StrongOrdering { +impl Secondary { + pub unsafe fn operator_eq(this: *const Self, _a0: *const Secondary) -> bool { + return (((*this).a) == ((*_a0).a)); + } + pub unsafe fn operator_ne(this: *const Self, _a0: *const Secondary) -> bool { + return !(unsafe { Secondary::operator_eq(&raw const (*this), _a0) }); + } + pub unsafe fn operator_cmp( + this: *const Self, + _a0: *const Secondary, + ) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).a), &((*_a0).a))); @@ -228,12 +636,93 @@ impl ThreeWayComparableUnsafe for Secondary { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_lt(this: *const Self, _a0: *const Secondary) -> bool { + return libcc2rs::is_lt((unsafe { Secondary::operator_cmp(&raw const (*this), _a0) })); + } + pub unsafe fn operator_ge(this: *const Self, _a0: *const Secondary) -> bool { + return libcc2rs::is_gteq((unsafe { Secondary::operator_cmp(&raw const (*this), _a0) })); + } +} +impl Cpp17EqualityComparableUnsafe for Secondary { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Secondary { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs) }); + } } impl LessThanComparableUnsafe for Secondary { - unsafe fn less(this: *const Self, _a0: *const Secondary) -> bool { - return libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const (*this), _a0) }), - ); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); + } +} +impl PartiallyOrderedWithUnsafe for Secondary { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return libcc2rs::is_gt((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return libcc2rs::is_lteq((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs) }); + } +} +impl ThreeWayComparableUnsafe for Secondary { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + return (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }); } } #[repr(C)] @@ -246,18 +735,17 @@ impl LessThanComparableUnsafe for Secondary { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct PtrMember { pub p: *mut i32, } -impl ThreeWayComparableUnsafe for PtrMember { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, _a0: *const PtrMember) -> libcc2rs::StrongOrdering { +impl PtrMember { + pub unsafe fn operator_cmp( + this: *const Self, + _a0: *const PtrMember, + ) -> libcc2rs::StrongOrdering { { let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).p), &((*_a0).p))); @@ -267,6 +755,91 @@ impl ThreeWayComparableUnsafe for PtrMember { } return libcc2rs::STRONG_ORDERING_EQUAL; } + pub unsafe fn operator_eq(this: *const Self, _a0: *const PtrMember) -> bool { + return (((*this).p) == ((*_a0).p)); + } +} +impl Cpp17EqualityComparableUnsafe for PtrMember { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return (unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for PtrMember { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return !(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for PtrMember { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for PtrMember { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return libcc2rs::is_gt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return libcc2rs::is_lteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return libcc2rs::is_gteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl ThreeWayComparableUnsafe for PtrMember { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + return (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }); + } } pub fn main() { unsafe { @@ -278,28 +851,27 @@ unsafe fn main_0() -> i32 { let mut e1: Eq = Eq { a: 1, b: 2 }; let mut e2: Eq = Eq { a: 1, b: 2 }; let mut e3: Eq = Eq { a: 1, b: 3 }; - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const e1, &e2,) })); - assert!(!(unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const e1, &e3,) })); + assert!((unsafe { Eq::operator_eq(&raw const e1, &e2,) })); + assert!(!(unsafe { Eq::operator_eq(&raw const e1, &e3,) })); let mut c1: Cmp = Cmp { a: 1, b: 2 }; let mut c2: Cmp = Cmp { a: 1, b: 3 }; let mut c3: Cmp = Cmp { a: 2, b: 0 }; let mut c4: Cmp = Cmp { a: 1, b: 9 }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const c1, &c2,) }) + (unsafe { Cmp::operator_cmp(&raw const c1, &c2,) }) )); assert!(libcc2rs::is_gt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const c3, &c4,) }) + (unsafe { Cmp::operator_cmp(&raw const c3, &c4,) }) )); assert!( (unsafe { let _arg0: *const Cmp = &c1; - WeaklyEqualityComparableWithUnsafe::equal(&raw const c1, _arg0) + Cmp::operator_eq(&raw const c1, _arg0) }) ); assert!({ - let __a = libcc2rs::PartialOrdering::from( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const c1, &c2) }), - ); + let __a = + libcc2rs::PartialOrdering::from((unsafe { Cmp::operator_cmp(&raw const c1, &c2) })); let __b = libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_LESS); libcc2rs::is_lt(__a) == libcc2rs::is_lt(__b) && libcc2rs::is_eq(__a) == libcc2rs::is_eq(__b) @@ -308,12 +880,12 @@ unsafe fn main_0() -> i32 { let mut b1: Both = Both { a: 1 }; let mut b2: Both = Both { a: 2 }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const b1, &b2,) }) + (unsafe { Both::operator_cmp(&raw const b1, &b2,) }) )); assert!( (unsafe { let _arg0: *const Both = &b2; - WeaklyEqualityComparableWithUnsafe::equal(&raw const b2, _arg0) + Both::operator_eq(&raw const b2, _arg0) }) ); let mut o1: OrdOnly = OrdOnly { a: 1 }; @@ -342,13 +914,12 @@ unsafe fn main_0() -> i32 { y: 9, }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const x1, &x2,) }) + (unsafe { Outer::operator_cmp(&raw const x1, &x2,) }) )); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const x1, &x3,) })); + assert!((unsafe { Outer::operator_eq(&raw const x1, &x3,) })); assert!({ - let __a = libcc2rs::PartialOrdering::from( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const x2, &x1) }), - ); + let __a = + libcc2rs::PartialOrdering::from((unsafe { Outer::operator_cmp(&raw const x2, &x1) })); let __b = libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_GREATER); libcc2rs::is_lt(__a) == libcc2rs::is_lt(__b) && libcc2rs::is_eq(__a) == libcc2rs::is_eq(__b) @@ -356,10 +927,10 @@ unsafe fn main_0() -> i32 { }); let mut s1: Secondary = Secondary { a: 1 }; let mut s2: Secondary = Secondary { a: 2 }; - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::not_equal(&raw const s1, &s2,) })); - assert!((unsafe { LessThanComparableUnsafe::less(&raw const s1, &s2,) })); - assert!((unsafe { PartiallyOrderedWithUnsafe::greater_equal(&raw const s2, &s1,) })); - assert!(!(unsafe { LessThanComparableUnsafe::less(&raw const s2, &s1,) })); + assert!((unsafe { Secondary::operator_ne(&raw const s1, &s2,) })); + assert!((unsafe { Secondary::operator_lt(&raw const s1, &s2,) })); + assert!((unsafe { Secondary::operator_ge(&raw const s2, &s1,) })); + assert!(!(unsafe { Secondary::operator_lt(&raw const s2, &s1,) })); let mut arr: [i32; 2] = [0, 0]; let mut p1: PtrMember = PtrMember { p: arr.as_mut_ptr(), @@ -371,12 +942,12 @@ unsafe fn main_0() -> i32 { p: arr.as_mut_ptr(), }; assert!(libcc2rs::is_lt( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const p1, &p2,) }) + (unsafe { PtrMember::operator_cmp(&raw const p1, &p2,) }) )); - assert!((unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const p1, &p3,) })); + assert!((unsafe { PtrMember::operator_eq(&raw const p1, &p3,) })); assert!({ let __a = libcc2rs::PartialOrdering::from( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const p2, &p1) }), + (unsafe { PtrMember::operator_cmp(&raw const p2, &p1) }), ); let __b = libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_GREATER); libcc2rs::is_lt(__a) == libcc2rs::is_lt(__b) @@ -385,61 +956,4 @@ unsafe fn main_0() -> i32 { }); return 0; } -impl PartiallyOrderedWithUnsafe for Secondary { - unsafe fn greater_equal(this: *const Self, _a0: *const Secondary) -> bool { - return libcc2rs::is_gteq( - (unsafe { ThreeWayComparableUnsafe::three_way(&raw const (*this), _a0) }), - ); - } - unsafe fn less(lhs: *const Self, rhs: *const Self) -> bool { - ::less(lhs, rhs) - } - unsafe fn greater(lhs: *const Self, rhs: *const Self) -> bool { - libcc2rs::is_gt(ThreeWayComparableUnsafe::three_way(lhs, rhs)) - } - unsafe fn less_equal(lhs: *const Self, rhs: *const Self) -> bool { - libcc2rs::is_lteq(ThreeWayComparableUnsafe::three_way(lhs, rhs)) - } -} -impl WeaklyEqualityComparableWithUnsafe for Both { - unsafe fn equal(this: *const Self, _a0: *const Both) -> bool { - return (((*this).a) == ((*_a0).a)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Cmp { - unsafe fn equal(this: *const Self, _a0: *const Cmp) -> bool { - return (((*this).a) == ((*_a0).a)) && (((*this).b) == ((*_a0).b)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Eq { - unsafe fn equal(this: *const Self, _a0: *const Eq) -> bool { - return (((*this).a) == ((*_a0).a)) && (((*this).b) == ((*_a0).b)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Inner { - unsafe fn equal(this: *const Self, _a0: *const Inner) -> bool { - return (((*this).x) == ((*_a0).x)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Outer { - unsafe fn equal(this: *const Self, _a0: *const Outer) -> bool { - return (unsafe { - let _arg0: *const Inner = &(*_a0).i; - WeaklyEqualityComparableWithUnsafe::equal(&raw const (*this).i, _arg0) - }) && (((*this).y) == ((*_a0).y)); - } -} -impl WeaklyEqualityComparableWithUnsafe for PtrMember { - unsafe fn equal(this: *const Self, _a0: *const PtrMember) -> bool { - return (((*this).p) == ((*_a0).p)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Secondary { - unsafe fn equal(this: *const Self, _a0: *const Secondary) -> bool { - return (((*this).a) == ((*_a0).a)); - } - unsafe fn not_equal(this: *const Self, _a0: *const Secondary) -> bool { - return !(unsafe { WeaklyEqualityComparableWithUnsafe::equal(&raw const (*this), _a0) }); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index 53db0128e1..a1b43366d0 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -327,14 +327,14 @@ impl PartiallyOrderedWithUnsafe for MyBool { } } impl ThreeWayComparableUnsafe for MyBool { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; unsafe fn three_way( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, ) -> Self::Category { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32), &((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32), )); @@ -501,14 +501,14 @@ impl PartiallyOrderedWithUnsafe for RefBool { } } impl ThreeWayComparableUnsafe for RefBool { - type Category = std_strong_ordering; + type Category = libcc2rs::StrongOrdering; unsafe fn three_way( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, ) -> Self::Category { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); - return std_strong_ordering::from(std::cmp::Ord::cmp( + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( &((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32), &((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32), )); diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 2aed80036c..945ec78f03 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -6,6 +6,9 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; +pub unsafe fn operator_eq_0(_a0: *const Defaulted, _a1: *const Defaulted) -> bool { + return (((*_a0).a) == ((*_a1).a)) && (((*_a0).b) == ((*_a1).b)); +} #[repr(C)] #[derive( Copy, @@ -23,21 +26,49 @@ pub struct Defaulted { pub a: i32, pub b: i32, } -impl ThreeWayComparableUnsafe for DefaultedOrd { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - _a0: *const DefaultedOrd, - _a1: *const DefaultedOrd, - ) -> libcc2rs::StrongOrdering { - { - let mut cmp: libcc2rs::StrongOrdering = - libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*_a0).a), &((*_a1).a))); - if !(libcc2rs::is_eq(cmp)) { - return cmp; - } +impl Cpp17EqualityComparableUnsafe for Defaulted { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Defaulted); + let __rhs = (__rhs.as_ptr() as *const Defaulted); + return (unsafe { + let _arg0: *const Defaulted = __lhs; + operator_eq_0(_arg0, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Defaulted { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Defaulted); + let __rhs = (__rhs.as_ptr() as *const Defaulted); + return !(unsafe { + let _arg0: *const Defaulted = __lhs; + operator_eq_0(_arg0, __rhs) + }); + } +} +pub unsafe fn operator_cmp_1( + _a0: *const DefaultedOrd, + _a1: *const DefaultedOrd, +) -> libcc2rs::StrongOrdering { + { + let mut cmp: libcc2rs::StrongOrdering = + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*_a0).a), &((*_a1).a))); + if !(libcc2rs::is_eq(cmp)) { + return cmp; } - return libcc2rs::STRONG_ORDERING_EQUAL; } + return libcc2rs::STRONG_ORDERING_EQUAL; +} +pub unsafe fn operator_eq_2(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) -> bool { + return (((*_a0).a) == ((*_a1).a)); } #[repr(C)] #[derive( @@ -49,21 +80,135 @@ impl ThreeWayComparableUnsafe for DefaultedOrd { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct DefaultedOrd { pub a: i32, } -impl LessThanComparableUnsafe for Inline { - unsafe fn less(x: *const Inline, y: *const Inline) -> bool { - return (((*x).a) < ((*y).a)); +impl Cpp17EqualityComparableUnsafe for DefaultedOrd { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_eq_2(_arg0, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for DefaultedOrd { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return !(unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_eq_2(_arg0, __rhs) + }); + } +} +impl LessThanComparableUnsafe for DefaultedOrd { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ); } } -pub unsafe fn operator_add_0(x: *const Inline, y: *const Inline) -> Inline { +impl PartiallyOrderedWithUnsafe for DefaultedOrd { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return libcc2rs::is_gt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return libcc2rs::is_lteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return libcc2rs::is_gteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ); + } +} +impl ThreeWayComparableUnsafe for DefaultedOrd { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + return (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }); + } +} +pub unsafe fn operator_eq_3(x: *const Inline, y: *const Inline) -> bool { + return (((*x).a) == ((*y).a)); +} +pub unsafe fn operator_lt_4(x: *const Inline, y: *const Inline) -> bool { + return (((*x).a) < ((*y).a)); +} +pub unsafe fn operator_add_5(x: *const Inline, y: *const Inline) -> Inline { return Inline { a: (((*x).a) + ((*y).a)), }; @@ -84,6 +229,48 @@ pub unsafe fn operator_add_0(x: *const Inline, y: *const Inline) -> Inline { pub struct Inline { pub a: i32, } +impl Cpp17EqualityComparableUnsafe for Inline { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + return (unsafe { + let _x: *const Inline = __lhs; + operator_eq_3(_x, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Inline { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + return !(unsafe { + let _x: *const Inline = __lhs; + operator_eq_3(_x, __rhs) + }); + } +} +impl LessThanComparableUnsafe for Inline { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + return (unsafe { + let _x: *const Inline = __lhs; + operator_lt_4(_x, __rhs) + }); + } +} #[repr(C)] #[derive( Copy, @@ -100,11 +287,52 @@ pub struct Inline { pub struct OutOfLine { pub a: i32, } -impl LessThanComparableUnsafe for Tmpl_int_ { - unsafe fn less(x: *const Tmpl_int_, y: *const Tmpl_int_) -> bool { - return (((*x).v) < ((*y).v)); +impl Cpp17EqualityComparableUnsafe for OutOfLine { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const OutOfLine); + let __rhs = (__rhs.as_ptr() as *const OutOfLine); + return (unsafe { + let _x: *const OutOfLine = __lhs; + operator_eq_6(_x, __rhs) + }); } } +impl WeaklyEqualityComparableWithUnsafe for OutOfLine { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const OutOfLine); + let __rhs = (__rhs.as_ptr() as *const OutOfLine); + return (unsafe { + let _x: *const OutOfLine = __lhs; + operator_ne_7(_x, __rhs) + }); + } +} +pub unsafe fn operator_eq_6(x: *const OutOfLine, y: *const OutOfLine) -> bool { + return (((*x).a) == ((*y).a)); +} +pub unsafe fn operator_ne_7(x: *const OutOfLine, y: *const OutOfLine) -> bool { + return !(unsafe { + let _x: *const OutOfLine = x; + operator_eq_6(_x, y) + }); +} +pub unsafe fn operator_eq_8(x: *const Tmpl_int_, y: *const Tmpl_int_) -> bool { + return (((*x).v) == ((*y).v)); +} +pub unsafe fn operator_lt_9(x: *const Tmpl_int_, y: *const Tmpl_int_) -> bool { + return (((*x).v) < ((*y).v)); +} +pub unsafe fn operator_eq_10(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool { + return (((*x).v as i64) == ((*y).v)); +} #[repr(C)] #[derive( Copy, @@ -121,6 +349,54 @@ impl LessThanComparableUnsafe for Tmpl_int_ { pub struct Tmpl_int_ { pub v: i32, } +impl Cpp17EqualityComparableUnsafe for Tmpl_int_ { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + return (unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_eq_8(_x, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + return !(unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_eq_8(_x, __rhs) + }); + } +} +impl LessThanComparableUnsafe for Tmpl_int_ { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + return (unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_lt_9(_x, __rhs) + }); + } +} +pub unsafe fn operator_eq_11(x: *const Tmpl_long_, y: *const Tmpl_long_) -> bool { + return (((*x).v) == ((*y).v)); +} +pub unsafe fn operator_lt_12(x: *const Tmpl_long_, y: *const Tmpl_long_) -> bool { + return (((*x).v) < ((*y).v)); +} #[repr(C)] #[derive( Copy, @@ -137,6 +413,54 @@ pub struct Tmpl_int_ { pub struct Tmpl_long_ { pub v: i64, } +impl Cpp17EqualityComparableUnsafe for Tmpl_long_ { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + return (unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_eq_11(_x, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Tmpl_long_ { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + return !(unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_eq_11(_x, __rhs) + }); + } +} +impl LessThanComparableUnsafe for Tmpl_long_ { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + return (unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_lt_12(_x, __rhs) + }); + } +} +pub unsafe fn operator_eq_13( + _a0: *const TmplDefaulted_int_, + _a1: *const TmplDefaulted_int_, +) -> bool { + return (((*_a0).v) == ((*_a1).v)); +} #[repr(C)] #[derive( Copy, @@ -153,6 +477,34 @@ pub struct Tmpl_long_ { pub struct TmplDefaulted_int_ { pub v: i32, } +impl Cpp17EqualityComparableUnsafe for TmplDefaulted_int_ { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); + let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); + return (unsafe { + let _arg0: *const TmplDefaulted_int_ = __lhs; + operator_eq_13(_arg0, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for TmplDefaulted_int_ { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); + let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); + return !(unsafe { + let _arg0: *const TmplDefaulted_int_ = __lhs; + operator_eq_13(_arg0, __rhs) + }); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -166,19 +518,19 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _arg0: *const Defaulted = &d1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &d2) + operator_eq_0(_arg0, &d2) }) ); assert!( !(unsafe { let _arg0: *const Defaulted = &d1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &d3) + operator_eq_0(_arg0, &d3) }) ); assert!( !(unsafe { let _arg0: *const Defaulted = &d1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &d3) + operator_eq_0(_arg0, &d3) }) ); let mut o1: DefaultedOrd = DefaultedOrd { a: 1 }; @@ -186,27 +538,27 @@ unsafe fn main_0() -> i32 { assert!(libcc2rs::is_lt( (unsafe { let _arg0: *const DefaultedOrd = &o1; - ThreeWayComparableUnsafe::three_way(_arg0, &o2) + operator_cmp_1(_arg0, &o2) }) )); assert!(libcc2rs::is_gt( (unsafe { let _arg0: *const DefaultedOrd = &o2; - ThreeWayComparableUnsafe::three_way(_arg0, &o1) + operator_cmp_1(_arg0, &o1) }) )); assert!( (unsafe { let _arg0: *const DefaultedOrd = &o1; let _arg1: *const DefaultedOrd = &o1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, _arg1) + operator_eq_2(_arg0, _arg1) }) ); assert!({ let __a = libcc2rs::PartialOrdering::from( (unsafe { let _arg0: *const DefaultedOrd = &o1; - ThreeWayComparableUnsafe::three_way(_arg0, &o2) + operator_cmp_1(_arg0, &o2) }), ); let __b = libcc2rs::PartialOrdering::from(libcc2rs::STRONG_ORDERING_LESS); @@ -220,35 +572,35 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const Inline = &i1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &i3) + operator_eq_3(_x, &i3) }) ); assert!( !(unsafe { let _x: *const Inline = &i1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &i2) + operator_eq_3(_x, &i2) }) ); assert!( (unsafe { let _x: *const Inline = &i1; - LessThanComparableUnsafe::less(_x, &i2) + operator_lt_4(_x, &i2) }) ); assert!( !(unsafe { let _x: *const Inline = &i2; - LessThanComparableUnsafe::less(_x, &i1) + operator_lt_4(_x, &i1) }) ); assert!( (unsafe { let mut _x: Inline = (unsafe { let _x: *const Inline = &i1; - operator_add_0(_x, &i2) + operator_add_5(_x, &i2) }); let mut _y: Inline = Inline { a: 3 }; - WeaklyEqualityComparableWithUnsafe::equal(&mut _x, &mut _y) + operator_eq_3(&mut _x, &mut _y) }) ); let mut f1: OutOfLine = OutOfLine { a: 4 }; @@ -257,19 +609,19 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const OutOfLine = &f1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &f2) + operator_eq_6(_x, &f2) }) ); assert!( (unsafe { let _x: *const OutOfLine = &f1; - WeaklyEqualityComparableWithUnsafe::not_equal(_x, &f3) + operator_ne_7(_x, &f3) }) ); assert!( !(unsafe { let _x: *const OutOfLine = &f1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &f3) + operator_eq_6(_x, &f3) }) ); let mut t1: Tmpl_int_ = Tmpl_int_ { v: 1 }; @@ -278,19 +630,19 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const Tmpl_int_ = &t1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &t3) + operator_eq_8(_x, &t3) }) ); assert!( !(unsafe { let _x: *const Tmpl_int_ = &t1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &t2) + operator_eq_8(_x, &t2) }) ); assert!( (unsafe { let _x: *const Tmpl_int_ = &t1; - LessThanComparableUnsafe::less(_x, &t2) + operator_lt_9(_x, &t2) }) ); let mut u1: Tmpl_long_ = Tmpl_long_ { v: 1_i64 }; @@ -298,13 +650,13 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _x: *const Tmpl_int_ = &t1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &u1) + operator_eq_10(_x, &u1) }) ); assert!( !(unsafe { let _x: *const Tmpl_int_ = &t1; - WeaklyEqualityComparableWithUnsafe::equal(_x, &u2) + operator_eq_10(_x, &u2) }) ); let mut v1: TmplDefaulted_int_ = TmplDefaulted_int_ { v: 7 }; @@ -313,67 +665,21 @@ unsafe fn main_0() -> i32 { assert!( (unsafe { let _arg0: *const TmplDefaulted_int_ = &v1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &v2) + operator_eq_13(_arg0, &v2) }) ); assert!( !(unsafe { let _arg0: *const TmplDefaulted_int_ = &v1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &v3) + operator_eq_13(_arg0, &v3) }) ); assert!( !(unsafe { let _arg0: *const TmplDefaulted_int_ = &v1; - WeaklyEqualityComparableWithUnsafe::equal(_arg0, &v3) + operator_eq_13(_arg0, &v3) }) ); return 0; } -impl WeaklyEqualityComparableWithUnsafe for Defaulted { - unsafe fn equal(_a0: *const Defaulted, _a1: *const Defaulted) -> bool { - return (((*_a0).a) == ((*_a1).a)) && (((*_a0).b) == ((*_a1).b)); - } -} -impl WeaklyEqualityComparableWithUnsafe for DefaultedOrd { - unsafe fn equal(_a0: *const DefaultedOrd, _a1: *const DefaultedOrd) -> bool { - return (((*_a0).a) == ((*_a1).a)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Inline { - unsafe fn equal(x: *const Inline, y: *const Inline) -> bool { - return (((*x).a) == ((*y).a)); - } -} -impl WeaklyEqualityComparableWithUnsafe for OutOfLine { - unsafe fn equal(x: *const OutOfLine, y: *const OutOfLine) -> bool { - return (((*x).a) == ((*y).a)); - } - unsafe fn not_equal(x: *const OutOfLine, y: *const OutOfLine) -> bool { - return !(unsafe { - let _x: *const OutOfLine = x; - WeaklyEqualityComparableWithUnsafe::equal(_x, y) - }); - } -} -impl WeaklyEqualityComparableWithUnsafe for TmplDefaulted_int_ { - unsafe fn equal(_a0: *const TmplDefaulted_int_, _a1: *const TmplDefaulted_int_) -> bool { - return (((*_a0).v) == ((*_a1).v)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { - unsafe fn equal(x: *const Tmpl_int_, y: *const Tmpl_int_) -> bool { - return (((*x).v) == ((*y).v)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Tmpl_long_ { - unsafe fn equal(lhs: *const Self, rhs: *const Tmpl_int_) -> bool { - >::equal(rhs, lhs) - } -} -impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { - unsafe fn equal(x: *const Tmpl_int_, y: *const Tmpl_long_) -> bool { - return (((*x).v as i64) == ((*y).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index b3d094d2a2..e549bf3572 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -22,11 +22,22 @@ use std::rc::Rc; pub struct Lt { pub v: i32, } -impl LessThanComparableUnsafe for Lt { - unsafe fn less(this: *const Self, o: *const Lt) -> bool { +impl Lt { + pub unsafe fn operator_lt(this: *const Self, o: *const Lt) -> bool { return (((*this).v) < ((*o).v)); } } +impl LessThanComparableUnsafe for Lt { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Lt); + let __rhs = (__rhs.as_ptr() as *const Lt); + return (unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, @@ -43,6 +54,33 @@ impl LessThanComparableUnsafe for Lt { pub struct Eq { pub v: i32, } +impl Eq { + pub unsafe fn operator_eq(this: *const Self, o: *const Eq) -> bool { + return (((*this).v) == ((*o).v)); + } +} +impl Cpp17EqualityComparableUnsafe for Eq { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Eq { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); + } +} #[repr(C)] #[derive( Copy, @@ -53,19 +91,100 @@ pub struct Eq { TriviallyDefaultConstructibleUnsafe, TriviallyCopyableUnsafe, Default, - LessThanComparableUnsafe, - PartiallyOrderedWithUnsafe, + ConversionsUnsafe, )] -#[three_way(ThreeWayComparableUnsafe::three_way)] -#[derive(ConversionsUnsafe)] #[conversions(copy, move)] pub struct Cmp { pub v: i32, } +impl Cmp { + pub unsafe fn operator_cmp(this: *const Self, o: *const Cmp) -> libcc2rs::StrongOrdering { + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).v), &((*o).v))); + } + pub unsafe fn operator_eq(this: *const Self, o: *const Cmp) -> bool { + return (((*this).v) == ((*o).v)); + } +} +impl Cpp17EqualityComparableUnsafe for Cmp { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Cmp { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl LessThanComparableUnsafe for Cmp { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} +impl PartiallyOrderedWithUnsafe for Cmp { + type LessResult = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterResult = bool; + unsafe fn greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::LessEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::GreaterEqualResult { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); + } +} impl ThreeWayComparableUnsafe for Cmp { type Category = libcc2rs::StrongOrdering; - unsafe fn three_way(this: *const Self, o: *const Cmp) -> libcc2rs::StrongOrdering { - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp(&((*this).v), &((*o).v))); + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + return (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }); } } #[repr(C)] @@ -84,11 +203,60 @@ impl ThreeWayComparableUnsafe for Cmp { pub struct Free { pub v: i32, } +impl Cpp17EqualityComparableUnsafe for Free { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + return (unsafe { + let _a: *const Free = __lhs; + operator_eq_0(_a, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Free { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + return !(unsafe { + let _a: *const Free = __lhs; + operator_eq_0(_a, __rhs) + }); + } +} impl LessThanComparableUnsafe for Free { - unsafe fn less(a: *const Free, b: *const Free) -> bool { - return (((*a).v) < ((*b).v)); + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + return (unsafe { + let _a: *const Free = __lhs; + operator_lt_1(_a, __rhs) + }); } } +pub unsafe fn operator_lt_1(a: *const Free, b: *const Free) -> bool { + return (((*a).v) < ((*b).v)); +} +pub unsafe fn operator_eq_0(a: *const Free, b: *const Free) -> bool { + return (((*a).v) == ((*b).v)); +} +pub unsafe fn operator_eq_2(a: *const Wrapped_int_, b: *const Wrapped_int_) -> bool { + return (((*a).v) == ((*b).v)); +} +pub unsafe fn operator_lt_3(a: *const Wrapped_int_, b: *const Wrapped_int_) -> bool { + return (((*a).v) < ((*b).v)); +} #[repr(C)] #[derive( Copy, @@ -105,6 +273,48 @@ impl LessThanComparableUnsafe for Free { pub struct Wrapped_int_ { pub v: i32, } +impl Cpp17EqualityComparableUnsafe for Wrapped_int_ { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + return (unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_eq_2(_a, __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for Wrapped_int_ { + type NotEqualResult = bool; + unsafe fn not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::NotEqualResult { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + return !(unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_eq_2(_a, __rhs) + }); + } +} +impl LessThanComparableUnsafe for Wrapped_int_ { + type Result = bool; + unsafe fn less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Result { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + return (unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_lt_3(_a, __rhs) + }); + } +} pub fn main() { unsafe { __cpp2rust_init_globals(); @@ -120,11 +330,19 @@ unsafe fn main_0() -> i32 { let __n = lts.end().iter_distance(&__tmp_0); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const _; - let __b = __tmp_0.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_0.iter_at(__x) as *const Lt; + let __b = __tmp_0.iter_at(__y) as *const Lt; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -149,9 +367,17 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { eqs.begin() }; let mut __tmp_2 = { eqs.end() }; let mut __it = (__tmp_1).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_2) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &two) - { + while ConvertibleToUnsafe::::convert_value( + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_2), + ), + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&two), + ), + ) { __it.iter_inc(); } __it @@ -159,19 +385,17 @@ unsafe fn main_0() -> i32 { .iter_deref()) .v) == (2)) ); - assert!(WeaklyEqualityComparableWithUnsafe::equal( - &{ - let mut __tmp_3 = { eqs.begin() }; - let mut __tmp_4 = { eqs.end() }; - let mut __it = (__tmp_3).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_4) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &nine) - { - __it.iter_inc(); - } - __it - }, - &eqs.end() + assert!(ConvertibleToUnsafe::::convert_value( + Cpp17EqualityComparableUnsafe::equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_3 = { eqs.begin() }; + let mut __tmp_4 = { eqs.end() }; + let mut __it = (__tmp_3).clone(); + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_4 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&nine ), ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind(&eqs.end()), + ) )); let mut cmps: Vec = Vec::from([Cmp { v: 3 }, Cmp { v: 1 }, Cmp { v: 2 }]); { @@ -179,11 +403,19 @@ unsafe fn main_0() -> i32 { let __n = cmps.end().iter_distance(&__tmp_5); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_5.iter_at(__x) as *const _; - let __b = __tmp_5.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_5.iter_at(__x) as *const Cmp; + let __b = __tmp_5.iter_at(__y) as *const Cmp; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -204,9 +436,17 @@ unsafe fn main_0() -> i32 { let mut __tmp_6 = { cmps.begin() }; let mut __tmp_7 = { cmps.end() }; let mut __it = (__tmp_6).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_7) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &three) - { + while ConvertibleToUnsafe::::convert_value( + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_7), + ), + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&three), + ), + ) { __it.iter_inc(); } __it @@ -220,11 +460,19 @@ unsafe fn main_0() -> i32 { let __n = frees.end().iter_distance(&__tmp_8); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_8.iter_at(__x) as *const _; - let __b = __tmp_8.iter_at(__y) as *const _; - if LessThanComparableUnsafe::less(__a, __b) { + let __a = __tmp_8.iter_at(__x) as *const Free; + let __b = __tmp_8.iter_at(__y) as *const Free; + if ConvertibleToUnsafe::::convert_value(::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + )) { std::cmp::Ordering::Less - } else if LessThanComparableUnsafe::less(__b, __a) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -245,9 +493,17 @@ unsafe fn main_0() -> i32 { let mut __tmp_9 = { frees.begin() }; let mut __tmp_10 = { frees.end() }; let mut __it = (__tmp_9).clone(); - while WeaklyEqualityComparableWithUnsafe::not_equal(&__it, &__tmp_10) - && !WeaklyEqualityComparableWithUnsafe::equal(&*__it.iter_deref(), &ftwo) - { + while ConvertibleToUnsafe::::convert_value( + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_10), + ), + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&ftwo), + ), + ) { __it.iter_inc(); } __it @@ -282,19 +538,4 @@ unsafe fn main_0() -> i32 { }; return 0; } -impl WeaklyEqualityComparableWithUnsafe for Cmp { - unsafe fn equal(this: *const Self, o: *const Cmp) -> bool { - return (((*this).v) == ((*o).v)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Eq { - unsafe fn equal(this: *const Self, o: *const Eq) -> bool { - return (((*this).v) == ((*o).v)); - } -} -impl WeaklyEqualityComparableWithUnsafe for Free { - unsafe fn equal(a: *const Free, b: *const Free) -> bool { - return (((*a).v) == ((*b).v)); - } -} pub unsafe fn __cpp2rust_init_globals() {} From eb226bcb085917097d4673863671b4c24576107d Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:30:16 +0000 Subject: [PATCH 10/17] format --- cpp2rust/converter/converter_lib.cpp | 20 ++++++------ cpp2rust/converter/converter_lib.h | 4 +-- libcc2rs-macros/src/lib.rs | 1 - libcc2rs/src/cmp.rs | 48 +++++++++++++++++++++------- libcc2rs/src/fn_ptr.rs | 6 ++-- libcc2rs/src/void.rs | 6 ++-- rules/algorithm/tgt_unsafe.rs | 22 +++++++------ rules/iterator_category/shim.rs | 19 +++-------- rules/map/shim.rs | 4 +-- rules/pair/tgt_unsafe.rs | 10 +++--- 10 files changed, 80 insertions(+), 60 deletions(-) diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 60ad69b75b..30f299afc7 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -2348,8 +2348,8 @@ bool Comparisons::Has(const ComparisonTrait &trait) const { } bool SatisfiesComparisonTrait(const ComparisonTrait &trait, - const Comparisons &forward, - const Comparisons &reverse) { + const Comparisons &forward, + const Comparisons &reverse) { return forward.Has(trait) && (!trait.is_symmetric || reverse.Has(trait)); } @@ -2365,8 +2365,8 @@ BuildComparisons(clang::Sema &sema, clang::BlockDecl *context, ctx, context, loc, loc, &ctx.Idents.get(name), reference, ctx.getTrivialTypeSourceInfo(reference, loc), clang::SC_None); }; - Comparisons comparisons{lhs, rhs, operand("__lhs", lhs), - operand("__rhs", rhs), {}}; + Comparisons comparisons{ + lhs, rhs, operand("__lhs", lhs), operand("__rhs", rhs), {}}; auto refer = [&](clang::VarDecl *var) -> clang::Expr * { return clang::DeclRefExpr::Create(ctx, {}, {}, var, false, loc, var->getType().getNonReferenceType(), @@ -2375,18 +2375,18 @@ BuildComparisons(clang::Sema &sema, clang::BlockDecl *context, for (const auto *trait : traits) { for (const auto &relation : trait->relations) { if (!comparisons.exprs.contains(relation.op)) { - comparisons.exprs.emplace( - relation.op, BuildComparison(sema, relation.op, - refer(comparisons.lhs), - refer(comparisons.rhs))); + comparisons.exprs.emplace(relation.op, + BuildComparison(sema, relation.op, + refer(comparisons.lhs), + refer(comparisons.rhs))); } } } return comparisons; } -const RecordComparisons &GetRecordComparisons(clang::Sema &sema, - const clang::CXXRecordDecl *decl) { +const RecordComparisons & +GetRecordComparisons(clang::Sema &sema, const clang::CXXRecordDecl *decl) { static std::unordered_map built; decl = decl->getCanonicalDecl(); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 5ac5234606..69746d3992 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -279,8 +279,8 @@ inline constexpr const ComparisonTrait *kHeterogeneousComparisonTraits[] = { &kPartiallyOrderedWith}; bool SatisfiesComparisonTrait(const ComparisonTrait &trait, - const Comparisons &forward, - const Comparisons &reverse); + const Comparisons &forward, + const Comparisons &reverse); const RecordComparisons &GetRecordComparisons(clang::Sema &sema, const clang::CXXRecordDecl *decl); diff --git a/libcc2rs-macros/src/lib.rs b/libcc2rs-macros/src/lib.rs index cfc75e1e79..bac10e9491 100644 --- a/libcc2rs-macros/src/lib.rs +++ b/libcc2rs-macros/src/lib.rs @@ -359,4 +359,3 @@ pub fn derive_destructible(input: TokenStream) -> TokenStream { pub fn derive_destructible_unsafe(input: TokenStream) -> TokenStream { destructor::expand(input, true) } - diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index b1fed6f006..9bdb12f752 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -30,8 +30,10 @@ pub trait LessThanComparableUnsafe: Sized { /// # Safety /// `a` and `b` must refer to live values. - unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) - -> Self::Result; + unsafe fn less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::Result; } pub trait Cpp17EqualityComparable: ByteRepr + Sized { @@ -45,8 +47,10 @@ pub trait Cpp17EqualityComparableUnsafe: Sized { /// # Safety /// `a` and `b` must refer to live values. - unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) - -> Self::EqualResult; + unsafe fn equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::EqualResult; } pub trait WeaklyEqualityComparableWith = Self>: @@ -231,11 +235,17 @@ impl LessThanComparableUnsafe for Vec { let (m, n) = ((*a).len(), (*b).len()); let (a, b) = ((*a).as_ptr(), (*b).as_ptr()); for i in 0..m.min(n) { - let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(a.add(i)), + LvalueRefUnsafe::bind(b.add(i)), + ); if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return true; } - let (x, y) = (LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(b.add(i)), + LvalueRefUnsafe::bind(a.add(i)), + ); if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return false; } @@ -252,11 +262,17 @@ impl LessThanComparableUnsafe for [ let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); for i in 0..N { unsafe { - let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(a.add(i)), + LvalueRefUnsafe::bind(b.add(i)), + ); if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return true; } - let (x, y) = (LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(b.add(i)), + LvalueRefUnsafe::bind(a.add(i)), + ); if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { return false; } @@ -488,7 +504,10 @@ impl Cpp17EqualityComparableUnsafe for Vec } let (a, b) = ((*a).as_ptr(), (*b).as_ptr()); (0..len).all(|i| { - let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(a.add(i)), + LvalueRefUnsafe::bind(b.add(i)), + ); ConvertibleToUnsafe::::convert_value(T::equal(x, y)) }) } @@ -509,7 +528,10 @@ impl Cpp17EqualityComparableUn unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); (0..N).all(|i| unsafe { - let (x, y) = (LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i))); + let (x, y) = ( + LvalueRefUnsafe::bind(a.add(i)), + LvalueRefUnsafe::bind(b.add(i)), + ); ConvertibleToUnsafe::::convert_value(T::equal(x, y)) }) } @@ -580,8 +602,10 @@ pub trait PartiallyOrderedWithUnsafe = Self> /// # Safety /// `a` and `b` must refer to live values. - unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) - -> Self::LessResult; + unsafe fn less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> Self::LessResult; /// # Safety /// `a` and `b` must refer to live values. unsafe fn greater( diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index 12a4d12f6e..1a66995d8b 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -500,7 +500,8 @@ impl crate::Cpp17EqualityComparable for FnPtr { a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { - a.as_pointer().with(|a| b.as_pointer().with(|b| a.addr == b.addr)) + a.as_pointer() + .with(|a| b.as_pointer().with(|b| a.addr == b.addr)) } } @@ -511,7 +512,8 @@ impl crate::WeaklyEqualityComparableWith for FnPtr { a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { - a.as_pointer().with(|a| b.as_pointer().with(|b| a.addr != b.addr)) + a.as_pointer() + .with(|a| b.as_pointer().with(|b| a.addr != b.addr)) } } diff --git a/libcc2rs/src/void.rs b/libcc2rs/src/void.rs index 0163a1bb31..c99cc06802 100644 --- a/libcc2rs/src/void.rs +++ b/libcc2rs/src/void.rs @@ -155,7 +155,8 @@ impl crate::Cpp17EqualityComparable for AnyPtr { a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { - a.as_pointer().with(|a| b.as_pointer().with(|b| *a.ptr == *b.ptr)) + a.as_pointer() + .with(|a| b.as_pointer().with(|b| *a.ptr == *b.ptr)) } } @@ -166,7 +167,8 @@ impl crate::WeaklyEqualityComparableWith for AnyPtr { a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { - a.as_pointer().with(|a| b.as_pointer().with(|b| *a.ptr != *b.ptr)) + a.as_pointer() + .with(|a| b.as_pointer().with(|b| *a.ptr != *b.ptr)) } } diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 50377541a0..984bf10fba 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -16,10 +16,12 @@ unsafe fn f1, T2: LessThanComparableUnsafe LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -80,12 +82,12 @@ unsafe fn f3, T2, T3: Cpp17EqualityComparableUnsa LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&a1), ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&a2), - ), - ) { + ) && !ConvertibleToUnsafe::::convert_value(>::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&a2), + )) { __it.iter_inc(); } __it diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index fd949f8ccc..bf4b7452fd 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -225,13 +225,8 @@ macro_rules! uninhabited_iterator { } } - impl crate::ConstructorUnsafe<(LvalueRefUnsafe>,)> - for $name - { - unsafe fn constructor( - _: *mut Self, - (src,): (LvalueRefUnsafe>,), - ) { + impl crate::ConstructorUnsafe<(LvalueRefUnsafe>,)> for $name { + unsafe fn constructor(_: *mut Self, (src,): (LvalueRefUnsafe>,)) { unsafe { (*src.as_const_ptr()).never() } } } @@ -643,10 +638,7 @@ impl PartiallyOrderedWith for RandomAccessIterator { impl crate::Cpp17EqualityComparableUnsafe for UnsafeRandomAccessIterator { type EqualResult = bool; - unsafe fn equal( - this: LvalueRefUnsafe>, - rhs: LvalueRefUnsafe>, - ) -> bool { + unsafe fn equal(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a == b, @@ -674,10 +666,7 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { type GreaterResult = bool; type LessEqualResult = bool; type GreaterEqualResult = bool; - unsafe fn less( - this: LvalueRefUnsafe>, - rhs: LvalueRefUnsafe>, - ) -> bool { + unsafe fn less(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a < b, diff --git a/rules/map/shim.rs b/rules/map/shim.rs index e5365c978a..204a720d4f 100644 --- a/rules/map/shim.rs +++ b/rules/map/shim.rs @@ -11,8 +11,8 @@ use crate::{ AsPointer, BidirectionalIterator, ByteRepr, Const, Constructor, ConstructorUnsafe, ConvertibleToUnsafe, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, LessThanComparable, LessThanComparableUnsafe, LvalueRef, - LvalueRefUnsafe, Ptr, UnsafeBidirectionalIterator, Value, ZeroInitialization, - copy_constructed, copy_constructed_unsafe, cpp_cmp, + LvalueRefUnsafe, Ptr, UnsafeBidirectionalIterator, Value, ZeroInitialization, copy_constructed, + copy_constructed_unsafe, cpp_cmp, }; impl ByteRepr for BTreeMap {} diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index c69d1bd22f..05c8f603f3 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -210,10 +210,12 @@ unsafe fn f28, T2: Cpp17EqualityComparable !(ConvertibleToUnsafe::::convert_value(::equal( LvalueRefUnsafe::>::bind(&a0.0), LvalueRefUnsafe::>::bind(&a1.0), - )) && ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(&a0.1), - LvalueRefUnsafe::>::bind(&a1.1), - ))) + )) && ConvertibleToUnsafe::::convert_value( + ::equal( + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), + ), + )) } unsafe fn f29( From b5fceaedfbed925f572321032180fcd43d87d560 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:34:24 +0000 Subject: [PATCH 11/17] Rename --- libcc2rs/src/overload.rs | 40 +++++++++---------- .../out/unsafe/concept.equalitycomparable.rs | 2 +- .../utilities/pairs/out/unsafe/pairs.pair.rs | 6 +-- tests/unit/out/unsafe/find.rs | 10 ++--- tests/unit/out/unsafe/operator_traits.rs | 2 +- tests/unit/out/unsafe/size_t_ssize_t.rs | 2 +- tests/unit/out/unsafe/sort_no_copy.rs | 2 +- .../unsafe/unboxed_conditional_iterator.rs | 2 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/libcc2rs/src/overload.rs b/libcc2rs/src/overload.rs index 71f7440e2e..1f182a91e7 100644 --- a/libcc2rs/src/overload.rs +++ b/libcc2rs/src/overload.rs @@ -112,7 +112,7 @@ pub trait ConstructibleFrom: Sized { impl ConstructibleFrom for T { fn construct(this: Ptr, args: Args) { - initialize(&T::table(), this.to_any(), &args.as_args(), true); + initialize(&T::table(), this.to_any(), &args.into_args(), true); } } @@ -133,7 +133,7 @@ pub trait ConvertibleTo: Sized { impl ConvertibleTo for From { fn convert(self, to: Ptr) { - initialize(&To::table(), to.to_any(), &[self.as_arg()], false); + initialize(&To::table(), to.to_any(), &[self.into_arg()], false); } } @@ -145,7 +145,7 @@ pub trait ConstructibleFromUnsafe: Sized { impl ConstructibleFromUnsafe for T { unsafe fn construct(this: *mut T, args: Args) { - initialize(&T::table(), this.cast(), &args.as_args(), true); + initialize(&T::table(), this.cast(), &args.into_args(), true); } } @@ -170,16 +170,16 @@ pub trait ConvertibleToUnsafe: Sized { impl ConvertibleToUnsafe for From { unsafe fn convert(self, to: *mut To) { - initialize(&To::table(), to.cast(), &[self.as_arg()], false); + initialize(&To::table(), to.cast(), &[self.into_arg()], false); } } pub trait AsArg { - fn as_arg(self) -> Arg; + fn into_arg(self) -> Arg; } impl AsArg for T { - fn as_arg(self) -> Arg { + fn into_arg(self) -> Arg { let object: crate::rc::Value = std::rc::Rc::new(std::cell::RefCell::new(self)); let ptr = crate::rc::AsPointer::::as_pointer(&object); Arg { @@ -190,29 +190,29 @@ impl AsArg for T { } impl AsArg for LvalueRef { - fn as_arg(self) -> Arg { + fn into_arg(self) -> Arg { Arg::lvalue(self.as_pointer()) } } impl AsArg for LvalueRef> { - fn as_arg(self) -> Arg { + fn into_arg(self) -> Arg { Arg::const_lvalue(self.as_pointer()) } } impl AsArg for RvalueRef { - fn as_arg(self) -> Arg { + fn into_arg(self) -> Arg { Arg::rvalue(self.as_pointer()) } } pub trait AsArgUnsafe { - fn as_arg(self) -> Arg<*mut c_void>; + fn into_arg(self) -> Arg<*mut c_void>; } impl AsArgUnsafe for T { - fn as_arg(self) -> Arg<*mut c_void> { + fn into_arg(self) -> Arg<*mut c_void> { let mut object = Box::new(self); let ptr: *mut T = &raw mut *object; Arg { @@ -223,19 +223,19 @@ impl AsArgUnsafe for T { } impl AsArgUnsafe for LvalueRefUnsafe { - fn as_arg(self) -> Arg<*mut c_void> { + fn into_arg(self) -> Arg<*mut c_void> { Arg::lvalue_unsafe(self.as_ptr()) } } impl AsArgUnsafe for LvalueRefUnsafe> { - fn as_arg(self) -> Arg<*mut c_void> { + fn into_arg(self) -> Arg<*mut c_void> { Arg::const_lvalue_unsafe(self.as_const_ptr()) } } impl AsArgUnsafe for RvalueRefUnsafe { - fn as_arg(self) -> Arg<*mut c_void> { + fn into_arg(self) -> Arg<*mut c_void> { Arg::rvalue_unsafe(self.as_ptr()) } } @@ -481,28 +481,28 @@ impl ParameterUnsafe for RvalueRefUnsafe> { } pub trait ArgList { - fn as_args(self) -> Vec>; + fn into_args(self) -> Vec>; } pub trait ArgListUnsafe { - fn as_args(self) -> Vec>; + fn into_args(self) -> Vec>; } macro_rules! arg_list { ($($name:ident),*) => { impl<$($name: AsArg),*> ArgList for ($($name,)*) { #[allow(non_snake_case, clippy::vec_init_then_push)] - fn as_args(self) -> Vec> { + fn into_args(self) -> Vec> { let ($($name,)*) = self; - vec![$($name.as_arg()),*] + vec![$($name.into_arg()),*] } } impl<$($name: AsArgUnsafe),*> ArgListUnsafe for ($($name,)*) { #[allow(non_snake_case, clippy::vec_init_then_push)] - fn as_args(self) -> Vec> { + fn into_args(self) -> Vec> { let ($($name,)*) = self; - vec![$($name.as_arg()),*] + vec![$($name.into_arg()),*] } } }; diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 6247b064da..3b42e6b6c4 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -272,7 +272,7 @@ pub unsafe fn test_3() { let mut __tmp_2 = { lengths.begin() }; let mut __tmp_3 = { lengths.end() }; let mut __it = (__tmp_2).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), )) { __it.iter_inc(); } __it } ), diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index e25948f17c..1f8dba0c8e 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -181,7 +181,7 @@ pub unsafe fn test_4() { ::equal( LvalueRefUnsafe::>::bind(&a.1), LvalueRefUnsafe::>::bind(&b.1), - ) + ), )) ); assert!( @@ -194,7 +194,7 @@ pub unsafe fn test_4() { ::equal( LvalueRefUnsafe::>::bind(&a.1), LvalueRefUnsafe::>::bind(&a.1), - ) + ), ))) ); assert!(ConvertibleToUnsafe::::convert_value( @@ -339,7 +339,7 @@ pub unsafe fn test_7() { ::equal( LvalueRefUnsafe::>::bind(&to_x.1), LvalueRefUnsafe::>::bind(&to_y.1), - ) + ), )) ); } diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 755c9a0f33..a0389c4cc8 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -119,7 +119,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_7 = { v.begin() }; let mut __tmp_8 = { v.begin() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&v.begin()), @@ -132,7 +132,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_9 = { w.begin().iter_add(2_isize) }; let mut __tmp_10 = { w.end() }; let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( @@ -146,7 +146,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_11 = { w.begin().iter_add(2_isize) }; let mut __tmp_12 = { w.end() }; let mut __it = (__tmp_11).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&w.end()), @@ -158,7 +158,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_13 = { w.begin().iter_add(2_isize) }; let mut __tmp_14 = { w.begin().iter_add(4_isize) }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( @@ -173,7 +173,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_15 = { p.begin() }; let mut __tmp_16 = { p.end() }; let mut __it = (__tmp_15).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index e549bf3572..cbd6e1f458 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -391,7 +391,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { eqs.begin() }; let mut __tmp_4 = { eqs.end() }; let mut __it = (__tmp_3).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_4 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&nine ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_4 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&nine ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&eqs.end()), diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index e356bc779e..83aef3089c 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -319,7 +319,7 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_13 = { v3.begin() }; let mut __tmp_14 = { v3.end() }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&v3.end()), diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index 19e6f6c79d..f25877c892 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -531,7 +531,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_7 = { bag_vec.begin() }; let mut __tmp_8 = { bag_vec.end() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), )) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index 39b69fb06d..3aa499a652 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -55,7 +55,7 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) let mut __tmp_0 = { items.begin() }; let mut __tmp_1 = { items.end() }; let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), )) { __it.iter_inc(); } __it }; assert!(ConvertibleToUnsafe::::convert_value( From 2ca8947f992bcc80d647ca0c831e3ca6a8583948 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:54:35 +0000 Subject: [PATCH 12/17] Return bool from is_less, is_greter, etc --- cpp2rust/converter/converter.cpp | 93 ++-- cpp2rust/converter/converter.h | 10 + cpp2rust/converter/converter_lib.cpp | 25 +- cpp2rust/converter/converter_lib.h | 18 +- .../converter/models/converter_refcount.cpp | 5 + .../converter/models/converter_refcount.h | 2 + cpp2rust/converter/rules/rules_loader.cpp | 8 +- libcc2rs/src/cmp.rs | 449 +++++++++++++++--- libcc2rs/src/fn_ptr.rs | 34 ++ libcc2rs/src/reference.rs | 135 +++++- libcc2rs/src/void.rs | 16 + rules/algorithm/tgt_refcount.rs | 50 +- rules/algorithm/tgt_unsafe.rs | 98 ++-- rules/iterator_category/shim.rs | 176 ++++++- rules/iterator_category/tgt_refcount.rs | 28 +- rules/iterator_category/tgt_unsafe.rs | 28 +- rules/map/shim.rs | 14 +- rules/pair/tgt_refcount.rs | 28 +- rules/pair/tgt_unsafe.rs | 32 +- rules/vector/tgt_refcount.rs | 8 +- rules/vector/tgt_unsafe.rs | 16 +- 21 files changed, 961 insertions(+), 312 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 6b69b53b46..6026aba320 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -1647,18 +1647,7 @@ bool Converter::VisitReturnStmt(clang::ReturnStmt *stmt) { ScopedValue return_value(return_value_, stmt->getRetValue()); auto return_type = curr_function_->getReturnType(); if (auto *value = stmt->getRetValue(); value && UsesReturnSlot(return_type)) { - std::string_view slot = "__return"; - if (auto *construct = GetPlacementInitializer(value)) { - ConstructInPlace(value, construct, GetReturnSlotReceiver(slot)); - } else { - HoistMaterializedTempBindings hoist_temps(*this); - StrCat(slot, ".write"); - { - PushParen paren(*this); - ConvertVarInit(return_type, value); - } - StrCat(token::kSemiColon); - } + InitializeReturnSlot(return_type, value); StrCat(keyword::kReturn, token::kSemiColon); return false; } @@ -1673,6 +1662,25 @@ bool Converter::VisitReturnStmt(clang::ReturnStmt *stmt) { return false; } +void Converter::InitializeReturnSlot(clang::QualType type, clang::Expr *value) { + std::string_view slot = "__return"; + if (auto *construct = GetPlacementInitializer(value)) { + ConstructInPlace(value, construct, GetReturnSlotReceiver(slot)); + return; + } + HoistMaterializedTempBindings hoist_temps(*this); + StrCat(slot, ".write"); + { + PushParen paren(*this); + if (type->isReferenceType()) { + StrCat(GetReferenceMarker(type->isRValueReferenceType()), "::bind"); + } + PushParen bind(*this, type->isReferenceType()); + ConvertVarInit(type, value); + } + StrCat(token::kSemiColon); +} + bool Converter::VisitGotoStmt(clang::GotoStmt *stmt) { StrCat(std::format("goto!('{})", stmt->getLabel()->getName().str())); return false; @@ -5922,41 +5930,64 @@ void Converter::EmitComparisonMethod(const ComparisonRelation &relation, const Comparisons &comparisons) { auto *expr = comparisons.exprs.at(relation.op); auto type = ctx_.getReferenceQualifiedType(expr); - bool is_reference = type->isReferenceType(); - if (!is_reference && UsesReturnSlot(type)) { - llvm::report_fatal_error( - "comparison results returned in a return slot are not supported"); - } StrCat(std::format("type {} = {};", relation.result, - is_reference + type->isReferenceType() ? GetReferenceMarkerAsString(type) : GetUnboxedTypeAsString(type.getUnqualifiedType()))); - StrCat(keyword_unsafe_, keyword::kFn, relation.method); + if (!relation.test_method) { + assert(!type->isReferenceType() && !UsesReturnSlot(type)); + EmitComparisonFunction(relation.method, "", + std::format("Self::{}", relation.result), + comparisons, [&] { + HoistMaterializedTempBindings hoist_temps(*this); + StrCat(keyword::kReturn); + ConvertVarInit(type, expr); + StrCat(token::kSemiColon); + }); + return; + } + EmitComparisonFunction( + relation.method, + std::format("__return: {},", + GetReturnSlotType(std::format("Self::{}", relation.result))), + "", comparisons, [&] { InitializeReturnSlot(type, expr); }); + EmitComparisonFunction(relation.test_method, "", "bool", comparisons, [&] { + HoistMaterializedTempBindings hoist_temps(*this); + StrCat(keyword::kReturn); + ConvertVarInit(ctx_.BoolTy, comparisons.tests.at(relation.op)); + StrCat(token::kSemiColon); + }); +} + +void Converter::EmitComparisonFunction(std::string_view method, + std::string_view slot_param, + std::string_view return_type, + const Comparisons &comparisons, + llvm::function_ref body) { + StrCat(keyword_unsafe_, keyword::kFn, method); { PushParen params(*this); + StrCat(slot_param); for (auto *operand : {comparisons.lhs, comparisons.rhs}) { StrCat(GetNamedDeclAsString(operand), token::kColon, GetReferenceMarkerAsString(operand->getType()), token::kComma); } } - StrCat(token::kArrow, std::format("Self::{}", relation.result)); - PushBrace body(*this); + if (!return_type.empty()) { + StrCat(token::kArrow, return_type); + } + PushBrace brace(*this); for (auto *operand : {comparisons.lhs, comparisons.rhs}) { auto name = GetNamedDeclAsString(operand); StrCat(std::format("let {} = {};", name, GetReferredObjectPointer(name, operand->getType()))); } PushExprKind push(*this, ExprKind::Void); - ConvertFullExpression([&] { - HoistMaterializedTempBindings hoist_temps(*this); - StrCat(keyword::kReturn); - if (is_reference) { - StrCat(GetReferenceMarker(type->isRValueReferenceType()), "::bind"); - } - PushParen bind(*this, is_reference); - ConvertVarInit(type, expr); - }); - StrCat(token::kSemiColon); + ConvertFullExpression(body); +} + +std::string Converter::GetReturnSlotType(std::string_view object_type) const { + return std::format("*mut {}", object_type); } void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 2c80ea540f..e24e4c9a08 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -314,6 +314,10 @@ class Converter : public clang::RecursiveASTVisitor { virtual std::string GetReturnSlotArg(std::string_view receiver) const; + virtual std::string GetReturnSlotType(std::string_view object_type) const; + + void InitializeReturnSlot(clang::QualType type, clang::Expr *value); + std::string GetReturnSlotParam(clang::QualType type); virtual bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *decl); @@ -513,6 +517,12 @@ class Converter : public clang::RecursiveASTVisitor { void EmitComparisonMethod(const ComparisonRelation &relation, const Comparisons &comparisons); + void EmitComparisonFunction(std::string_view method, + std::string_view slot_param, + std::string_view return_type, + const Comparisons &comparisons, + llvm::function_ref body); + void ConvertParamTy(clang::QualType param_type, clang::Expr *expr); virtual void ConvertParamTyConstCast(clang::QualType param_type, diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 30f299afc7..df2120e58a 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -2323,7 +2323,8 @@ class TranslationUnitScope { static clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, - clang::Expr *lhs, clang::Expr *rhs) { + clang::Expr *lhs, clang::Expr *rhs, + bool is_test) { TranslationUnitScope tu_scope(sema); RuleDecls::Trial trial(sema); clang::ExprResult result; @@ -2331,6 +2332,9 @@ static clang::Expr *BuildComparison(clang::Sema &sema, clang::Sema::GlobalEagerInstantiationScope instantiations( sema, /*Enabled=*/true, /*AtEndOfTU=*/false); result = sema.BuildBinOp(tu_scope.get(), lhs->getExprLoc(), op, lhs, rhs); + if (is_test && result.isUsable()) { + result = sema.PerformContextuallyConvertToBool(result.get()); + } if (result.isUsable()) { result = sema.ActOnFinishFullExpr(result.get(), /*DiscardedValue=*/false); } @@ -2342,7 +2346,8 @@ static clang::Expr *BuildComparison(clang::Sema &sema, bool Comparisons::Has(const ComparisonTrait &trait) const { return llvm::all_of(trait.relations, [&](const ComparisonRelation &relation) { - return exprs.at(relation.op) != nullptr; + return exprs.at(relation.op) && + (!relation.test_method || tests.at(relation.op)); }) && (!trait.supertrait || Has(*trait.supertrait)); } @@ -2374,11 +2379,17 @@ BuildComparisons(clang::Sema &sema, clang::BlockDecl *context, }; for (const auto *trait : traits) { for (const auto &relation : trait->relations) { - if (!comparisons.exprs.contains(relation.op)) { - comparisons.exprs.emplace(relation.op, - BuildComparison(sema, relation.op, - refer(comparisons.lhs), - refer(comparisons.rhs))); + if (comparisons.exprs.contains(relation.op)) { + continue; + } + auto *result = BuildComparison(sema, relation.op, refer(comparisons.lhs), + refer(comparisons.rhs), false); + comparisons.exprs.emplace(relation.op, result); + if (result && relation.test_method) { + comparisons.tests.emplace( + relation.op, + BuildComparison(sema, relation.op, refer(comparisons.lhs), + refer(comparisons.rhs), true)); } } } diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 69746d3992..fdc794f377 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -196,6 +196,7 @@ const clang::ParmVarDecl *GetCopyOrMoveSource(const clang::FunctionDecl *decl); struct ComparisonRelation { clang::BinaryOperatorKind op; const char *method; + const char *test_method; const char *result; }; @@ -207,18 +208,18 @@ struct ComparisonTrait { }; inline constexpr ComparisonRelation kEqualRelations[] = { - {clang::BO_EQ, "equal", "EqualResult"}}; + {clang::BO_EQ, "equal", "is_equal", "EqualResult"}}; inline constexpr ComparisonRelation kNotEqualRelations[] = { - {clang::BO_NE, "not_equal", "NotEqualResult"}}; + {clang::BO_NE, "not_equal", "is_not_equal", "NotEqualResult"}}; inline constexpr ComparisonRelation kLessThanRelations[] = { - {clang::BO_LT, "less", "Result"}}; + {clang::BO_LT, "less", "is_less", "Result"}}; inline constexpr ComparisonRelation kOrderingRelations[] = { - {clang::BO_LT, "less", "LessResult"}, - {clang::BO_GT, "greater", "GreaterResult"}, - {clang::BO_LE, "less_equal", "LessEqualResult"}, - {clang::BO_GE, "greater_equal", "GreaterEqualResult"}}; + {clang::BO_LT, "less", "is_less", "LessResult"}, + {clang::BO_GT, "greater", "is_greater", "GreaterResult"}, + {clang::BO_LE, "less_equal", "is_less_equal", "LessEqualResult"}, + {clang::BO_GE, "greater_equal", "is_greater_equal", "GreaterEqualResult"}}; inline constexpr ComparisonRelation kThreeWayRelations[] = { - {clang::BO_Cmp, "three_way", "Category"}}; + {clang::BO_Cmp, "three_way", nullptr, "Category"}}; inline constexpr ComparisonTrait kCpp17EqualityComparable{ {nullptr, {"Cpp17EqualityComparable"}, {"Cpp17EqualityComparableUnsafe"}}, @@ -255,6 +256,7 @@ struct Comparisons { clang::VarDecl *lhs; clang::VarDecl *rhs; std::unordered_map exprs; + std::unordered_map tests; bool Has(const ComparisonTrait &trait) const; }; diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 4349f387cc..468d9c4604 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -3664,6 +3664,11 @@ ConverterRefCount::GetReturnSlotArg(std::string_view receiver) const { return std::format("Ptr::clone(&{})", receiver); } +std::string +ConverterRefCount::GetReturnSlotType(std::string_view object_type) const { + return std::format("Ptr<{}>", object_type); +} + std::string ConverterRefCount::GetParamTypeAsString(const clang::ParmVarDecl *param) { PushConversionKind push(*this, VarConversionKind(param)); diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index 83c2a7fb5f..a69641e371 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -112,6 +112,8 @@ class ConverterRefCount final : public Converter { std::string GetReturnSlotArg(std::string_view receiver) const override; + std::string GetReturnSlotType(std::string_view object_type) const override; + bool VisitCXXThisExpr(clang::CXXThisExpr *expr) override; bool ThisIsRustPtr() const override; diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index 9180326334..9785f22c3a 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -68,9 +68,11 @@ class RuleUsageCollector } void TraverseComparisons(const Comparisons &comparisons) { - for (const auto &[op, expr] : comparisons.exprs) { - if (expr) { - TraverseStmt(expr); + for (const auto *exprs : {&comparisons.exprs, &comparisons.tests}) { + for (const auto &[op, expr] : *exprs) { + if (expr) { + TraverseStmt(expr); + } } } } diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index 9bdb12f752..8d0d1a5762 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -22,35 +22,47 @@ impl> BooleanTestableUnsafe for T {} pub trait LessThanComparable: ByteRepr + Sized { type Result: BooleanTestable; - fn less(a: LvalueRef>, b: LvalueRef>) -> Self::Result; + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>); + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool; } pub trait LessThanComparableUnsafe: Sized { type Result: BooleanTestableUnsafe; /// # Safety - /// `a` and `b` must refer to live values. + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn less( + __return: *mut Self::Result, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::Result; + ); + /// # Safety + /// `a` and `b` must refer to live values. + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; } pub trait Cpp17EqualityComparable: ByteRepr + Sized { type EqualResult: BooleanTestable; - fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult; + fn equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>); + fn is_equal(a: LvalueRef>, b: LvalueRef>) -> bool; } pub trait Cpp17EqualityComparableUnsafe: Sized { type EqualResult: BooleanTestableUnsafe; /// # Safety - /// `a` and `b` must refer to live values. + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn equal( + __return: *mut Self::EqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::EqualResult; + ); + /// # Safety + /// `a` and `b` must refer to live values. + unsafe fn is_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; } pub trait WeaklyEqualityComparableWith = Self>: @@ -58,7 +70,12 @@ pub trait WeaklyEqualityComparableWith = S { type NotEqualResult: BooleanTestable; - fn not_equal(a: LvalueRef>, b: LvalueRef>) -> Self::NotEqualResult; + fn not_equal( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ); + fn is_not_equal(a: LvalueRef>, b: LvalueRef>) -> bool; } pub trait WeaklyEqualityComparableWithUnsafe = Self>: @@ -67,11 +84,16 @@ pub trait WeaklyEqualityComparableWithUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::NotEqualResult; + ); + /// # Safety + /// `a` and `b` must refer to live values. + unsafe fn is_not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; } pub trait EqualityComparable: WeaklyEqualityComparableWith {} @@ -116,6 +138,14 @@ macro_rules! impl_less_than_comparable { type Result = bool; fn less( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_less(a, b)); + } + + fn is_less( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { @@ -134,6 +164,16 @@ macro_rules! impl_less_than_comparable_unsafe { type Result = bool; unsafe fn less( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write(::is_less(a, b)); + } + } + + unsafe fn is_less( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { @@ -161,17 +201,21 @@ where { type Result = bool; - fn less(a: LvalueRef>, b: LvalueRef>) -> bool { + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_less(a, b)); + } + + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); let (m, n) = (a.with(Vec::len), b.with(Vec::len)); let (a, b) = (a.decay(), b.decay()); for i in 0..m.min(n) { let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return true; } let (x, y) = (LvalueRef::bind(b.offset(i)), LvalueRef::bind(a.offset(i))); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return false; } } @@ -182,17 +226,21 @@ where impl LessThanComparable for Box<[T]> { type Result = bool; - fn less(a: LvalueRef>, b: LvalueRef>) -> bool { + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_less(a, b)); + } + + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); let (m, n) = (a.with(|elems| elems.len()), b.with(|elems| elems.len())); let (a, b) = (a.decay(), b.decay()); for i in 0..m.min(n) { let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return true; } let (x, y) = (LvalueRef::bind(b.offset(i)), LvalueRef::bind(a.offset(i))); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return false; } } @@ -206,7 +254,11 @@ where { type Result = bool; - fn less(a: LvalueRef>, b: LvalueRef>) -> bool { + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_less(a, b)); + } + + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool { let pointers = |pair: &Self| { ( AsPointer::::as_pointer(&pair.0), @@ -216,20 +268,28 @@ where let (a0, a1) = a.as_pointer().with(pointers); let (b0, b1) = b.as_pointer().with(pointers); let (x, y) = (LvalueRef::bind(a0.clone()), LvalueRef::bind(b0.clone())); - if ConvertibleTo::::convert_value(A::less(x, y)) { + if A::is_less(x, y) { return true; } - if ConvertibleTo::::convert_value(A::less(LvalueRef::bind(b0), LvalueRef::bind(a0))) { + if A::is_less(LvalueRef::bind(b0), LvalueRef::bind(a0)) { return false; } - ConvertibleTo::::convert_value(B::less(LvalueRef::bind(a1), LvalueRef::bind(b1))) + B::is_less(LvalueRef::bind(a1), LvalueRef::bind(b1)) } } impl LessThanComparableUnsafe for Vec { type Result = bool; - unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn less( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_less(a, b)) } + } + + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); let (m, n) = ((*a).len(), (*b).len()); @@ -239,14 +299,14 @@ impl LessThanComparableUnsafe for Vec { LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i)), ); - if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return true; } let (x, y) = ( LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i)), ); - if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return false; } } @@ -258,7 +318,15 @@ impl LessThanComparableUnsafe for Vec { impl LessThanComparableUnsafe for [T; N] { type Result = bool; - unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn less( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_less(a, b)) } + } + + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); for i in 0..N { unsafe { @@ -266,14 +334,14 @@ impl LessThanComparableUnsafe for [ LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i)), ); - if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return true; } let (x, y) = ( LvalueRefUnsafe::bind(b.add(i)), LvalueRefUnsafe::bind(a.add(i)), ); - if ConvertibleToUnsafe::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return false; } } @@ -285,21 +353,29 @@ impl LessThanComparableUnsafe for [ impl LessThanComparableUnsafe for (A, B) { type Result = bool; - unsafe fn less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn less( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_less(a, b)) } + } + + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); let (a0, b0) = (&raw const (*a).0, &raw const (*b).0); let (a1, b1) = (&raw const (*a).1, &raw const (*b).1); let (x, y) = (LvalueRefUnsafe::bind(a0), LvalueRefUnsafe::bind(b0)); - if ConvertibleToUnsafe::::convert_value(A::less(x, y)) { + if A::is_less(x, y) { return true; } let (x, y) = (LvalueRefUnsafe::bind(b0), LvalueRefUnsafe::bind(a0)); - if ConvertibleToUnsafe::::convert_value(A::less(x, y)) { + if A::is_less(x, y) { return false; } let (x, y) = (LvalueRefUnsafe::bind(a1), LvalueRefUnsafe::bind(b1)); - ConvertibleToUnsafe::::convert_value(B::less(x, y)) + B::is_less(x, y) } } } @@ -313,6 +389,14 @@ macro_rules! impl_cpp17_equality_comparable { type EqualResult = bool; fn equal( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_equal(a, b)); + } + + fn is_equal( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { @@ -331,6 +415,14 @@ macro_rules! impl_weakly_equality_comparable_with { type NotEqualResult = bool; fn not_equal( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_not_equal(a, b)); + } + + fn is_not_equal( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { @@ -349,6 +441,16 @@ macro_rules! impl_cpp17_equality_comparable_unsafe { type EqualResult = bool; unsafe fn equal( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write(::is_equal(a, b)); + } + } + + unsafe fn is_equal( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { @@ -367,6 +469,18 @@ macro_rules! impl_weakly_equality_comparable_with_unsafe { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write( + ::is_not_equal(a, b), + ); + } + } + + unsafe fn is_not_equal( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { @@ -394,7 +508,11 @@ where { type EqualResult = bool; - fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { + fn equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_equal(a, b)); + } + + fn is_equal(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); let len = a.with(Vec::len); if len != b.with(Vec::len) { @@ -403,7 +521,7 @@ where let (a, b) = (a.decay(), b.decay()); (0..len).all(|i| { let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); - ConvertibleTo::::convert_value(T::equal(x, y)) + T::is_equal(x, y) }) } } @@ -414,15 +532,23 @@ where { type NotEqualResult = bool; - fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { - !Self::equal(a, b) + fn not_equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_not_equal(a, b)); + } + + fn is_not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::is_equal(a, b) } } impl Cpp17EqualityComparable for Box<[T]> { type EqualResult = bool; - fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { + fn equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_equal(a, b)); + } + + fn is_equal(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); let len = a.with(|elems| elems.len()); if len != b.with(|elems| elems.len()) { @@ -431,7 +557,7 @@ impl Cpp17EqualityComparable for Box<[T]> { let (a, b) = (a.decay(), b.decay()); (0..len).all(|i| { let (x, y) = (LvalueRef::bind(a.offset(i)), LvalueRef::bind(b.offset(i))); - ConvertibleTo::::convert_value(T::equal(x, y)) + T::is_equal(x, y) }) } } @@ -439,8 +565,12 @@ impl Cpp17EqualityComparable for Box<[T]> { impl WeaklyEqualityComparableWith for Box<[T]> { type NotEqualResult = bool; - fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { - !Self::equal(a, b) + fn not_equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_not_equal(a, b)); + } + + fn is_not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::is_equal(a, b) } } @@ -451,7 +581,11 @@ where { type EqualResult = bool; - fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { + fn equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_equal(a, b)); + } + + fn is_equal(a: LvalueRef>, b: LvalueRef>) -> bool { let pointers = |pair: &Self| { ( AsPointer::::as_pointer(&pair.0), @@ -461,10 +595,10 @@ where let (a0, a1) = a.as_pointer().with(pointers); let (b0, b1) = b.as_pointer().with(pointers); let (x, y) = (LvalueRef::bind(a0), LvalueRef::bind(b0)); - if !ConvertibleTo::::convert_value(A::equal(x, y)) { + if !A::is_equal(x, y) { return false; } - ConvertibleTo::::convert_value(B::equal(LvalueRef::bind(a1), LvalueRef::bind(b1))) + B::is_equal(LvalueRef::bind(a1), LvalueRef::bind(b1)) } } @@ -475,8 +609,12 @@ where { type NotEqualResult = bool; - fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { - !Self::equal(a, b) + fn not_equal(__return: Ptr, a: LvalueRef>, b: LvalueRef>) { + __return.write(Self::is_not_equal(a, b)); + } + + fn is_not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + !Self::is_equal(a, b) } } @@ -495,7 +633,15 @@ impl_weakly_equality_comparable_with_unsafe!( impl Cpp17EqualityComparableUnsafe for Vec { type EqualResult = bool; - unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_equal(a, b)) } + } + + unsafe fn is_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); let len = (*a).len(); @@ -508,7 +654,7 @@ impl Cpp17EqualityComparableUnsafe for Vec LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i)), ); - ConvertibleToUnsafe::::convert_value(T::equal(x, y)) + T::is_equal(x, y) }) } } @@ -517,22 +663,41 @@ impl Cpp17EqualityComparableUnsafe for Vec impl WeaklyEqualityComparableWithUnsafe for Vec { type NotEqualResult = bool; - unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { - unsafe { !Self::equal(a, b) } + unsafe fn not_equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_not_equal(a, b)) } + } + + unsafe fn is_not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { !Self::is_equal(a, b) } } } impl Cpp17EqualityComparableUnsafe for [T; N] { type EqualResult = bool; - unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_equal(a, b)) } + } + + unsafe fn is_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); (0..N).all(|i| unsafe { let (x, y) = ( LvalueRefUnsafe::bind(a.add(i)), LvalueRefUnsafe::bind(b.add(i)), ); - ConvertibleToUnsafe::::convert_value(T::equal(x, y)) + T::is_equal(x, y) }) } } @@ -542,8 +707,19 @@ impl WeaklyEqualityComparableW { type NotEqualResult = bool; - unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { - unsafe { !Self::equal(a, b) } + unsafe fn not_equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_not_equal(a, b)) } + } + + unsafe fn is_not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { !Self::is_equal(a, b) } } } @@ -552,21 +728,29 @@ impl { type EqualResult = bool; - unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { + unsafe fn equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_equal(a, b)) } + } + + unsafe fn is_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { let (a, b) = (a.as_const_ptr(), b.as_const_ptr()); let (x, y) = ( LvalueRefUnsafe::bind(&raw const (*a).0), LvalueRefUnsafe::bind(&raw const (*b).0), ); - if !ConvertibleToUnsafe::::convert_value(A::equal(x, y)) { + if !A::is_equal(x, y) { return false; } let (x, y) = ( LvalueRefUnsafe::bind(&raw const (*a).1), LvalueRefUnsafe::bind(&raw const (*b).1), ); - ConvertibleToUnsafe::::convert_value(B::equal(x, y)) + B::is_equal(x, y) } } } @@ -576,8 +760,19 @@ impl { type NotEqualResult = bool; - unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { - unsafe { !Self::equal(a, b) } + unsafe fn not_equal( + __return: *mut bool, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_not_equal(a, b)) } + } + + unsafe fn is_not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { !Self::is_equal(a, b) } } } @@ -587,11 +782,26 @@ pub trait PartiallyOrderedWith = Self>: ByteRepr + type LessEqualResult: BooleanTestable; type GreaterEqualResult: BooleanTestable; - fn less(a: LvalueRef>, b: LvalueRef>) -> Self::LessResult; - fn greater(a: LvalueRef>, b: LvalueRef>) -> Self::GreaterResult; - fn less_equal(a: LvalueRef>, b: LvalueRef>) -> Self::LessEqualResult; - fn greater_equal(a: LvalueRef>, b: LvalueRef>) - -> Self::GreaterEqualResult; + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>); + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool; + fn greater( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ); + fn is_greater(a: LvalueRef>, b: LvalueRef>) -> bool; + fn less_equal( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ); + fn is_less_equal(a: LvalueRef>, b: LvalueRef>) -> bool; + fn greater_equal( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ); + fn is_greater_equal(a: LvalueRef>, b: LvalueRef>) -> bool; } pub trait PartiallyOrderedWithUnsafe = Self>: Sized { @@ -601,29 +811,52 @@ pub trait PartiallyOrderedWithUnsafe = Self> type GreaterEqualResult: BooleanTestableUnsafe; /// # Safety - /// `a` and `b` must refer to live values. + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn less( + __return: *mut Self::LessResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::LessResult; + ); /// # Safety /// `a` and `b` must refer to live values. + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; + /// # Safety + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn greater( + __return: *mut Self::GreaterResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::GreaterResult; + ); /// # Safety /// `a` and `b` must refer to live values. + unsafe fn is_greater(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; + /// # Safety + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn less_equal( + __return: *mut Self::LessEqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::LessEqualResult; + ); /// # Safety /// `a` and `b` must refer to live values. + unsafe fn is_less_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; + /// # Safety + /// `__return` must point to writable storage for the result, and `a` and `b` must refer to + /// live values. unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ); + /// # Safety + /// `a` and `b` must refer to live values. + unsafe fn is_greater_equal( a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult; + ) -> bool; } pub trait TotallyOrdered: EqualityComparable + PartiallyOrderedWith {} @@ -677,24 +910,59 @@ macro_rules! impl_partially_ordered_with { type GreaterEqualResult = bool; fn less( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_less(a, b)); + } + + fn is_less( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| a < b)) } + fn greater( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_greater(a, b)); + } + + fn is_greater( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| a > b)) } + fn less_equal( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_less_equal(a, b)); + } + + fn is_less_equal( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| a <= b)) } + fn greater_equal( + __return: $crate::Ptr, + a: $crate::LvalueRef<$crate::Const>, + b: $crate::LvalueRef<$crate::Const>, + ) { + __return.write(::is_greater_equal(a, b)); + } + + fn is_greater_equal( a: $crate::LvalueRef<$crate::Const>, b: $crate::LvalueRef<$crate::Const>, ) -> bool { @@ -716,24 +984,71 @@ macro_rules! impl_partially_ordered_with_unsafe { type GreaterEqualResult = bool; unsafe fn less( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write(::is_less(a, b)); + } + } + + unsafe fn is_less( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { unsafe { *a.as_const_ptr() < *b.as_const_ptr() } } + unsafe fn greater( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write(::is_greater(a, b)); + } + } + + unsafe fn is_greater( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { unsafe { *a.as_const_ptr() > *b.as_const_ptr() } } + unsafe fn less_equal( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write( + ::is_less_equal(a, b), + ); + } + } + + unsafe fn is_less_equal( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { unsafe { *a.as_const_ptr() <= *b.as_const_ptr() } } + unsafe fn greater_equal( + __return: *mut bool, + a: $crate::LvalueRefUnsafe<$crate::Const>, + b: $crate::LvalueRefUnsafe<$crate::Const>, + ) { + unsafe { + __return.write( + ::is_greater_equal(a, b), + ); + } + } + + unsafe fn is_greater_equal( a: $crate::LvalueRefUnsafe<$crate::Const>, b: $crate::LvalueRefUnsafe<$crate::Const>, ) -> bool { @@ -885,11 +1200,11 @@ impl_three_way_comparable_unsafe!(PartialOrdering, PartialOrd::partial_cmp, <> f // The order of two values that std::sort and std::map derive from operator<. pub fn cpp_cmp(lhs: &Ptr, rhs: &Ptr) -> Ordering { let (x, y) = (LvalueRef::bind(lhs.clone()), LvalueRef::bind(rhs.clone())); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { return Ordering::Less; } let (x, y) = (LvalueRef::bind(rhs.clone()), LvalueRef::bind(lhs.clone())); - if ConvertibleTo::::convert_value(T::less(x, y)) { + if T::is_less(x, y) { Ordering::Greater } else { Ordering::Equal diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index 1a66995d8b..8be9c18b0c 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -497,6 +497,14 @@ impl crate::Cpp17EqualityComparable for FnPtr { type EqualResult = bool; fn equal( + __return: crate::Ptr, + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) { + __return.write(::is_equal(a, b)); + } + + fn is_equal( a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { @@ -509,6 +517,14 @@ impl crate::WeaklyEqualityComparableWith for FnPtr { type NotEqualResult = bool; fn not_equal( + __return: crate::Ptr, + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) { + __return.write(::is_not_equal(a, b)); + } + + fn is_not_equal( a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { @@ -521,6 +537,14 @@ impl crate::Cpp17EqualityComparableUnsafe for FnPtr { type EqualResult = bool; unsafe fn equal( + __return: *mut bool, + a: crate::LvalueRefUnsafe>, + b: crate::LvalueRefUnsafe>, + ) { + unsafe { __return.write(::is_equal(a, b)) } + } + + unsafe fn is_equal( a: crate::LvalueRefUnsafe>, b: crate::LvalueRefUnsafe>, ) -> bool { @@ -532,6 +556,16 @@ impl crate::WeaklyEqualityComparableWithUnsafe for FnPtr { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut bool, + a: crate::LvalueRefUnsafe>, + b: crate::LvalueRefUnsafe>, + ) { + unsafe { + __return.write(::is_not_equal(a, b)) + } + } + + unsafe fn is_not_equal( a: crate::LvalueRefUnsafe>, b: crate::LvalueRefUnsafe>, ) -> bool { diff --git a/libcc2rs/src/reference.rs b/libcc2rs/src/reference.rs index 81d20837b3..ac5e3d2f5f 100644 --- a/libcc2rs/src/reference.rs +++ b/libcc2rs/src/reference.rs @@ -127,8 +127,20 @@ macro_rules! reference { { type EqualResult = ::EqualResult; - fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ) { ::equal( + __return, + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), + ); + } + + fn is_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + ::is_equal( LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) @@ -143,10 +155,19 @@ macro_rules! reference { ::NotEqualResult; fn not_equal( + __return: Ptr, a: LvalueRef>, b: LvalueRef>, - ) -> Self::NotEqualResult { + ) { ::not_equal( + __return, + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), + ); + } + + fn is_not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { + ::is_not_equal( LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) @@ -159,8 +180,20 @@ macro_rules! reference { { type Result = ::Result; - fn less(a: LvalueRef>, b: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + a: LvalueRef>, + b: LvalueRef>, + ) { ::less( + __return, + LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), + LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), + ); + } + + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool { + ::is_less( LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) @@ -296,11 +329,25 @@ macro_rules! reference_unsafe { type EqualResult = T::EqualResult; unsafe fn equal( + __return: *mut Self::EqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { unsafe { T::equal( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_equal( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) @@ -314,11 +361,25 @@ macro_rules! reference_unsafe { type NotEqualResult = T::NotEqualResult; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { unsafe { T::not_equal( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_not_equal( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) @@ -332,11 +393,25 @@ macro_rules! reference_unsafe { type EqualResult = T::EqualResult; unsafe fn equal( + __return: *mut Self::EqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { unsafe { T::equal( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_equal( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) @@ -350,11 +425,25 @@ macro_rules! reference_unsafe { type NotEqualResult = T::NotEqualResult; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { unsafe { T::not_equal( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_not_equal( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_not_equal( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) @@ -366,11 +455,25 @@ macro_rules! reference_unsafe { type Result = T::Result; unsafe fn less( + __return: *mut Self::Result, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::Result { + ) { unsafe { T::less( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_less( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) @@ -384,11 +487,25 @@ macro_rules! reference_unsafe { type Result = T::Result; unsafe fn less( + __return: *mut Self::Result, a: LvalueRefUnsafe>, b: LvalueRefUnsafe>, - ) -> Self::Result { + ) { unsafe { T::less( + __return, + LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), + LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), + ) + } + } + + unsafe fn is_less( + a: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, + ) -> bool { + unsafe { + T::is_less( LvalueRefUnsafe::bind((*a.as_const_ptr()).as_ptr().cast::()), LvalueRefUnsafe::bind((*b.as_const_ptr()).as_ptr().cast::()), ) diff --git a/libcc2rs/src/void.rs b/libcc2rs/src/void.rs index c99cc06802..6ccae5b82a 100644 --- a/libcc2rs/src/void.rs +++ b/libcc2rs/src/void.rs @@ -152,6 +152,14 @@ impl crate::Cpp17EqualityComparable for AnyPtr { type EqualResult = bool; fn equal( + __return: crate::Ptr, + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) { + __return.write(Self::is_equal(a, b)); + } + + fn is_equal( a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { @@ -164,6 +172,14 @@ impl crate::WeaklyEqualityComparableWith for AnyPtr { type NotEqualResult = bool; fn not_equal( + __return: crate::Ptr, + a: crate::LvalueRef>, + b: crate::LvalueRef>, + ) { + __return.write(Self::is_not_equal(a, b)); + } + + fn is_not_equal( a: crate::LvalueRef>, b: crate::LvalueRef>, ) -> bool { diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index 9f17e3d64c..ec06e69d34 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -30,10 +30,10 @@ where let __first: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); let mut __out = a2; - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__first.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { object!(__value, T4, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), __this @@ -55,13 +55,13 @@ fn f3, T2: ByteRepr, T3: Cpp17EqualityComparable>( ) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(>::equal( + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(a2.clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -91,19 +91,19 @@ fn f8, T2: LessThanComparable>(a0: T1, a1: T1) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value(::not_equal( + if ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { - if ConvertibleTo::::convert_value(::less( + ) { + if ::is_less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), - )) { + ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -122,22 +122,22 @@ fn f10, T2: Cpp17EqualityComparable + TriviallyCopy ) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - if ConvertibleTo::::convert_value(::equal( + if ::is_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { __last.borrow().clone() } else { let mut __write = __it.borrow().clone(); __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { - if !ConvertibleTo::::convert_value(::equal( + ) { + if !::is_equal( LvalueRef::>::bind(__write.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), - )) { + ) { __write.iter_inc(); __write .iter_deref() @@ -153,10 +153,10 @@ fn f10, T2: Cpp17EqualityComparable + TriviallyCopy fn f12, T2: Clone + ByteRepr>(a0: T1, a1: T1, a2: T2) { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { __it.borrow().iter_deref().write(Clone::clone(&a2)); __it.borrow_mut().iter_inc(); } @@ -167,10 +167,10 @@ fn f13>(a0: T1, a1: T1, a2: &mut ::std::fs::File) -> :: let __last: Value = Rc::new(RefCell::new(a1)); let __out = &mut *a2; let mut __bytes: Vec = Vec::new(); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { __bytes.push(__it.borrow().iter_deref().read() as u8); __it.borrow_mut().iter_inc(); } @@ -199,10 +199,10 @@ where } fn f16(a0: Ptr, a1: Ptr) -> Ptr { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(a1.clone()), LvalueRef::>::bind(a0.clone()), - )) { + ) { a1 } else { a0 @@ -210,10 +210,10 @@ fn f16(a0: Ptr, a1: Ptr) -> Ptr { } fn f17(a0: Ptr, a1: Ptr) -> Ptr { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(a0.clone()), LvalueRef::>::bind(a1.clone()), - )) { + ) { a1 } else { a0 diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 984bf10fba..ccd60599a9 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -11,16 +11,14 @@ unsafe fn f1, T2: LessThanComparableUnsafe __order.sort_by(|&__x, &__y| { let __a = a0.iter_at(__x) as *const T2; let __b = a0.iter_at(__y) as *const T2; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -51,11 +49,9 @@ where { let mut __first = a0; let mut __out = a2; - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&a1), ) { object_unsafe!(__value, T4, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), @@ -77,17 +73,13 @@ unsafe fn f3, T2, T3: Cpp17EqualityComparableUnsa a2: T2, ) -> T1 { let mut __it = a0; - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), - ) && !ConvertibleToUnsafe::::convert_value(>::equal( + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), + ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&a2), - )) { + ) { __it.iter_inc(); } __it @@ -121,24 +113,20 @@ where unsafe fn f8, T2: LessThanComparableUnsafe>(a0: T1, a1: T1) -> T1 { let mut __best = a0.clone(); - if ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&a0), - LvalueRefUnsafe::>::bind(&a1), - ), + if ::is_not_equal( + LvalueRefUnsafe::>::bind(&a0), + LvalueRefUnsafe::>::bind(&a1), ) { let mut __it = a0; __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ) { - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), - )) { + ) { __best = __it.clone(); } __it.iter_inc(); @@ -157,26 +145,22 @@ unsafe fn f10, T2: Cpp17EqualityComparableUnsafe< a0: T1, a1: T1, ) -> T1 { - if ConvertibleToUnsafe::::convert_value(::equal( + if ::is_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) { + ) { a1 } else { let mut __write = a0.clone(); let mut __it = a0; __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ) { - if !ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(__write.iter_deref()), - LvalueRefUnsafe::>::bind(__it.iter_deref()), - ), + if !::is_equal( + LvalueRefUnsafe::>::bind(__write.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __write.iter_inc(); *__write.iter_deref() = (*__it.iter_deref()).clone(); @@ -190,11 +174,9 @@ unsafe fn f10, T2: Cpp17EqualityComparableUnsafe< unsafe fn f12, T2: Clone>(a0: T1, a1: T1, a2: T2) { let mut __it = a0; - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ) { *__it.iter_deref() = Clone::clone(&a2); __it.iter_inc(); @@ -209,11 +191,9 @@ unsafe fn f13>( let mut __it = a0; let __out = &mut *a2; let mut __bytes: Vec = Vec::new(); - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ) { __bytes.push(*__it.iter_deref() as u8); __it.iter_inc(); @@ -241,10 +221,10 @@ where unsafe fn f16(a0: *const T1, a1: *const T1) -> *const T1 { let __a: *const _ = a0; let __b: *const _ = a1; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -254,10 +234,10 @@ unsafe fn f16(a0: *const T1, a1: *const T1) -> *co unsafe fn f17(a0: *const T1, a1: *const T1) -> *const T1 { let __a: *const _ = a0; let __b: *const _ = a1; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index bf4b7452fd..2bb579158b 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -175,14 +175,30 @@ macro_rules! uninhabited_iterator { impl crate::Cpp17EqualityComparable for $name { type EqualResult = bool; - fn equal(this: LvalueRef>, _: LvalueRef>) -> bool { + fn equal( + __return: Ptr, + this: LvalueRef>, + rhs: LvalueRef>, + ) { + __return.write(::is_equal(this, rhs)); + } + fn is_equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) } } impl crate::WeaklyEqualityComparableWith for $name { type NotEqualResult = bool; - fn not_equal(this: LvalueRef>, _: LvalueRef>) -> bool { + fn not_equal( + __return: Ptr, + this: LvalueRef>, + rhs: LvalueRef>, + ) { + __return.write( + ::is_not_equal(this, rhs), + ); + } + fn is_not_equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) } } @@ -190,6 +206,17 @@ macro_rules! uninhabited_iterator { impl crate::Cpp17EqualityComparableUnsafe for $name { type EqualResult = bool; unsafe fn equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { + __return.write( + ::is_equal(this, rhs), + ) + } + } + unsafe fn is_equal( this: LvalueRefUnsafe>, _: LvalueRefUnsafe>, ) -> bool { @@ -200,6 +227,20 @@ macro_rules! uninhabited_iterator { impl crate::WeaklyEqualityComparableWithUnsafe for $name { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { + __return.write( + ::is_not_equal( + this, + rhs, + ), + ) + } + } + unsafe fn is_not_equal( this: LvalueRefUnsafe>, _: LvalueRefUnsafe>, ) -> bool { @@ -304,7 +345,10 @@ impl ByteRepr for BidirectionalIterator {} impl crate::Cpp17EqualityComparable for BidirectionalIterator { type EqualResult = bool; - fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn equal(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_equal(this, rhs)); + } + fn is_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Map(a), Self::Map(b)) => Rc::ptr_eq(a, b), @@ -315,7 +359,10 @@ impl crate::Cpp17EqualityComparable for BidirectionalIterator { impl crate::WeaklyEqualityComparableWith for BidirectionalIterator { type NotEqualResult = bool; - fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn not_equal(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_not_equal(this, rhs)); + } + fn is_not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Map(a), Self::Map(b)) => !Rc::ptr_eq(a, b), @@ -379,7 +426,17 @@ impl Clone for UnsafeBidirectionalIterator { impl crate::Cpp17EqualityComparableUnsafe for UnsafeBidirectionalIterator { type EqualResult = bool; - unsafe fn equal(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { + unsafe fn equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_equal(this, rhs)) } + } + unsafe fn is_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Map(a), Self::Map(b)) => a == b, @@ -391,6 +448,13 @@ impl crate::Cpp17EqualityComparableUnsafe for UnsafeBidirectionalIterator impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeBidirectionalIterator { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_not_equal(this, rhs)) } + } + unsafe fn is_not_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, ) -> bool { @@ -581,7 +645,10 @@ crate::constructor::impl_trivial_copy_move!( impl crate::Cpp17EqualityComparable for RandomAccessIterator { type EqualResult = bool; - fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn equal(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_equal(this, rhs)); + } + fn is_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a == b, @@ -592,7 +659,10 @@ impl crate::Cpp17EqualityComparable for RandomAccessIterator { impl crate::WeaklyEqualityComparableWith for RandomAccessIterator { type NotEqualResult = bool; - fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn not_equal(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_not_equal(this, rhs)); + } + fn is_not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a != b, @@ -606,28 +676,44 @@ impl PartiallyOrderedWith for RandomAccessIterator { type GreaterResult = bool; type LessEqualResult = bool; type GreaterEqualResult = bool; - fn less(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn less(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_less(this, rhs)); + } + fn is_less(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a < b, }) }) } - fn greater(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn greater(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_greater(this, rhs)); + } + fn is_greater(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a > b, }) }) } - fn less_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn less_equal(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { + __return.write(Self::is_less_equal(this, rhs)); + } + fn is_less_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a <= b, }) }) } - fn greater_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { + fn greater_equal( + __return: Ptr, + this: LvalueRef>, + rhs: LvalueRef>, + ) { + __return.write(Self::is_greater_equal(this, rhs)); + } + fn is_greater_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { (Self::Vec(a), Self::Vec(b)) => a >= b, @@ -638,7 +724,17 @@ impl PartiallyOrderedWith for RandomAccessIterator { impl crate::Cpp17EqualityComparableUnsafe for UnsafeRandomAccessIterator { type EqualResult = bool; - unsafe fn equal(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { + unsafe fn equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_equal(this, rhs)) } + } + unsafe fn is_equal( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a == b, @@ -650,6 +746,13 @@ impl crate::Cpp17EqualityComparableUnsafe for UnsafeRandomAccessIterator { impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_not_equal(this, rhs)) } + } + unsafe fn is_not_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, ) -> bool { @@ -666,7 +769,17 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { type GreaterResult = bool; type LessEqualResult = bool; type GreaterEqualResult = bool; - unsafe fn less(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { + unsafe fn less( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_less(this, rhs)) } + } + unsafe fn is_less( + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { (Self::Vec(a), Self::Vec(b)) => a < b, @@ -674,6 +787,13 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { } } unsafe fn greater( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_greater(this, rhs)) } + } + unsafe fn is_greater( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, ) -> bool { @@ -684,6 +804,13 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { } } unsafe fn less_equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_less_equal(this, rhs)) } + } + unsafe fn is_less_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, ) -> bool { @@ -694,6 +821,13 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { } } unsafe fn greater_equal( + __return: *mut bool, + this: LvalueRefUnsafe>, + rhs: LvalueRefUnsafe>, + ) { + unsafe { __return.write(Self::is_greater_equal(this, rhs)) } + } + unsafe fn is_greater_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, ) -> bool { @@ -723,11 +857,9 @@ macro_rules! iter_step { Rc::new(RefCell::new(self)) } fn iter_not_equal(cur: &Self::Var, end: &Self::Var) -> bool { - crate::ConvertibleTo::::convert_value( - ::not_equal( - LvalueRef::>::bind(crate::AsPointer::::as_pointer(cur)), - LvalueRef::>::bind(crate::AsPointer::::as_pointer(end)), - ), + ::is_not_equal( + LvalueRef::>::bind(crate::AsPointer::::as_pointer(cur)), + LvalueRef::>::bind(crate::AsPointer::::as_pointer(end)), ) } fn iter_next(cur: &mut Self::Var) -> Self { @@ -749,11 +881,9 @@ macro_rules! iter_step_unsafe { } fn iter_not_equal(cur: &Self::Var, end: &Self::Var) -> bool { unsafe { - crate::ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&raw const *cur), - LvalueRefUnsafe::>::bind(&raw const *end), - ), + ::is_not_equal( + LvalueRefUnsafe::>::bind(&raw const *cur), + LvalueRefUnsafe::>::bind(&raw const *end), ) } } diff --git a/rules/iterator_category/tgt_refcount.rs b/rules/iterator_category/tgt_refcount.rs index 737c99a744..07f9d3dc7b 100644 --- a/rules/iterator_category/tgt_refcount.rs +++ b/rules/iterator_category/tgt_refcount.rs @@ -59,17 +59,17 @@ fn f8, T2>(a0: T1) -> Ptr { } fn f9, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f10, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + WeaklyEqualityComparableWith::is_not_equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f11, T2>(a0: &mut T1) -> &mut T1 { @@ -112,31 +112,31 @@ fn f19, T2>(a0: T1, a1: isize) -> Ptr { } fn f20, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(PartiallyOrderedWith::less( + PartiallyOrderedWith::is_less( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f21, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(PartiallyOrderedWith::greater( + PartiallyOrderedWith::is_greater( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f22, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(PartiallyOrderedWith::less_equal( + PartiallyOrderedWith::is_less_equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f23, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(PartiallyOrderedWith::greater_equal( + PartiallyOrderedWith::is_greater_equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } fn f24, T2>(a0: T2) -> T1 { @@ -157,8 +157,8 @@ fn f27 + Cpp17EqualityComparable, T2: CppInputItera a0: Ptr, a1: Ptr, ) -> bool { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), - )) + ) } diff --git a/rules/iterator_category/tgt_unsafe.rs b/rules/iterator_category/tgt_unsafe.rs index 9b21b74d92..0999a65ca3 100644 --- a/rules/iterator_category/tgt_unsafe.rs +++ b/rules/iterator_category/tgt_unsafe.rs @@ -59,17 +59,17 @@ fn f8, T2>(a0: T1) -> *mut T2 { } unsafe fn f9, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f10, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( + WeaklyEqualityComparableWithUnsafe::is_not_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } fn f11, T2>(a0: &mut T1) -> &mut T1 { @@ -112,31 +112,31 @@ fn f19, T2>(a0: T1, a1: isize) -> *mut T2 } unsafe fn f20, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less( + PartiallyOrderedWithUnsafe::is_less( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f21, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater( + PartiallyOrderedWithUnsafe::is_greater( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f22, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::less_equal( + PartiallyOrderedWithUnsafe::is_less_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f23, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(PartiallyOrderedWithUnsafe::greater_equal( + PartiallyOrderedWithUnsafe::is_greater_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } fn f24, T2>(a0: T2) -> T1 { @@ -161,8 +161,8 @@ unsafe fn f27< a0: T1, a1: T2, ) -> bool { - ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } diff --git a/rules/map/shim.rs b/rules/map/shim.rs index 204a720d4f..25d1cfbaee 100644 --- a/rules/map/shim.rs +++ b/rules/map/shim.rs @@ -9,9 +9,9 @@ use std::rc::{Rc, Weak}; use crate::{ AsPointer, BidirectionalIterator, ByteRepr, Const, Constructor, ConstructorUnsafe, - ConvertibleToUnsafe, CopyAssignable, CopyAssignableUnsafe, CopyConstructible, - CopyConstructibleUnsafe, LessThanComparable, LessThanComparableUnsafe, LvalueRef, - LvalueRefUnsafe, Ptr, UnsafeBidirectionalIterator, Value, ZeroInitialization, copy_constructed, + CopyAssignable, CopyAssignableUnsafe, CopyConstructible, CopyConstructibleUnsafe, + LessThanComparable, LessThanComparableUnsafe, LvalueRef, LvalueRefUnsafe, Ptr, + UnsafeBidirectionalIterator, Value, ZeroInitialization, copy_constructed, copy_constructed_unsafe, cpp_cmp, }; @@ -407,15 +407,15 @@ struct UnsafeMapKey(*const K); impl Ord for UnsafeMapKey { fn cmp(&self, other: &Self) -> Ordering { unsafe { - if ConvertibleToUnsafe::::convert_value(K::less( + if K::is_less( LvalueRefUnsafe::>::bind(self.0), LvalueRefUnsafe::>::bind(other.0), - )) { + ) { Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(K::less( + } else if K::is_less( LvalueRefUnsafe::>::bind(other.0), LvalueRefUnsafe::>::bind(self.0), - )) { + ) { Ordering::Greater } else { Ordering::Equal diff --git a/rules/pair/tgt_refcount.rs b/rules/pair/tgt_refcount.rs index b0a32386a0..8ff7c913d7 100644 --- a/rules/pair/tgt_refcount.rs +++ b/rules/pair/tgt_refcount.rs @@ -218,13 +218,13 @@ fn f28, T2: Cpp17EqualityComparable>( a0: (Value, Value), a1: (Value, Value), ) -> bool { - !(ConvertibleTo::::convert_value(::equal( + !(::is_equal( LvalueRef::>::bind(a0.0.as_pointer()), LvalueRef::>::bind(a1.0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + ) && ::is_equal( LvalueRef::>::bind(a0.1.as_pointer()), LvalueRef::>::bind(a1.1.as_pointer()), - ))) + )) } fn f34< @@ -253,51 +253,51 @@ fn f29( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + <(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a0), LvalueRef::, Value)>>::bind(a1), - )) + ) } fn f30( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - !ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + !<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a1), LvalueRef::, Value)>>::bind(a0), - )) + ) } fn f31( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + <(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a1), LvalueRef::, Value)>>::bind(a0), - )) + ) } fn f32( a0: Ptr<(Value, Value)>, a1: Ptr<(Value, Value)>, ) -> bool { - !ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( + !<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a0), LvalueRef::, Value)>>::bind(a1), - )) + ) } fn f33, T2: Cpp17EqualityComparable>( a0: (Value, Value), a1: (Value, Value), ) -> bool { - ConvertibleTo::::convert_value(::equal( + ::is_equal( LvalueRef::>::bind(a0.0.as_pointer()), LvalueRef::>::bind(a1.0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + ) && ::is_equal( LvalueRef::>::bind(a0.1.as_pointer()), LvalueRef::>::bind(a1.1.as_pointer()), - )) + ) } diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index 05c8f603f3..adf634df77 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -207,14 +207,12 @@ unsafe fn f28, T2: Cpp17EqualityComparable a0: (T1, T2), a1: (T1, T2), ) -> bool { - !(ConvertibleToUnsafe::::convert_value(::equal( + !(::is_equal( LvalueRefUnsafe::>::bind(&a0.0), LvalueRefUnsafe::>::bind(&a1.0), - )) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a0.1), - LvalueRefUnsafe::>::bind(&a1.1), - ), + ) && ::is_equal( + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), )) } @@ -222,53 +220,53 @@ unsafe fn f29( a0: (T1, T2), a1: (T1, T2), ) -> bool { - ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + <(T1, T2) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f30( a0: (T1, T2), a1: (T1, T2), ) -> bool { - !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + !<(T1, T2) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&a1), LvalueRefUnsafe::>::bind(&a0), - )) + ) } unsafe fn f31( a0: (T1, T2), a1: (T1, T2), ) -> bool { - ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + <(T1, T2) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&a1), LvalueRefUnsafe::>::bind(&a0), - )) + ) } unsafe fn f32( a0: (T1, T2), a1: (T1, T2), ) -> bool { - !ConvertibleToUnsafe::::convert_value(<(T1, T2) as LessThanComparableUnsafe>::less( + !<(T1, T2) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), - )) + ) } unsafe fn f33, T2: Cpp17EqualityComparableUnsafe>( a0: (T1, T2), a1: (T1, T2), ) -> bool { - ConvertibleToUnsafe::::convert_value(::equal( + ::is_equal( LvalueRefUnsafe::>::bind(&a0.0), LvalueRefUnsafe::>::bind(&a1.0), - )) && ConvertibleToUnsafe::::convert_value(::equal( + ) && ::is_equal( LvalueRefUnsafe::>::bind(&a0.1), LvalueRefUnsafe::>::bind(&a1.1), - )) + ) } unsafe fn f34< diff --git a/rules/vector/tgt_refcount.rs b/rules/vector/tgt_refcount.rs index 5a479f3f13..3e081cd864 100644 --- a/rules/vector/tgt_refcount.rs +++ b/rules/vector/tgt_refcount.rs @@ -110,10 +110,10 @@ fn f92< let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( @@ -168,10 +168,10 @@ fn f101< let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value = Rc::new(RefCell::new(a2)); let __last: Value = Rc::new(RefCell::new(a3)); - while ConvertibleTo::::convert_value(::not_equal( + while ::is_not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) { + ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( diff --git a/rules/vector/tgt_unsafe.rs b/rules/vector/tgt_unsafe.rs index f9bf5db6e7..300bc098da 100644 --- a/rules/vector/tgt_unsafe.rs +++ b/rules/vector/tgt_unsafe.rs @@ -168,11 +168,9 @@ unsafe fn f92< ) -> Vec { let mut __v: Vec = Vec::new(); let mut __it = a0; - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a1), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a1), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -223,11 +221,9 @@ unsafe fn f101< let __off = a1.iter_distance(&UnsafeRandomAccessIterator::Vec(a0.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = a2; - while ConvertibleToUnsafe::::convert_value( - ::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&a3), - ), + while ::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&a3), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( From e6be330feb09f3b68980ee5b54934857fb33c77f Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:56:41 +0000 Subject: [PATCH 13/17] Update tests --- libcc2rs/src/fn_ptr.rs | 10 +- rules/iterator_category/shim.rs | 19 +- .../out/refcount/friend_operator.rs | 29 +- .../out/unsafe/friend_operator.rs | 42 +- .../out/refcount/class.spaceship.rs | 458 +++++++++++-- .../out/unsafe/class.spaceship.rs | 391 +++++++++++- .../class.conv/out/refcount/class.conv.fct.rs | 105 ++- .../class.conv/out/unsafe/class.conv.fct.rs | 98 ++- .../refcount/concept.equalitycomparable.rs | 205 +++--- .../out/refcount/concept.totallyordered.rs | 286 ++++++++- .../out/unsafe/concept.equalitycomparable.rs | 184 ++++-- .../out/unsafe/concept.totallyordered.rs | 283 +++++++- .../out/refcount/concept.convertible.rs | 105 ++- .../out/unsafe/concept.convertible.rs | 98 ++- .../out/refcount/sequence.reqmts.rs | 147 +++-- .../out/unsafe/sequence.reqmts.rs | 123 +++- .../allocator.requirements.general.rs | 22 +- .../unsafe/allocator.requirements.general.rs | 32 +- .../out/refcount/utility.arg.requirements.rs | 334 +++++----- .../out/unsafe/utility.arg.requirements.rs | 236 +++++-- .../stmt.select/out/refcount/stmt.switch.rs | 175 ++++- .../stmt.select/out/unsafe/stmt.switch.rs | 189 +++++- .../support/cmp/out/refcount/cmp.concept.rs | 348 +++++++++- .../std/support/cmp/out/unsafe/cmp.concept.rs | 348 +++++++++- .../pairs/out/refcount/pairs.pair.rs | 123 ++-- .../utilities/pairs/out/unsafe/pairs.pair.rs | 152 ++--- tests/ub/out/refcount/max.rs | 8 +- tests/ub/out/unsafe/max.rs | 8 +- tests/unit/out/refcount/class.rs | 8 +- .../refcount/container_element_receiver.rs | 10 +- tests/unit/out/refcount/copy_ctor.rs | 8 +- .../refcount/elidable_iterator_copy_cxx11.rs | 18 +- .../out/refcount/emplace_receiver_alias.rs | 8 +- .../out/refcount/emplace_receiver_order.rs | 16 +- tests/unit/out/refcount/find.rs | 140 ++-- tests/unit/out/refcount/friend.rs | 11 +- .../out/refcount/global_call_temporaries.rs | 36 +- tests/unit/out/refcount/map.rs | 36 +- tests/unit/out/refcount/map_key_copy_ctor.rs | 11 +- tests/unit/out/refcount/map_key_identity.rs | 161 ++--- tests/unit/out/refcount/map_try_emplace.rs | 2 +- tests/unit/out/refcount/max.rs | 75 +-- tests/unit/out/refcount/min_max_ptr2ptr.rs | 24 +- .../refcount/operator_comparison_defaulted.rs | 525 +++++++++++++-- .../out/refcount/operator_comparison_free.rs | 117 +++- .../refcount/operator_comparison_member.rs | 70 +- .../out/refcount/operator_comparison_mixed.rs | 132 +++- .../refcount/operator_comparison_nonbool.rs | 429 +++++++++++-- .../operator_comparison_noncopyable.rs | 18 +- tests/unit/out/refcount/operator_friend.rs | 228 ++++++- .../out/refcount/operator_other_member.rs | 77 ++- tests/unit/out/refcount/operator_overloads.rs | 65 +- tests/unit/out/refcount/operator_three_way.rs | 80 ++- tests/unit/out/refcount/operator_traits.rs | 234 +++++-- .../refcount/pair_converting_construction.rs | 84 ++- tests/unit/out/refcount/push_emplace_back.rs | 32 +- .../refcount/redundant_copy_in_conversion.rs | 20 +- tests/unit/out/refcount/size_t_ssize_t.rs | 82 +-- tests/unit/out/refcount/sort_no_copy.rs | 98 ++- tests/unit/out/refcount/stdcopy.rs | 32 +- tests/unit/out/refcount/stdcopy_ostream.rs | 8 +- tests/unit/out/refcount/stdmin_fpoint.rs | 4 +- .../refcount/unboxed_conditional_iterator.rs | 42 +- tests/unit/out/refcount/unboxed_locals.rs | 4 +- tests/unit/out/refcount/vector.rs | 48 +- .../out/refcount/vector_iter_range_ctor.rs | 150 +++-- .../out/refcount/vector_with_allocator.rs | 40 +- tests/unit/out/unsafe/cast.rs | 16 +- tests/unit/out/unsafe/class.rs | 11 +- .../out/unsafe/container_element_receiver.rs | 8 +- tests/unit/out/unsafe/copy_ctor.rs | 14 +- .../unsafe/elidable_iterator_copy_cxx11.rs | 36 +- .../unit/out/unsafe/emplace_receiver_alias.rs | 8 +- .../unit/out/unsafe/emplace_receiver_order.rs | 16 +- tests/unit/out/unsafe/find.rs | 148 ++--- tests/unit/out/unsafe/friend.rs | 13 +- .../out/unsafe/global_call_temporaries.rs | 72 +-- tests/unit/out/unsafe/map.rs | 124 ++-- tests/unit/out/unsafe/map_key_copy_ctor.rs | 11 +- tests/unit/out/unsafe/map_key_identity.rs | 84 ++- tests/unit/out/unsafe/map_try_emplace.rs | 40 +- tests/unit/out/unsafe/max.rs | 92 +-- tests/unit/out/unsafe/min_max_ptr2ptr.rs | 40 +- .../unsafe/operator_comparison_defaulted.rs | 603 ++++++++++++++++-- .../out/unsafe/operator_comparison_free.rs | 145 ++++- .../out/unsafe/operator_comparison_member.rs | 68 +- .../out/unsafe/operator_comparison_mixed.rs | 162 ++++- .../out/unsafe/operator_comparison_nonbool.rs | 480 +++++++++++--- .../unsafe/operator_comparison_noncopyable.rs | 26 +- tests/unit/out/unsafe/operator_friend.rs | 352 +++++++++- .../unit/out/unsafe/operator_other_member.rs | 89 ++- tests/unit/out/unsafe/operator_overloads.rs | 79 ++- tests/unit/out/unsafe/operator_three_way.rs | 78 ++- tests/unit/out/unsafe/operator_traits.rs | 344 ++++++---- .../unsafe/pair_converting_construction.rs | 98 ++- tests/unit/out/unsafe/push_emplace_back.rs | 32 +- .../unsafe/redundant_copy_in_conversion.rs | 37 +- tests/unit/out/unsafe/size_t_ssize_t.rs | 94 ++- tests/unit/out/unsafe/sort.rs | 12 +- tests/unit/out/unsafe/sort_no_copy.rs | 211 +++--- tests/unit/out/unsafe/stdcopy.rs | 32 +- tests/unit/out/unsafe/stdcopy_ostream.rs | 10 +- tests/unit/out/unsafe/stdmin_fpoint.rs | 4 +- .../unsafe/unboxed_conditional_iterator.rs | 20 +- tests/unit/out/unsafe/unboxed_locals.rs | 4 +- tests/unit/out/unsafe/vector.rs | 60 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 158 +++-- .../unit/out/unsafe/vector_with_allocator.rs | 40 +- tests/unit/out/unsafe/void_return.rs | 24 +- 109 files changed, 9001 insertions(+), 2735 deletions(-) diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index 8be9c18b0c..c9161e1772 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -521,7 +521,9 @@ impl crate::WeaklyEqualityComparableWith for FnPtr { a: crate::LvalueRef>, b: crate::LvalueRef>, ) { - __return.write(::is_not_equal(a, b)); + __return.write(::is_not_equal( + a, b, + )); } fn is_not_equal( @@ -541,7 +543,11 @@ impl crate::Cpp17EqualityComparableUnsafe for FnPtr { a: crate::LvalueRefUnsafe>, b: crate::LvalueRefUnsafe>, ) { - unsafe { __return.write(::is_equal(a, b)) } + unsafe { + __return.write(::is_equal( + a, b, + )) + } } unsafe fn is_equal( diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index 2bb579158b..499c8a4d56 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -180,7 +180,9 @@ macro_rules! uninhabited_iterator { this: LvalueRef>, rhs: LvalueRef>, ) { - __return.write(::is_equal(this, rhs)); + __return.write(::is_equal( + this, rhs, + )); } fn is_equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) @@ -194,9 +196,9 @@ macro_rules! uninhabited_iterator { this: LvalueRef>, rhs: LvalueRef>, ) { - __return.write( - ::is_not_equal(this, rhs), - ); + __return.write(::is_not_equal( + this, rhs, + )); } fn is_not_equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) @@ -211,9 +213,9 @@ macro_rules! uninhabited_iterator { rhs: LvalueRefUnsafe>, ) { unsafe { - __return.write( - ::is_equal(this, rhs), - ) + __return.write(::is_equal( + this, rhs, + )) } } unsafe fn is_equal( @@ -234,8 +236,7 @@ macro_rules! uninhabited_iterator { unsafe { __return.write( ::is_not_equal( - this, - rhs, + this, rhs, ), ) } diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index 7a90000fb5..0d7bafd3be 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -29,7 +29,16 @@ pub struct S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -37,7 +46,16 @@ impl Cpp17EqualityComparable for S { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); @@ -45,7 +63,12 @@ impl WeaklyEqualityComparableWith for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index 35da325f09..533a7d6984 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -26,9 +26,20 @@ pub struct S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _x: *const S = __lhs; + operator_eq_0(_x, __rhs) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -40,9 +51,23 @@ impl Cpp17EqualityComparableUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _x: *const S = __lhs; + operator_ne_1(_x, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -54,9 +79,20 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _x: *const S = __lhs; + operator_lt_2(_x, __rhs) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 98d2d65227..8dabf916d7 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -72,9 +72,25 @@ impl p1_memberwise_in_declaration_order_Date { impl Cpp17EqualityComparable for p1_memberwise_in_declaration_order_Date { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_memberwise_in_declaration_order_Date::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -85,9 +101,25 @@ impl Cpp17EqualityComparable for p1_memberwise_in_declaration_order_Date { impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ + p1_memberwise_in_declaration_order_Date::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -98,9 +130,25 @@ impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { impl LessThanComparable for p1_memberwise_in_declaration_order_Date { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -116,9 +164,25 @@ impl LessThanComparable for p1_memberwise_in_declaration_order_Date { impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -132,9 +196,25 @@ impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -148,9 +228,25 @@ impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -164,9 +260,25 @@ impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -345,9 +457,22 @@ impl p2_common_comparison_category_Reading { impl Cpp17EqualityComparable for p2_common_comparison_category_Reading { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -358,9 +483,22 @@ impl Cpp17EqualityComparable for p2_common_comparison_category_Reading { impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ + p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -371,9 +509,25 @@ impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { impl LessThanComparable for p2_common_comparison_category_Reading { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -389,9 +543,25 @@ impl LessThanComparable for p2_common_comparison_category_Reading { impl PartiallyOrderedWith for p2_common_comparison_category_Reading { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -405,9 +575,25 @@ impl PartiallyOrderedWith for p2_common_comparison_category_Reading { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -421,9 +607,25 @@ impl PartiallyOrderedWith for p2_common_comparison_category_Reading { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -437,9 +639,25 @@ impl PartiallyOrderedWith for p2_common_comparison_category_Reading { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -538,9 +756,25 @@ impl weak_ordering_from_user_operator_Fraction { impl LessThanComparable for weak_ordering_from_user_operator_Fraction { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -556,9 +790,25 @@ impl LessThanComparable for weak_ordering_from_user_operator_Fraction { impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -572,9 +822,25 @@ impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -588,9 +854,25 @@ impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -604,9 +886,25 @@ impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -684,15 +982,13 @@ pub fn test_2() { }) )); assert!( - (if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - third.as_pointer().clone() - ), - LvalueRef::>::bind( - half.as_pointer().clone() - ), - ) + (if ::is_less( + LvalueRef::>::bind( + third.as_pointer().clone() + ), + LvalueRef::>::bind( + half.as_pointer().clone() + ), ) { half.as_pointer() } else { @@ -702,15 +998,13 @@ pub fn test_2() { == 2) ); assert!( - (if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - half.as_pointer().clone() - ), - LvalueRef::>::bind( - third.as_pointer().clone() - ), - ) + (if ::is_less( + LvalueRef::>::bind( + half.as_pointer().clone() + ), + LvalueRef::>::bind( + third.as_pointer().clone() + ), ) { half.as_pointer() } else { @@ -763,9 +1057,25 @@ impl partial_ordering_from_user_operator_Interval { impl LessThanComparable for partial_ordering_from_user_operator_Interval { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -781,9 +1091,25 @@ impl LessThanComparable for partial_ordering_from_user_operator_Interval { impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -797,9 +1123,25 @@ impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -813,9 +1155,25 @@ impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -829,9 +1187,25 @@ impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 21eef60d63..08ae3c834e 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -64,9 +64,22 @@ impl p1_memberwise_in_declaration_order_Date { impl Cpp17EqualityComparableUnsafe for p1_memberwise_in_declaration_order_Date { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return (unsafe { @@ -77,9 +90,22 @@ impl Cpp17EqualityComparableUnsafe for p1_memberwise_in_declaration_order_Date { impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write( + !(unsafe { + p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return !(unsafe { @@ -90,9 +116,22 @@ impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_D impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return libcc2rs::is_lt( @@ -105,9 +144,22 @@ impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return libcc2rs::is_lt( @@ -118,9 +170,22 @@ impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write(libcc2rs::is_gt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return libcc2rs::is_gt( @@ -131,9 +196,22 @@ impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write(libcc2rs::is_lteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return libcc2rs::is_lteq( @@ -144,9 +222,22 @@ impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); + __return.write(libcc2rs::is_gteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); return libcc2rs::is_gteq( @@ -288,9 +379,22 @@ impl p2_common_comparison_category_Reading { impl Cpp17EqualityComparableUnsafe for p2_common_comparison_category_Reading { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write( + (unsafe { + p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return (unsafe { @@ -301,9 +405,22 @@ impl Cpp17EqualityComparableUnsafe for p2_common_comparison_category_Reading { impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write( + !(unsafe { + p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return !(unsafe { @@ -314,9 +431,22 @@ impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Readin impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write(libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return libcc2rs::is_lt( @@ -329,9 +459,22 @@ impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write(libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return libcc2rs::is_lt( @@ -342,9 +485,22 @@ impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write(libcc2rs::is_gt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return libcc2rs::is_gt( @@ -355,9 +511,22 @@ impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write(libcc2rs::is_lteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return libcc2rs::is_lteq( @@ -368,9 +537,22 @@ impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); + let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); + __return.write(libcc2rs::is_gteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); return libcc2rs::is_gteq( @@ -452,9 +634,22 @@ impl weak_ordering_from_user_operator_Fraction { impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + __return.write(libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); return libcc2rs::is_lt( @@ -467,9 +662,22 @@ impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + __return.write(libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); return libcc2rs::is_lt( @@ -480,9 +688,22 @@ impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + __return.write(libcc2rs::is_gt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); return libcc2rs::is_gt( @@ -493,9 +714,22 @@ impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + __return.write(libcc2rs::is_lteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); return libcc2rs::is_lteq( @@ -506,9 +740,22 @@ impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); + __return.write(libcc2rs::is_gteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); return libcc2rs::is_gteq( @@ -568,11 +815,9 @@ pub unsafe fn test_2() { (((*{ let __a: *const _ = &mut third; let __b: *const _ = &mut half; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -586,11 +831,9 @@ pub unsafe fn test_2() { (((*{ let __a: *const _ = &mut third; let __b: *const _ = &mut half; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -638,9 +881,25 @@ impl partial_ordering_from_user_operator_Interval { impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + __return.write(libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); return libcc2rs::is_lt( @@ -656,9 +915,25 @@ impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + __return.write(libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); return libcc2rs::is_lt( @@ -672,9 +947,25 @@ impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + __return.write(libcc2rs::is_gt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); return libcc2rs::is_gt( @@ -688,9 +979,25 @@ impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + __return.write(libcc2rs::is_lteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); return libcc2rs::is_lteq( @@ -704,9 +1011,25 @@ impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); + __return.write(libcc2rs::is_gteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); return libcc2rs::is_gteq( diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index f583775736..27c84a9be1 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -71,9 +71,22 @@ impl p2_implicit_conversion_function_Ratio { impl Cpp17EqualityComparable for p2_implicit_conversion_function_Ratio { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { @@ -84,9 +97,22 @@ impl Cpp17EqualityComparable for p2_implicit_conversion_function_Ratio { impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { @@ -97,9 +123,22 @@ impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { impl LessThanComparable for p2_implicit_conversion_function_Ratio { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { @@ -110,9 +149,22 @@ impl LessThanComparable for p2_implicit_conversion_function_Ratio { impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { @@ -121,9 +173,22 @@ impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { @@ -132,9 +197,22 @@ impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { @@ -143,9 +221,22 @@ impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { + ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index d8abbc180c..419e8cb603 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -62,9 +62,21 @@ impl p2_implicit_conversion_function_Ratio { impl Cpp17EqualityComparableUnsafe for p2_implicit_conversion_function_Ratio { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -74,9 +86,21 @@ impl Cpp17EqualityComparableUnsafe for p2_implicit_conversion_function_Ratio { impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Ratio { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + != (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -86,9 +110,21 @@ impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Rati impl LessThanComparableUnsafe for p2_implicit_conversion_function_Ratio { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -98,9 +134,21 @@ impl LessThanComparableUnsafe for p2_implicit_conversion_function_Ratio { impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -108,9 +156,21 @@ impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + > (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -118,9 +178,21 @@ impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + <= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) @@ -128,9 +200,21 @@ impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); + __return.write( + ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) + >= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index 8d7517c0fb..76e653bc0c 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -40,9 +40,18 @@ impl p1_3_not_equal_Meters { impl Cpp17EqualityComparable for p1_3_not_equal_Meters { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -51,9 +60,18 @@ impl Cpp17EqualityComparable for p1_3_not_equal_Meters { impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) }); @@ -100,9 +118,20 @@ impl p1_2_reversed_operands_Meters { impl Cpp17EqualityComparable for p1_2_reversed_operands_Meters { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -111,9 +140,20 @@ impl Cpp17EqualityComparable for p1_2_reversed_operands_Meters { impl Cpp17EqualityComparable for i32 { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }), + ); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); @@ -122,9 +162,20 @@ impl Cpp17EqualityComparable for i32 { impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -133,9 +184,20 @@ impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { impl WeaklyEqualityComparableWith for i32 { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); @@ -196,9 +258,19 @@ impl p1_different_types_Meters { impl Cpp17EqualityComparable for p1_different_types_Meters { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -207,9 +279,19 @@ impl Cpp17EqualityComparable for p1_different_types_Meters { impl Cpp17EqualityComparable for i32 { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) })); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); @@ -218,9 +300,19 @@ impl Cpp17EqualityComparable for i32 { impl WeaklyEqualityComparableWith for p1_different_types_Meters { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(!({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -229,9 +321,19 @@ impl WeaklyEqualityComparableWith for p1_different_types_Meters { impl WeaklyEqualityComparableWith for i32 { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(!({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) })); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); @@ -251,86 +353,21 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().begin())); let __last: Value> = Rc::new(RefCell::new(lengths.decay().end())); - while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind( - __it.borrow().iter_deref(), - ), - LvalueRef::>::bind(__tmp_0.as_pointer().clone()), - ), - ) { - __it.borrow_mut().iter_inc(); - } + while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_0.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() } }), )); - assert!(ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::not_equal( - LvalueRef::>>::bind( - found.as_pointer() - ), - LvalueRef::>>::bind( - Rc::new(RefCell::new(lengths.decay().end())).as_pointer() - ), - ) + assert!(WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind( + found.as_pointer() + ), + LvalueRef::>>::bind( + Rc::new(RefCell::new(lengths.decay().end())).as_pointer() + ), )); assert!((({ (*found.borrow()).iter_deref() }).with(|__s| __s.value) == 2)); - assert!(match ( - Rc::new(RefCell::new( - ({ - let __tmp_2: Value = Rc::new(RefCell::new(7)); - { - let __it: Value> = - Rc::new(RefCell::new(lengths.decay().begin())); - let __last: Value> = - Rc::new(RefCell::new(lengths.decay().end())); - while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind( - __it.borrow().iter_deref(), - ), - LvalueRef::>::bind(__tmp_2.as_pointer().clone()), - ), - ) { - __it.borrow_mut().iter_inc(); - } - __it.borrow().clone() - } - }) - )) - .as_pointer(), - Rc::new(RefCell::new(lengths.decay().end())).as_pointer(), - ) { - (__tmp_1, __tmp_3) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( - LvalueRef::>>::bind( - (__tmp_1).clone(), - ), - LvalueRef::>>::bind( - (__tmp_3).clone(), - ), - )) - } - }); + assert!(match (Rc::new(RefCell::new(({ let __tmp_2 : Value = Rc::new(RefCell::new(7 )); {let __it: Value > = Rc::new(RefCell::new(lengths .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(lengths .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_2.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(lengths .decay() .end() )).as_pointer(),) { (__tmp_1, __tmp_3,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_1 ).clone()), LvalueRef:: >>::bind((__tmp_3 ).clone()), ) } } ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index 787ab38811..146b78e1ee 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -57,9 +57,22 @@ impl p1_each_relation_is_an_operator_Score { impl Cpp17EqualityComparable for p1_each_relation_is_an_operator_Score { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -70,9 +83,22 @@ impl Cpp17EqualityComparable for p1_each_relation_is_an_operator_Score { impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ + p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -83,9 +109,22 @@ impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { impl LessThanComparable for p1_each_relation_is_an_operator_Score { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -96,9 +135,22 @@ impl LessThanComparable for p1_each_relation_is_an_operator_Score { impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -107,9 +159,22 @@ impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_gt((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -118,9 +183,22 @@ impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_le((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -129,9 +207,22 @@ impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_each_relation_is_an_operator_Score::operator_ge((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -218,9 +309,20 @@ impl p1_relations_from_three_way_Level { impl Cpp17EqualityComparable for p1_relations_from_three_way_Level { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -231,9 +333,20 @@ impl Cpp17EqualityComparable for p1_relations_from_three_way_Level { impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -244,9 +357,20 @@ impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { impl LessThanComparable for p1_relations_from_three_way_Level { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -257,9 +381,20 @@ impl LessThanComparable for p1_relations_from_three_way_Level { impl PartiallyOrderedWith for p1_relations_from_three_way_Level { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -268,9 +403,20 @@ impl PartiallyOrderedWith for p1_relations_from_three_way_Level { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -279,9 +425,20 @@ impl PartiallyOrderedWith for p1_relations_from_three_way_Level { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -290,9 +447,20 @@ impl PartiallyOrderedWith for p1_relations_from_three_way_Level { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -400,9 +568,25 @@ impl p1_operator_preferred_over_three_way_Level { impl LessThanComparable for p1_operator_preferred_over_three_way_Level { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -418,9 +602,25 @@ impl LessThanComparable for p1_operator_preferred_over_three_way_Level { impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -434,9 +634,25 @@ impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + p1_operator_preferred_over_three_way_Level::operator_gt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -448,9 +664,25 @@ impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -464,9 +696,25 @@ impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 3b42e6b6c4..5f9dc48433 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -36,9 +36,18 @@ impl p1_3_not_equal_Meters { impl Cpp17EqualityComparableUnsafe for p1_3_not_equal_Meters { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); + let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); + __return.write((unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); return (unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) }); @@ -47,9 +56,18 @@ impl Cpp17EqualityComparableUnsafe for p1_3_not_equal_Meters { impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); + let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); + __return.write((unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); return (unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) }); @@ -88,9 +106,20 @@ impl p1_2_reversed_operands_Meters { impl Cpp17EqualityComparableUnsafe for p1_2_reversed_operands_Meters { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write( + (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }); @@ -99,9 +128,20 @@ impl Cpp17EqualityComparableUnsafe for p1_2_reversed_operands_Meters { impl Cpp17EqualityComparableUnsafe for i32 { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); + __return.write( + (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }); @@ -110,9 +150,20 @@ impl Cpp17EqualityComparableUnsafe for i32 { impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write( + !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); let __rhs = (__rhs.as_ptr() as *const i32); return !(unsafe { @@ -123,9 +174,20 @@ impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { impl WeaklyEqualityComparableWithUnsafe for i32 { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); + __return.write( + !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); return !(unsafe { @@ -184,9 +246,19 @@ impl p1_different_types_Meters { impl Cpp17EqualityComparableUnsafe for p1_different_types_Meters { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + __return + .write((unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); @@ -195,9 +267,19 @@ impl Cpp17EqualityComparableUnsafe for p1_different_types_Meters { impl Cpp17EqualityComparableUnsafe for i32 { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); + __return + .write((unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); @@ -206,9 +288,20 @@ impl Cpp17EqualityComparableUnsafe for i32 { impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write( + !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); let __rhs = (__rhs.as_ptr() as *const i32); return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); @@ -217,9 +310,20 @@ impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { impl WeaklyEqualityComparableWithUnsafe for i32 { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); + __return.write( + !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); @@ -235,51 +339,29 @@ pub unsafe fn test_3() { let mut __tmp_0 = { lengths.begin() }; let mut __tmp_1 = { lengths.end() }; let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind( - &__it, - ), - LvalueRefUnsafe::>>::bind( - &__tmp_1, - ), - )) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&2), - ), - ) { - __it.iter_inc(); - } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ) { __it.iter_inc(); } __it }; - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind( - &found - ), - LvalueRefUnsafe::>>::bind( - &lengths.end() - ), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind( + &found + ), + LvalueRefUnsafe::>>::bind( + &lengths.end() + ), )); assert!((((*found.iter_deref()).value) == (2))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &{ - let mut __tmp_2 = { lengths.begin() }; - let mut __tmp_3 = { lengths.end() }; - let mut __it = (__tmp_2).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), )) { __it.iter_inc(); } - __it - } - ), - LvalueRefUnsafe::>>::bind( - &lengths.end() - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_2 = { lengths.begin() }; + let mut __tmp_3 = { lengths.end() }; + let mut __it = (__tmp_2).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind( + &lengths.end() + ), )); } pub fn main() { diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index 01a8d0c932..bab544a29a 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -66,9 +66,22 @@ impl p1_each_relation_is_an_operator_Score { impl Cpp17EqualityComparableUnsafe for p1_each_relation_is_an_operator_Score { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -79,9 +92,22 @@ impl Cpp17EqualityComparableUnsafe for p1_each_relation_is_an_operator_Score { impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + !(unsafe { + p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return !(unsafe { @@ -92,9 +118,22 @@ impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Scor impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -105,9 +144,22 @@ impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -116,9 +168,22 @@ impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_gt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -127,9 +192,22 @@ impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_le(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -138,9 +216,22 @@ impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); + __return.write( + (unsafe { + p1_each_relation_is_an_operator_Score::operator_ge(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); return (unsafe { @@ -214,9 +305,20 @@ impl p1_relations_from_three_way_Level { impl Cpp17EqualityComparableUnsafe for p1_relations_from_three_way_Level { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write( + (unsafe { p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return (unsafe { @@ -227,9 +329,22 @@ impl Cpp17EqualityComparableUnsafe for p1_relations_from_three_way_Level { impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write( + !(unsafe { + p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return !(unsafe { @@ -240,9 +355,22 @@ impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return libcc2rs::is_lt( @@ -255,9 +383,22 @@ impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return libcc2rs::is_lt( @@ -268,9 +409,22 @@ impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write(libcc2rs::is_gt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return libcc2rs::is_gt( @@ -281,9 +435,22 @@ impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write(libcc2rs::is_lteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return libcc2rs::is_lteq( @@ -294,9 +461,22 @@ impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); + __return.write(libcc2rs::is_gteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); return libcc2rs::is_gteq( @@ -389,9 +569,22 @@ impl p1_operator_preferred_over_three_way_Level { impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); return libcc2rs::is_lt( @@ -404,9 +597,22 @@ impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); return libcc2rs::is_lt( @@ -417,9 +623,22 @@ impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + __return.write( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_gt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); return (unsafe { @@ -428,9 +647,22 @@ impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + __return.write(libcc2rs::is_lteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); return libcc2rs::is_lteq( @@ -441,9 +673,22 @@ impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); + __return.write(libcc2rs::is_gteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); return libcc2rs::is_gteq( diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index 6b4b422c59..e9e0334b26 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -86,9 +86,22 @@ impl p1_convertible_to_Ratio { impl Cpp17EqualityComparable for p1_convertible_to_Ratio { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } == { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } == { @@ -99,9 +112,22 @@ impl Cpp17EqualityComparable for p1_convertible_to_Ratio { impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } != { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } != { @@ -112,9 +138,22 @@ impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { impl LessThanComparable for p1_convertible_to_Ratio { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { @@ -125,9 +164,22 @@ impl LessThanComparable for p1_convertible_to_Ratio { impl PartiallyOrderedWith for p1_convertible_to_Ratio { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { @@ -136,9 +188,22 @@ impl PartiallyOrderedWith for p1_convertible_to_Ratio { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } > { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } > { @@ -147,9 +212,22 @@ impl PartiallyOrderedWith for p1_convertible_to_Ratio { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } <= { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } <= { @@ -158,9 +236,22 @@ impl PartiallyOrderedWith for p1_convertible_to_Ratio { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } >= { + ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } >= { diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 75f2a8a771..3ba8d5319c 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -76,9 +76,21 @@ impl p1_convertible_to_Ratio { impl Cpp17EqualityComparableUnsafe for p1_convertible_to_Ratio { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -88,9 +100,21 @@ impl Cpp17EqualityComparableUnsafe for p1_convertible_to_Ratio { impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + != (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -100,9 +124,21 @@ impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { impl LessThanComparableUnsafe for p1_convertible_to_Ratio { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -112,9 +148,21 @@ impl LessThanComparableUnsafe for p1_convertible_to_Ratio { impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -122,9 +170,21 @@ impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + > (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -132,9 +192,21 @@ impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + <= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) @@ -142,9 +214,21 @@ impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); + let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); + __return.write( + ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) + >= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 7becf3e3d9..80cc1cf576 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -34,9 +34,22 @@ impl p38_insert_range_by_conversion_function_Ratio { impl Cpp17EqualityComparable for p38_insert_range_by_conversion_function_Ratio { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -46,9 +59,22 @@ impl Cpp17EqualityComparable for p38_insert_range_by_conversion_function_Ratio { impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ratio { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -58,9 +84,22 @@ impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ra impl LessThanComparable for p38_insert_range_by_conversion_function_Ratio { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -70,9 +109,22 @@ impl LessThanComparable for p38_insert_range_by_conversion_function_Ratio { impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -80,9 +132,22 @@ impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -90,9 +155,22 @@ impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -100,9 +178,22 @@ impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { + ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } @@ -124,26 +215,7 @@ pub fn test_0() { Rc::new(RefCell::new(ratios.decay())); let __last: Value> = Rc::new(RefCell::new(ratios.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) { - let __i = temp_vec.borrow().len(); - temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); - ConstructibleFrom::construct( - temp_vec.as_pointer().decay().offset(__i), - (LvalueRef::< - Const, - >::bind(__it.borrow().iter_deref()),), - ); - __it.borrow_mut().iter_inc(); - } + while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( temp_vec.as_pointer().decay().offset(__i), (LvalueRef::>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } longs.as_pointer().with_mut(|v: &mut Vec| { v.splice( start_idx..start_idx, @@ -198,26 +270,7 @@ pub fn test_1() { Rc::new(RefCell::new(levels.decay())); let __last: Value> = Rc::new(RefCell::new(levels.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) { - let __i = temp_vec.borrow().len(); - temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); - ConstructibleFrom::construct( - temp_vec.as_pointer().decay().offset(__i), - (LvalueRef::< - Const, - >::bind(__it.borrow().iter_deref()),), - ); - __it.borrow_mut().iter_inc(); - } + while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( temp_vec.as_pointer().decay().offset(__i), (LvalueRef::>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } ints.as_pointer().with_mut(|v: &mut Vec| { v.splice( start_idx..start_idx, diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index 4dd364a683..bd52c1d729 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -31,9 +31,24 @@ impl p38_insert_range_by_conversion_function_Ratio { impl Cpp17EqualityComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) == (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -46,9 +61,24 @@ impl Cpp17EqualityComparableUnsafe for p38_insert_range_by_conversion_function_R impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_function_Ratio { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) != (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -61,9 +91,24 @@ impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_funct impl LessThanComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) < (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -76,9 +121,24 @@ impl LessThanComparableUnsafe for p38_insert_range_by_conversion_function_Ratio impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Ratio { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) < (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -89,9 +149,24 @@ impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Rati } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) > (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -102,9 +177,24 @@ impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Rati } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) <= (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -115,9 +205,24 @@ impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Rati } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); + __return.write( + ((unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) + }) >= (unsafe { + p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) + })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); return ((unsafe { @@ -140,7 +245,7 @@ pub unsafe fn test_0() { __tmp_0.iter_distance(&UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ratios.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_by_conversion_function_Ratio as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_1 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } + while <*mut p38_insert_range_by_conversion_function_Ratio as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_1 ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } longs.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr().add(__off)) }; @@ -185,7 +290,7 @@ pub unsafe fn test_1() { __tmp_2.iter_distance(&UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = levels.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( <*mut p38_insert_range_best_conversion_function_Level as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_3 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } + while <*mut p38_insert_range_best_conversion_function_Level as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe::>::bind(&__it), LvalueRefUnsafe::>::bind(&__tmp_3 ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } ints.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(ints.as_mut_ptr().add(__off)) }; diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index d3dffb2181..9ed544d65e 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -48,9 +48,18 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { impl Cpp17EqualityComparable for p16_rebind_member_Alloc_std_pair_const_int__int__ { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -59,9 +68,18 @@ impl Cpp17EqualityComparable for p16_rebind_member_Alloc_std_pair_const_int__int impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int__int__ { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index 9178501f0b..630af1033a 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -43,9 +43,23 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { impl Cpp17EqualityComparableUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + __return.write( + (unsafe { + let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); return (unsafe { @@ -57,9 +71,23 @@ impl Cpp17EqualityComparableUnsafe for p16_rebind_member_Alloc_std_pair_const_in impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); + __return.write( + !(unsafe { + let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); return !(unsafe { diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 77405151a6..1cc7ed0c44 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -41,9 +41,20 @@ impl table29_member_operator_Version { impl LessThanComparable for table29_member_operator_Version { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ table29_member_operator_Version::operator_lt((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -63,15 +74,13 @@ pub fn test_1() { minor: 0, })); assert!( - (if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - old_version.as_pointer().clone() - ), - LvalueRef::>::bind( - new_version.as_pointer().clone() - ), - ) + (if ::is_less( + LvalueRef::>::bind( + old_version.as_pointer().clone() + ), + LvalueRef::>::bind( + new_version.as_pointer().clone() + ), ) { new_version.as_pointer() } else { @@ -81,15 +90,13 @@ pub fn test_1() { == 2) ); assert!( - (if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - new_version.as_pointer().clone() - ), - LvalueRef::>::bind( - old_version.as_pointer().clone() - ), - ) + (if ::is_less( + LvalueRef::>::bind( + new_version.as_pointer().clone() + ), + LvalueRef::>::bind( + old_version.as_pointer().clone() + ), ) { new_version.as_pointer() } else { @@ -123,55 +130,7 @@ pub fn test_1() { ({ { (*versions.borrow())[2_usize] }.major } == 2) && ({ { (*versions.borrow())[2_usize] }.minor } == 1) ); - assert!( - ({ - let __it: Value> = - Rc::new(RefCell::new(versions.decay().begin())); - let __last: Value> = - Rc::new(RefCell::new(versions.decay().end())); - let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) { - __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind( - __it.as_pointer(), - ), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - )) { - if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - __best.iter_deref(), - ), - LvalueRef::>::bind( - __it.borrow().iter_deref(), - ), - ), - ) { - __best = __it.borrow().clone(); - } - __it.borrow_mut().iter_inc(); - } - } - __best - } - .iter_deref() - .with(|__s| __s.minor) - == 1) - ); + assert!(( {let __it: Value > = Rc::new(RefCell::new(versions .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(versions .decay() .end() )); let mut __best = __it.borrow().clone(); if as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { __it.borrow_mut().iter_inc(); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { if ::is_less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); } } __best} .iter_deref() .with(|__s| __s . minor ) == 1 ) ); let downloads: Value< Map, Value)>, > = Rc::new(RefCell::new(Map::new())); @@ -243,9 +202,24 @@ impl table29_other_operator_shapes_Weight { impl LessThanComparable for table29_other_operator_shapes_Weight { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + table29_other_operator_shapes_Weight::operator_lt((__lhs).clone(), { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -277,9 +251,18 @@ pub struct table29_other_operator_shapes_Height { impl LessThanComparable for table29_other_operator_shapes_Height { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); @@ -324,9 +307,22 @@ impl table29_other_operator_shapes_Depth { impl LessThanComparable for table29_other_operator_shapes_Depth { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -339,9 +335,22 @@ impl LessThanComparable for table29_other_operator_shapes_Depth { impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -352,9 +361,22 @@ impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -365,9 +387,22 @@ impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -378,9 +413,22 @@ impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -401,14 +449,12 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 5, })); - if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - (__tmp_5.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_6.as_pointer()).clone(), - ), + if ::is_less( + LvalueRef::>::bind( + (__tmp_5.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_6.as_pointer()).clone(), ), ) { (__tmp_6.as_pointer()) @@ -428,14 +474,12 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 30, })); - if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - (__tmp_7.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_8.as_pointer()).clone(), - ), + if ::is_less( + LvalueRef::>::bind( + (__tmp_7.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_8.as_pointer()).clone(), ), ) { (__tmp_7.as_pointer()) @@ -455,14 +499,12 @@ pub fn test_3() { Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 4, })); - if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind( - (__tmp_9.as_pointer()).clone(), - ), - LvalueRef::>::bind( - (__tmp_10.as_pointer()).clone(), - ), + if ::is_less( + LvalueRef::>::bind( + (__tmp_9.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_10.as_pointer()).clone(), ), ) { (__tmp_10.as_pointer()) @@ -503,9 +545,25 @@ impl pairs_spec_p3_members_order_pairs_Rank { impl LessThanComparable for pairs_spec_p3_members_order_pairs_Rank { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + pairs_spec_p3_members_order_pairs_Rank::operator_lt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -535,77 +593,15 @@ pub fn test_4() { )), Rc::new(RefCell::new(5)), ))); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - low.as_pointer() - ), - LvalueRef::, Value)>>::bind( - high.as_pointer() - ), - ))); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - high.as_pointer() - ), - LvalueRef::, Value)>>::bind( - high_later.as_pointer() - ), - ))); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - low.as_pointer() - ), - LvalueRef::, Value)>>::bind( - high_later.as_pointer() - ), - ))); - assert!(!ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - high.as_pointer() - ), - LvalueRef::, Value)>>::bind( - low.as_pointer() - ), - ))); - assert!(!ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - high_later.as_pointer() - ), - LvalueRef::, Value)>>::bind( - high.as_pointer() - ), - ))); - assert!( - !(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind( - high.as_pointer() - ), - LvalueRef::, Value)>>::bind( - low.as_pointer() - ), - ))) - ); + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(low .as_pointer() ), LvalueRef::, Value)>>::bind(high .as_pointer() ), ) ); + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(high .as_pointer() ), LvalueRef::, Value)>>::bind(high_later .as_pointer() ), ) ); + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(low .as_pointer() ), LvalueRef::, Value)>>::bind(high_later .as_pointer() ), ) ); + assert!(!<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(high .as_pointer() ), LvalueRef::, Value)>>::bind(low .as_pointer() ), ) ); + assert!(!<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(high_later .as_pointer() ), LvalueRef::, Value)>>::bind(high .as_pointer() ), ) ); + assert!(! ( ( <(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(high .as_pointer() ), LvalueRef::, Value)>>::bind(low .as_pointer() ), ) ) ) ); assert!( ({ - ( (*(*if ConvertibleTo::::convert_value(<(Value, Value) as LessThanComparable>::less( LvalueRef::, Value) >>::bind(low .as_pointer() .clone()), LvalueRef::, Value) >>::bind(high .as_pointer() .clone()), )) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) + ( (*(*if <(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value) >>::bind(low .as_pointer() .clone()), LvalueRef::, Value) >>::bind(high .as_pointer() .clone()), ) { high .as_pointer() } else { low .as_pointer() } .upgrade().deref()) .1.borrow()) == 0 ) }) ); } diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index ae2525da3c..7d4b429147 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -37,9 +37,20 @@ impl table29_member_operator_Version { impl LessThanComparableUnsafe for table29_member_operator_Version { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const table29_member_operator_Version); + let __rhs = (__rhs.as_ptr() as *const table29_member_operator_Version); + __return.write( + (unsafe { table29_member_operator_Version::operator_lt(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_member_operator_Version); let __rhs = (__rhs.as_ptr() as *const table29_member_operator_Version); return (unsafe { @@ -56,11 +67,9 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -74,11 +83,9 @@ pub unsafe fn test_1() { (((*{ let __a: *const _ = &mut old_version; let __b: *const _ = &mut new_version; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -101,18 +108,14 @@ pub unsafe fn test_1() { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const table29_member_operator_Version; let __b = __tmp_0.iter_at(__y) as *const table29_member_operator_Version; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -130,7 +133,7 @@ pub unsafe fn test_1() { assert!(((versions[(0_usize)].major) == (1)) && ((versions[(0_usize)].minor) == (9))); assert!(((versions[(1_usize)].major) == (2)) && ((versions[(1_usize)].minor) == (0))); assert!(((versions[(2_usize)].major) == (2)) && ((versions[(2_usize)].minor) == (1))); - assert!(( ( ( * { let mut __tmp_1 = { versions .begin() };let mut __tmp_2 = { versions .end() }; let mut __best = __tmp_1 .clone(); if ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_1 ), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ), ) { let mut __it = (__tmp_1 ).clone(); __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ), ) { if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), )) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . minor ) == ( 1 ) ) ); + assert!(( ( ( * { let mut __tmp_1 = { versions .begin() };let mut __tmp_2 = { versions .end() }; let mut __best = __tmp_1 .clone(); if as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_1 ), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ) { let mut __it = (__tmp_1 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ) { if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . minor ) == ( 1 ) ) ); let mut downloads: UnsafeMap< table29_member_operator_Version, (table29_member_operator_Version, i32), @@ -169,9 +172,22 @@ impl table29_other_operator_shapes_Weight { impl LessThanComparableUnsafe for table29_other_operator_shapes_Weight { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Weight); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Weight); + __return.write( + (unsafe { + table29_other_operator_shapes_Weight::operator_lt(&raw const (*__lhs), (*__rhs)) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Weight); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Weight); return (unsafe { @@ -198,9 +214,23 @@ pub struct table29_other_operator_shapes_Height { impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Height); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); + __return.write( + (unsafe { + let _lhs: *const table29_other_operator_shapes_Height = __lhs; + operator_lt_2(_lhs, __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Height); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); return (unsafe { @@ -245,9 +275,22 @@ impl table29_other_operator_shapes_Depth { impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + __return.write(libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); return libcc2rs::is_lt( @@ -260,9 +303,22 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + __return.write(libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); return libcc2rs::is_lt( @@ -273,9 +329,22 @@ impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + __return.write(libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); return libcc2rs::is_gt( @@ -286,9 +355,22 @@ impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + __return.write(libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); return libcc2rs::is_lteq( @@ -299,9 +381,22 @@ impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); + __return.write(libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); return libcc2rs::is_gteq( @@ -321,11 +416,9 @@ pub unsafe fn test_3() { (*{ let __a: *const _ = (&mut __tmp_3); let __b: *const _ = (&mut __tmp_4); - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -344,11 +437,9 @@ pub unsafe fn test_3() { (*{ let __a: *const _ = (&mut __tmp_5); let __b: *const _ = (&mut __tmp_6); - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -367,11 +458,9 @@ pub unsafe fn test_3() { (*{ let __a: *const _ = (&mut __tmp_7); let __b: *const _ = (&mut __tmp_8); - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -409,9 +498,22 @@ impl pairs_spec_p3_members_order_pairs_Rank { impl LessThanComparableUnsafe for pairs_spec_p3_members_order_pairs_Rank { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); + let __rhs = (__rhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); + __return.write( + (unsafe { + pairs_spec_p3_members_order_pairs_Rank::operator_lt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); let __rhs = (__rhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); return (unsafe { @@ -426,62 +528,56 @@ pub unsafe fn test_4() { ((pairs_spec_p3_members_order_pairs_Rank { value: 2 }), 0); let mut high_later: (pairs_spec_p3_members_order_pairs_Rank, i32) = ((pairs_spec_p3_members_order_pairs_Rank { value: 2 }), 5); - assert!(ConvertibleToUnsafe::::convert_value( - <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + assert!( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&low), LvalueRefUnsafe::>::bind(&high), ) - )); - assert!(ConvertibleToUnsafe::::convert_value( - <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + ); + assert!( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&high), LvalueRefUnsafe::>::bind( &high_later ), ) - )); - assert!(ConvertibleToUnsafe::::convert_value( - <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + ); + assert!( + <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&low), LvalueRefUnsafe::>::bind( &high_later ), ) - )); - assert!(!ConvertibleToUnsafe::::convert_value( - <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + ); + assert!( + !<(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&high), LvalueRefUnsafe::>::bind(&low), ) - )); - assert!(!ConvertibleToUnsafe::::convert_value( - <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::less( + ); + assert!( + !<(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind( &high_later ), LvalueRefUnsafe::>::bind(&high), ) - )); + ); assert!( - !(ConvertibleToUnsafe::::convert_value(<( - pairs_spec_p3_members_order_pairs_Rank, - i32 - ) as LessThanComparableUnsafe>::less( + !(<(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&high), LvalueRefUnsafe::>::bind(&low), - ))) + )) ); assert!( (((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if ConvertibleToUnsafe::::convert_value(<( - pairs_spec_p3_members_order_pairs_Rank, - i32, - ) as LessThanComparableUnsafe>::less( + if <(pairs_spec_p3_members_order_pairs_Rank, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index e4d9303eca..62a2a12b99 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -121,9 +121,32 @@ impl Destructible for p2_condition_variable_lives_for_whole_statement_ConvertsTo impl Cpp17EqualityComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } == { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -146,9 +169,32 @@ impl WeaklyEqualityComparableWith { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } != { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -169,9 +215,32 @@ impl WeaklyEqualityComparableWith impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } < { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -192,9 +261,32 @@ impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_Conv impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } < { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -213,9 +305,32 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } > { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -234,9 +349,32 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } <= { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -255,9 +393,32 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__lhs).clone(), + ) + }) + } >= { + ({ + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + (__rhs).clone(), + ) + }) + }), + ); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index 4f8614a052..bc8f802a46 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -97,13 +97,38 @@ impl Cpp17EqualityComparableUnsafe { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) == (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -124,13 +149,38 @@ impl WeaklyEqualityComparableWithUnsafe { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) != (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -149,13 +199,38 @@ impl WeaklyEqualityComparableWithUnsafe impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) < (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -174,13 +249,38 @@ impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statemen impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) < (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -197,13 +297,38 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) > (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -220,13 +345,38 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) <= (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() @@ -243,13 +393,38 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe< + Const, + >, + __rhs: LvalueRefUnsafe< + Const, + >, + ) { + let __lhs = (__lhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + let __rhs = (__rhs.as_ptr() + as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); + __return.write( + ((unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__lhs), + ) + }) >= (unsafe { + p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( + &raw const (*__rhs), + ) + })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe< Const, >, __rhs: LvalueRefUnsafe< Const, >, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); let __rhs = (__rhs.as_ptr() diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index 838235d049..6716633aeb 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -60,9 +60,20 @@ impl p1_defaulted_three_way_Version { impl Cpp17EqualityComparable for p1_defaulted_three_way_Version { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -71,9 +82,20 @@ impl Cpp17EqualityComparable for p1_defaulted_three_way_Version { impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -84,9 +106,20 @@ impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { impl LessThanComparable for p1_defaulted_three_way_Version { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -97,9 +130,20 @@ impl LessThanComparable for p1_defaulted_three_way_Version { impl PartiallyOrderedWith for p1_defaulted_three_way_Version { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -108,9 +152,20 @@ impl PartiallyOrderedWith for p1_defaulted_three_way_Version { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -119,9 +174,20 @@ impl PartiallyOrderedWith for p1_defaulted_three_way_Version { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -130,9 +196,20 @@ impl PartiallyOrderedWith for p1_defaulted_three_way_Version { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -259,9 +336,20 @@ impl p1_user_written_three_way_Money { impl Cpp17EqualityComparable for p1_user_written_three_way_Money { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -272,9 +360,20 @@ impl Cpp17EqualityComparable for p1_user_written_three_way_Money { impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -285,9 +384,20 @@ impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { impl LessThanComparable for p1_user_written_three_way_Money { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -298,9 +408,20 @@ impl LessThanComparable for p1_user_written_three_way_Money { impl PartiallyOrderedWith for p1_user_written_three_way_Money { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -309,9 +430,20 @@ impl PartiallyOrderedWith for p1_user_written_three_way_Money { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -320,9 +452,20 @@ impl PartiallyOrderedWith for p1_user_written_three_way_Money { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -331,9 +474,20 @@ impl PartiallyOrderedWith for p1_user_written_three_way_Money { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -427,9 +581,20 @@ impl p1_weaker_category_Temperature { impl Cpp17EqualityComparable for p1_weaker_category_Temperature { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -438,9 +603,20 @@ impl Cpp17EqualityComparable for p1_weaker_category_Temperature { impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ @@ -451,9 +627,20 @@ impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { impl LessThanComparable for p1_weaker_category_Temperature { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -464,9 +651,20 @@ impl LessThanComparable for p1_weaker_category_Temperature { impl PartiallyOrderedWith for p1_weaker_category_Temperature { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -475,9 +673,20 @@ impl PartiallyOrderedWith for p1_weaker_category_Temperature { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -486,9 +695,20 @@ impl PartiallyOrderedWith for p1_weaker_category_Temperature { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -497,9 +717,20 @@ impl PartiallyOrderedWith for p1_weaker_category_Temperature { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( @@ -578,9 +809,22 @@ impl p1_three_way_without_equality_Rank { impl LessThanComparable for p1_three_way_without_equality_Rank { type Result = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -593,9 +837,22 @@ impl LessThanComparable for p1_three_way_without_equality_Rank { impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( @@ -606,9 +863,22 @@ impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( @@ -619,9 +889,22 @@ impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( @@ -632,9 +915,22 @@ impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index c4d2570526..c975d5b36e 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -56,9 +56,20 @@ impl p1_defaulted_three_way_Version { impl Cpp17EqualityComparableUnsafe for p1_defaulted_three_way_Version { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write( + (unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return (unsafe { @@ -69,9 +80,20 @@ impl Cpp17EqualityComparableUnsafe for p1_defaulted_three_way_Version { impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write( + !(unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return !(unsafe { @@ -82,9 +104,20 @@ impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write(libcc2rs::is_lt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return libcc2rs::is_lt( @@ -95,9 +128,20 @@ impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write(libcc2rs::is_lt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return libcc2rs::is_lt( @@ -106,9 +150,20 @@ impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write(libcc2rs::is_gt( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return libcc2rs::is_gt( @@ -117,9 +172,20 @@ impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write(libcc2rs::is_lteq( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return libcc2rs::is_lteq( @@ -128,9 +194,20 @@ impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); + let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); + __return.write(libcc2rs::is_gteq( + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); return libcc2rs::is_gteq( @@ -232,9 +309,20 @@ impl p1_user_written_three_way_Money { impl Cpp17EqualityComparableUnsafe for p1_user_written_three_way_Money { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write( + (unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return (unsafe { @@ -245,9 +333,20 @@ impl Cpp17EqualityComparableUnsafe for p1_user_written_three_way_Money { impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write( + !(unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return !(unsafe { @@ -258,9 +357,20 @@ impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { impl LessThanComparableUnsafe for p1_user_written_three_way_Money { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write(libcc2rs::is_lt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return libcc2rs::is_lt( @@ -271,9 +381,20 @@ impl LessThanComparableUnsafe for p1_user_written_three_way_Money { impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write(libcc2rs::is_lt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return libcc2rs::is_lt( @@ -282,9 +403,20 @@ impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write(libcc2rs::is_gt( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return libcc2rs::is_gt( @@ -293,9 +425,20 @@ impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write(libcc2rs::is_lteq( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return libcc2rs::is_lteq( @@ -304,9 +447,20 @@ impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); + let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); + __return.write(libcc2rs::is_gteq( + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); return libcc2rs::is_gteq( @@ -394,9 +548,20 @@ impl p1_weaker_category_Temperature { impl Cpp17EqualityComparableUnsafe for p1_weaker_category_Temperature { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write( + (unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return (unsafe { @@ -407,9 +572,20 @@ impl Cpp17EqualityComparableUnsafe for p1_weaker_category_Temperature { impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write( + !(unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return !(unsafe { @@ -420,9 +596,20 @@ impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { impl LessThanComparableUnsafe for p1_weaker_category_Temperature { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write(libcc2rs::is_lt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return libcc2rs::is_lt( @@ -433,9 +620,20 @@ impl LessThanComparableUnsafe for p1_weaker_category_Temperature { impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write(libcc2rs::is_lt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return libcc2rs::is_lt( @@ -444,9 +642,20 @@ impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write(libcc2rs::is_gt( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return libcc2rs::is_gt( @@ -455,9 +664,20 @@ impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write(libcc2rs::is_lteq( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return libcc2rs::is_lteq( @@ -466,9 +686,20 @@ impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); + let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); + __return.write(libcc2rs::is_gteq( + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); return libcc2rs::is_gteq( @@ -539,9 +770,22 @@ impl p1_three_way_without_equality_Rank { impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); return libcc2rs::is_lt( @@ -554,9 +798,22 @@ impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + __return.write(libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); return libcc2rs::is_lt( @@ -567,9 +824,22 @@ impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + __return.write(libcc2rs::is_gt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); return libcc2rs::is_gt( @@ -580,9 +850,22 @@ impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + __return.write(libcc2rs::is_lteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); return libcc2rs::is_lteq( @@ -593,9 +876,22 @@ impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); + let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); + __return.write(libcc2rs::is_gteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); return libcc2rs::is_gteq( diff --git a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs index dee72ccfb8..3c4b0fdbaa 100644 --- a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs @@ -156,104 +156,75 @@ pub fn test_4() { Rc::new(RefCell::new(0)), ))); assert!( - !(ConvertibleTo::::convert_value(::equal( + !(::is_equal( LvalueRef::>::bind((*a.borrow()).0.as_pointer()), LvalueRef::>::bind((*b.borrow()).0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + ) && ::is_equal( LvalueRef::>::bind((*a.borrow()).1.as_pointer()), LvalueRef::>::bind((*b.borrow()).1.as_pointer()), - ))) + )) ); assert!( ({ - !(!(ConvertibleTo::::convert_value(::equal( + !(!(::is_equal( LvalueRef::>::bind((*a.borrow()).0.as_pointer()), LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - )) && ConvertibleTo::::convert_value( - ::equal( - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - ), + ) && ::is_equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), ))) }) ); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a.as_pointer()), LvalueRef::, Value)>>::bind(b.as_pointer()), - ))); + )); assert!( - !(ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind(b.as_pointer()), - LvalueRef::, Value)>>::bind(a.as_pointer()), - ) + !(<(Value, Value) as LessThanComparable>::is_less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), )) ); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(b.as_pointer()), LvalueRef::, Value)>>::bind(c.as_pointer()), - ))); - assert!(!ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( + )); + assert!(!<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a.as_pointer()), LvalueRef::, Value)>>::bind(a.as_pointer()), - ))); + )); assert!( - !(!ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind(b.as_pointer()), - LvalueRef::, Value)>>::bind(c.as_pointer()), - ) + !(!<(Value, Value) as LessThanComparable>::is_less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), )) ); - assert!(ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( + assert!(<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(b.as_pointer()), LvalueRef::, Value)>>::bind(c.as_pointer()), - ))); + )); assert!( - !(ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind(a.as_pointer()), - LvalueRef::, Value)>>::bind(a.as_pointer()), - ) + !(<(Value, Value) as LessThanComparable>::is_less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(a.as_pointer()), )) ); - assert!(!ConvertibleTo::::convert_value(<( - Value, - Value - ) as LessThanComparable>::less( + assert!(!<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(c.as_pointer()), LvalueRef::, Value)>>::bind(a.as_pointer()), - ))); + )); assert!( - !(!ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind(a.as_pointer()), - LvalueRef::, Value)>>::bind(b.as_pointer()), - ) - )) - ); - let mut ordered: bool = (ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( + !(!<(Value, Value) as LessThanComparable>::is_less( LvalueRef::, Value)>>::bind(a.as_pointer()), LvalueRef::, Value)>>::bind(b.as_pointer()), - ), - )) && (ConvertibleTo::::convert_value( - <(Value, Value) as LessThanComparable>::less( - LvalueRef::, Value)>>::bind(b.as_pointer()), - LvalueRef::, Value)>>::bind(c.as_pointer()), - ), + )) + ); + let mut ordered: bool = (<(Value, Value) as LessThanComparable>::is_less( + LvalueRef::, Value)>>::bind(a.as_pointer()), + LvalueRef::, Value)>>::bind(b.as_pointer()), + )) && (<(Value, Value) as LessThanComparable>::is_less( + LvalueRef::, Value)>>::bind(b.as_pointer()), + LvalueRef::, Value)>>::bind(c.as_pointer()), )); assert!(ordered); } @@ -326,28 +297,24 @@ pub fn test_7() { ))); assert!( ({ - ConvertibleTo::::convert_value( - as Cpp17EqualityComparable>::equal( - LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), - LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), - ), - ) && ConvertibleTo::::convert_value(::equal( + as Cpp17EqualityComparable>::is_equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), + ) && ::is_equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), - )) + ) }) ); (*y.borrow_mut()) = 5; assert!( - !(ConvertibleTo::::convert_value( - as Cpp17EqualityComparable>::equal( - LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), - LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), - ) - ) && ConvertibleTo::::convert_value(::equal( + !( as Cpp17EqualityComparable>::is_equal( + LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), + LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), + ) && ::is_equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), - ))) + )) ); } pub fn test_8() { diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index 1f8dba0c8e..601bc297bb 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -172,103 +172,73 @@ pub unsafe fn test_4() { let mut b: (i32, i32) = (1, 3); let mut c: (i32, i32) = (2, 0); assert!( - !(ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a.0), - LvalueRefUnsafe::>::bind(&b.0), - ) - ) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a.1), - LvalueRefUnsafe::>::bind(&b.1), - ), + !(::is_equal( + LvalueRefUnsafe::>::bind(&a.0), + LvalueRefUnsafe::>::bind(&b.0), + ) && ::is_equal( + LvalueRefUnsafe::>::bind(&a.1), + LvalueRefUnsafe::>::bind(&b.1), )) ); assert!( - !(!(ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a.0), - LvalueRefUnsafe::>::bind(&a.0), - ) - ) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a.1), - LvalueRefUnsafe::>::bind(&a.1), - ), + !(!(::is_equal( + LvalueRefUnsafe::>::bind(&a.0), + LvalueRefUnsafe::>::bind(&a.0), + ) && ::is_equal( + LvalueRefUnsafe::>::bind(&a.1), + LvalueRefUnsafe::>::bind(&a.1), ))) ); - assert!(ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&a), - LvalueRefUnsafe::>::bind(&b), - ) + assert!(<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&b), )); assert!( - !(ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&b), - LvalueRefUnsafe::>::bind(&a), - ) + !(<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&a), )) ); - assert!(ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&b), - LvalueRefUnsafe::>::bind(&c), - ) + assert!(<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), )); - assert!(!ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&a), - LvalueRefUnsafe::>::bind(&a), - ) + assert!(!<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&a), )); assert!( - !(!ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&b), - LvalueRefUnsafe::>::bind(&c), - ) - )) - ); - assert!(ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( + !(!<(i32, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&b), LvalueRefUnsafe::>::bind(&c), - ) - )); - assert!( - !(ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&a), - LvalueRefUnsafe::>::bind(&a), - ) )) ); - assert!(!ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&c), - LvalueRefUnsafe::>::bind(&a), - ) + assert!(<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), )); assert!( - !(!ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&a), - LvalueRefUnsafe::>::bind(&b), - ) + !(<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&a), )) ); - let mut ordered: bool = (ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( + assert!(!<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&c), + LvalueRefUnsafe::>::bind(&a), + )); + assert!( + !(!<(i32, i32) as LessThanComparableUnsafe>::is_less( LvalueRefUnsafe::>::bind(&a), LvalueRefUnsafe::>::bind(&b), - ), - )) && (ConvertibleToUnsafe::::convert_value( - <(i32, i32) as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(&b), - LvalueRefUnsafe::>::bind(&c), - ), + )) + ); + let mut ordered: bool = (<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&a), + LvalueRefUnsafe::>::bind(&b), + )) && (<(i32, i32) as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(&b), + LvalueRefUnsafe::>::bind(&c), )); assert!(ordered); } @@ -316,30 +286,22 @@ pub unsafe fn test_7() { let mut to_x: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut x), 0); let mut to_y: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut y), 0); assert!( - ConvertibleToUnsafe::::convert_value( - as Cpp17EqualityComparableUnsafe>::equal( - LvalueRefUnsafe::>>::bind(&to_x.0), - LvalueRefUnsafe::>>::bind(&to_y.0), - ) - ) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&to_x.1), - LvalueRefUnsafe::>::bind(&to_y.1), - ) + as Cpp17EqualityComparableUnsafe>::is_equal( + LvalueRefUnsafe::>>::bind(&to_x.0), + LvalueRefUnsafe::>>::bind(&to_y.0), + ) && ::is_equal( + LvalueRefUnsafe::>::bind(&to_x.1), + LvalueRefUnsafe::>::bind(&to_y.1), ) ); y = 5; assert!( - !(ConvertibleToUnsafe::::convert_value( - as Cpp17EqualityComparableUnsafe>::equal( - LvalueRefUnsafe::>>::bind(&to_x.0), - LvalueRefUnsafe::>>::bind(&to_y.0), - ) - ) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&to_x.1), - LvalueRefUnsafe::>::bind(&to_y.1), - ), + !( as Cpp17EqualityComparableUnsafe>::is_equal( + LvalueRefUnsafe::>>::bind(&to_x.0), + LvalueRefUnsafe::>>::bind(&to_y.0), + ) && ::is_equal( + LvalueRefUnsafe::>::bind(&to_x.1), + LvalueRefUnsafe::>::bind(&to_y.1), )) ); } diff --git a/tests/ub/out/refcount/max.rs b/tests/ub/out/refcount/max.rs index 1f16e3f9ca..d12417dc9b 100644 --- a/tests/ub/out/refcount/max.rs +++ b/tests/ub/out/refcount/max.rs @@ -14,10 +14,10 @@ fn main_0() -> i32 { let a: Ptr = ({ let __tmp_0: Value = Rc::new(RefCell::new(2)); let __tmp_1: Value = Rc::new(RefCell::new(1)); - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), - )) { + ) { __tmp_0.as_pointer() } else { __tmp_1.as_pointer() @@ -26,10 +26,10 @@ fn main_0() -> i32 { let b: Ptr = ({ let __tmp_2: Value = Rc::new(RefCell::new(1)); let __tmp_3: Value = Rc::new(RefCell::new(2)); - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(__tmp_2.as_pointer().clone()), LvalueRef::>::bind(__tmp_3.as_pointer().clone()), - )) { + ) { __tmp_3.as_pointer() } else { __tmp_2.as_pointer() diff --git a/tests/ub/out/unsafe/max.rs b/tests/ub/out/unsafe/max.rs index f6abed652f..e914a88029 100644 --- a/tests/ub/out/unsafe/max.rs +++ b/tests/ub/out/unsafe/max.rs @@ -19,10 +19,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -35,10 +35,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 94e211bf62..7ea2b49730 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -117,9 +117,15 @@ impl Counter { impl Cpp17EqualityComparable for Counter { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Counter::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Counter::operator_eq((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/container_element_receiver.rs b/tests/unit/out/refcount/container_element_receiver.rs index 2eb597788b..3de54a513f 100644 --- a/tests/unit/out/refcount/container_element_receiver.rs +++ b/tests/unit/out/refcount/container_element_receiver.rs @@ -41,12 +41,10 @@ pub fn sum_1(v: Ptr>) -> i32 { { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { - (__tmp_0,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( - LvalueRef::>>::bind(it.as_pointer()), - LvalueRef::>>::bind((__tmp_0).clone()), - )) - } + (__tmp_0,) => WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_0).clone()), + ), } { 'for_body: { total += (({ (*it.borrow()).iter_deref() }).read()); diff --git a/tests/unit/out/refcount/copy_ctor.rs b/tests/unit/out/refcount/copy_ctor.rs index a59fcd59ac..03f6c5865b 100644 --- a/tests/unit/out/refcount/copy_ctor.rs +++ b/tests/unit/out/refcount/copy_ctor.rs @@ -473,11 +473,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(vec_.decay().begin())); let __last: Value> = Rc::new(RefCell::new(vec_.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index 9c9fe83903..4ce59b4127 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -28,17 +28,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_2.as_pointer().clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -48,10 +44,10 @@ fn main_0() -> i32 { assert!( match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { (__tmp_3,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + WeaklyEqualityComparableWith::is_not_equal( LvalueRef::>>::bind(it.as_pointer()), LvalueRef::>>::bind((__tmp_3).clone()), - )) + ) } } ); diff --git a/tests/unit/out/refcount/emplace_receiver_alias.rs b/tests/unit/out/refcount/emplace_receiver_alias.rs index 65d2f0b55b..cb6c71c4a5 100644 --- a/tests/unit/out/refcount/emplace_receiver_alias.rs +++ b/tests/unit/out/refcount/emplace_receiver_alias.rs @@ -36,11 +36,9 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( (alias).decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/emplace_receiver_order.rs b/tests/unit/out/refcount/emplace_receiver_order.rs index ff6f034eb6..c80384277b 100644 --- a/tests/unit/out/refcount/emplace_receiver_order.rs +++ b/tests/unit/out/refcount/emplace_receiver_order.rs @@ -43,11 +43,9 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -74,11 +72,9 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new( rows.decay().offset(0_usize).decay().offset((3) as isize), )); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 1370029f23..1fc640821a 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -32,7 +32,16 @@ impl P { } impl Cpp17EqualityComparable for P { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ P::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ P::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -66,17 +75,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(({ (*v_begin.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new(({ (*v_end.borrow()).clone() }))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_3.as_pointer().clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -84,12 +89,10 @@ fn main_0() -> i32 { }), )); let mut v_result_true: bool = match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { - (__tmp_4,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( - LvalueRef::>>::bind(it.as_pointer()), - LvalueRef::>>::bind((__tmp_4).clone()), - )) - } + (__tmp_4,) => WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_4).clone()), + ), }; let m: Value, Value)>> = Rc::new(RefCell::new(Map::new())); match (Rc::new(RefCell::new(1)).as_pointer(),) { @@ -118,16 +121,15 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - let mut m_result_true: bool = - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( - LvalueRef::, Value)>>>::bind( - m_begin.as_pointer(), - ), - LvalueRef::, Value)>>>::bind( - m_end.as_pointer(), - ), - )); - assert!(( ( v_result_true ) && ( m_result_true ) ) && ( match (Rc::new(RefCell::new(({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(v .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(v .decay() .begin() )); while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), )) && !ConvertibleTo::::convert_value(>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(v .decay() .begin() )).as_pointer(),) { (__tmp_8, __tmp_10,) => { ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef:: >>::bind((__tmp_8 ).clone()), LvalueRef:: >>::bind((__tmp_10 ).clone()), )) } } ) ); + let mut m_result_true: bool = WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::, Value)>>>::bind( + m_begin.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + m_end.as_pointer(), + ), + ); + assert!(( ( v_result_true ) && ( m_result_true ) ) && ( match (Rc::new(RefCell::new(({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(v .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(v .decay() .begin() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(v .decay() .begin() )).as_pointer(),) { (__tmp_8, __tmp_10,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_8 ).clone()), LvalueRef:: >>::bind((__tmp_10 ).clone()), ) } } ) ); let w: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5]))); assert!(match ( Rc::new(RefCell::new( @@ -138,18 +140,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_12.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_12.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -161,10 +157,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(3_isize))).as_pointer(), ) { (__tmp_11, __tmp_13) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_11).clone()), LvalueRef::>>::bind((__tmp_13).clone()), - )) + ) } }); assert!(match ( @@ -176,18 +172,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_15.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -199,10 +189,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().end())).as_pointer(), ) { (__tmp_14, __tmp_16) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_14).clone()), LvalueRef::>>::bind((__tmp_16).clone()), - )) + ) } }); assert!(match ( @@ -214,18 +204,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(2_isize))); let __last: Value> = Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_18.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_18.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -237,10 +221,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))).as_pointer(), ) { (__tmp_17, __tmp_19) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_17).clone()), LvalueRef::>>::bind((__tmp_19).clone()), - )) + ) } }); let p: Value> = Rc::new(RefCell::new(Vec::from([ @@ -257,16 +241,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new(p.decay().begin())); let __last: Value> = Rc::new(RefCell::new(p.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value( -

>::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !

>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind((__tmp_21.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } @@ -278,10 +258,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(p.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_22) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_20).clone()), LvalueRef::>>::bind((__tmp_22).clone()), - )) + ) } }); return 0; diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index 2e174ab1a3..cea1c7a61e 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -39,7 +39,16 @@ pub struct V { } impl Cpp17EqualityComparable for V { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/global_call_temporaries.rs b/tests/unit/out/refcount/global_call_temporaries.rs index 18b14ca25d..ad2773314a 100644 --- a/tests/unit/out/refcount/global_call_temporaries.rs +++ b/tests/unit/out/refcount/global_call_temporaries.rs @@ -18,10 +18,10 @@ thread_local!( ({ __tmp_0 = Rc::new(RefCell::new(0)); __tmp_1 = Rc::new(RefCell::new(0)); - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), - )) { + ) { __tmp_0.as_pointer() } else { __tmp_1.as_pointer() @@ -46,10 +46,10 @@ thread_local!( let __rhs = { __tmp_2 = Rc::new(RefCell::new(6)); __tmp_3 = Rc::new(RefCell::new(5)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_2.as_pointer().clone()), LvalueRef::>::bind(__tmp_3.as_pointer().clone()), - )) { + ) { __tmp_2.as_pointer() } else { __tmp_3.as_pointer() @@ -71,10 +71,10 @@ thread_local!( let __rhs = { __tmp_4 = Rc::new(RefCell::new(1)); __tmp_5 = Rc::new(RefCell::new(2)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_4.as_pointer().clone()), LvalueRef::>::bind(__tmp_5.as_pointer().clone()), - )) { + ) { __tmp_5.as_pointer() } else { __tmp_4.as_pointer() @@ -140,10 +140,10 @@ thread_local!( __tmp_7 = Rc::new(RefCell::new(Box::new([{ __tmp_8 = Rc::new(RefCell::new(4)); __tmp_9 = Rc::new(RefCell::new(3)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_8.as_pointer().clone()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), - )) { + ) { __tmp_8.as_pointer() } else { __tmp_9.as_pointer() @@ -156,10 +156,10 @@ thread_local!( value: { __tmp_11 = Rc::new(RefCell::new(5)); __tmp_12 = Rc::new(RefCell::new(6)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_11.as_pointer().clone()), LvalueRef::>::bind(__tmp_12.as_pointer().clone()), - )) { + ) { __tmp_12.as_pointer() } else { __tmp_11.as_pointer() @@ -183,10 +183,10 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_13 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_13.as_pointer().clone()), LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), - )) { + ) { __tmp_13.as_pointer() } else { left_10.with(|v| v.as_pointer()) @@ -205,10 +205,10 @@ thread_local!( Rc::new(RefCell::new( (({ __tmp_14 = Rc::new(RefCell::new((right_11.with(|rc| *rc.borrow()) as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(left_10.with(|v| v.as_pointer()).clone()), LvalueRef::>::bind(__tmp_14.as_pointer().clone()), - )) { + ) { __tmp_14.as_pointer() } else { left_10.with(|v| v.as_pointer()) @@ -245,10 +245,10 @@ thread_local!( __tmp_15 = Rc::new(RefCell::new(Box::new([{ __tmp_16 = Rc::new(RefCell::new(7)); __tmp_17 = Rc::new(RefCell::new(8)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_16.as_pointer().clone()), LvalueRef::>::bind(__tmp_17.as_pointer().clone()), - )) { + ) { __tmp_17.as_pointer() } else { __tmp_16.as_pointer() @@ -261,10 +261,10 @@ thread_local!( value: { __tmp_19 = Rc::new(RefCell::new(10)); __tmp_20 = Rc::new(RefCell::new(9)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_19.as_pointer().clone()), LvalueRef::>::bind(__tmp_20.as_pointer().clone()), - )) { + ) { __tmp_19.as_pointer() } else { __tmp_20.as_pointer() diff --git a/tests/unit/out/refcount/map.rs b/tests/unit/out/refcount/map.rs index 197df3e0cf..2c2078bd22 100644 --- a/tests/unit/out/refcount/map.rs +++ b/tests/unit/out/refcount/map.rs @@ -230,10 +230,10 @@ fn main_0() -> i32 { }), ), )); - let mut x1: u32 = if ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + let mut x1: u32 = if Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind(it.as_pointer()), LvalueRef::, Value)>>>::bind(end.as_pointer()), - )) { + ) { 0_u32 } else { (*(*({ (*it.borrow()).iter_deref() }).upgrade().deref()) @@ -247,14 +247,14 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_20,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_20,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_20).clone(), ), - )), + ), } { 0_u32 } else { @@ -269,14 +269,14 @@ fn main_0() -> i32 { )) .as_pointer(),) { - (__tmp_21,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_21,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_21).clone(), ), - )), + ), } { 0_u32 } else { @@ -294,14 +294,14 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_22,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_22,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_22).clone(), ), - )), + ), } { 0_u32 } else { @@ -407,14 +407,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_28, __tmp_30) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + WeaklyEqualityComparableWith::is_not_equal( LvalueRef::, Value)>>>::bind( (__tmp_28).clone(), ), LvalueRef::, Value)>>>::bind( (__tmp_30).clone(), ), - )) + ) } }); Map::erase((r).clone(), &({ (*it4.borrow()).clone() })); @@ -437,14 +437,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_31, __tmp_33) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( (__tmp_31).clone(), ), LvalueRef::, Value)>>>::bind( (__tmp_33).clone(), ), - )) + ) } }); match (Rc::new(RefCell::new(7_i16)).as_pointer(),) { @@ -504,14 +504,14 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_40,) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( next.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_40).clone(), ), - )) + ) } }); { @@ -524,14 +524,14 @@ fn main_0() -> i32 { .as_pointer(),) { (__tmp_42,) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( next.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_42).clone(), ), - )) + ) } }); assert!(({ ((*r.upgrade().deref()).len() == 3_usize) })); @@ -553,14 +553,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_43, __tmp_45) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( (__tmp_43).clone(), ), LvalueRef::, Value)>>>::bind( (__tmp_45).clone(), ), - )) + ) } }); let other_map: Value< diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 5863858e55..1e178b2f40 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -47,7 +47,16 @@ impl Key { } impl LessThanComparable for Key { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Key::operator_lt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Key::operator_lt((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index c6f957ef32..ec33f866fc 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -32,7 +32,16 @@ pub struct Key { } impl Cpp17EqualityComparable for Key { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); @@ -40,7 +49,16 @@ impl Cpp17EqualityComparable for Key { } impl LessThanComparable for Key { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); @@ -139,14 +157,14 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_0,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_0,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( a_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_0).clone(), ), - )), + ), }) as i32)) != 0 }; @@ -157,19 +175,36 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_1,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_1,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( b_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_1).clone(), ), - )), + ), }) as i32)) != 0 }; ok = { - ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(distinct .as_pointer() .with(|__m: &Map, Value)>| __m.end()) )).as_pointer(),) { (__tmp_2,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( LvalueRef::, Value) > >>::bind(b_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_2 ).clone()), )) } } ) ) as i32 ) ) != 0 + ((ok as i32) + & ((match (Rc::new(RefCell::new( + distinct + .as_pointer() + .with(|__m: &Map, Value)>| __m.end()), + )) + .as_pointer(),) + { + (__tmp_2,) => WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::, Value)>>>::bind( + b_it.as_pointer(), + ), + LvalueRef::, Value)>>>::bind( + (__tmp_2).clone(), + ), + ), + }) as i32)) + != 0 }; ok = { ((ok as i32) @@ -261,76 +296,16 @@ fn main_0() -> i32 { ok = { ((ok as i32) & (reused as i32)) != 0 }; ok = { ((ok as i32) & (((*equivalent.borrow()).len() == 1_usize) as i32)) != 0 }; if reused { - ok = - { - ((ok as i32) - & ((match (Rc::new(RefCell::new( - equivalent - .as_pointer() - .with(|__m: &Map, Value)>| __m.end()), - )) - .as_pointer(),) - { - (__tmp_3,) => ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::not_equal( - LvalueRef::< - Const, Value)>>, - >::bind(first_it.as_pointer()), - LvalueRef::< - Const, Value)>>, - >::bind((__tmp_3).clone()), - ), - ), - }) as i32)) - != 0 - }; + ok = { + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(equivalent .as_pointer() .with(|__m: &Map, Value)>| __m.end()) )).as_pointer(),) { (__tmp_3,) => { WeaklyEqualityComparableWith::is_not_equal( LvalueRef::, Value) > >>::bind(first_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_3 ).clone()), ) } } ) ) as i32 ) ) != 0 + }; ok = { ((ok as i32) & (({ (first).clone() } == { (second).clone() }) as i32)) != 0 }; - ok = - { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_a.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_4,) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( - LvalueRef::< - Const, Value)>>, - >::bind(first_it.as_pointer()), - LvalueRef::< - Const, Value)>>, - >::bind((__tmp_4).clone()), - )) - } - }) as i32)) - != 0 - }; - ok = - { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_b.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_5,) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( - LvalueRef::< - Const, Value)>>, - >::bind(first_it.as_pointer()), - LvalueRef::< - Const, Value)>>, - >::bind((__tmp_5).clone()), - )) - } - }) as i32)) - != 0 - }; + ok = { + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(equivalent .as_pointer() .with(|__m: &Map, Value)>| __m.find(&equivalent_a .as_pointer() )) )).as_pointer(),) { (__tmp_4,) => { Cpp17EqualityComparable::is_equal( LvalueRef::, Value) > >>::bind(first_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_4 ).clone()), ) } } ) ) as i32 ) ) != 0 + }; + ok = { + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(equivalent .as_pointer() .with(|__m: &Map, Value)>| __m.find(&equivalent_b .as_pointer() )) )).as_pointer(),) { (__tmp_5,) => { Cpp17EqualityComparable::is_equal( LvalueRef::, Value) > >>::bind(first_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_5 ).clone()), ) } } ) ) as i32 ) ) != 0 + }; ok = { ((ok as i32) & (({ @@ -387,29 +362,9 @@ fn main_0() -> i32 { }; ok = { ((ok as i32) & (((*equivalent.borrow()).len() == 2_usize) as i32)) != 0 }; if reused { - ok = - { - ((ok as i32) - & ((match (Rc::new(RefCell::new(equivalent.as_pointer().with( - |__m: &Map, Value)>| { - __m.find(&equivalent_a.as_pointer()) - }, - ))) - .as_pointer(),) - { - (__tmp_6,) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( - LvalueRef::< - Const, Value)>>, - >::bind(first_it.as_pointer()), - LvalueRef::< - Const, Value)>>, - >::bind((__tmp_6).clone()), - )) - } - }) as i32)) - != 0 - }; + ok = { + ( ( ok as i32 ) & ( ( ( match (Rc::new(RefCell::new(equivalent .as_pointer() .with(|__m: &Map, Value)>| __m.find(&equivalent_a .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { Cpp17EqualityComparable::is_equal( LvalueRef::, Value) > >>::bind(first_it .as_pointer() ), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), ) } } ) ) as i32 ) ) != 0 + }; ok = { ((ok as i32) & (({ @@ -472,14 +427,14 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_7,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_7,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( matched_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_7).clone(), ), - )), + ), }) as i32)) != 0 }; @@ -514,14 +469,14 @@ fn main_0() -> i32 { ))) .as_pointer(),) { - (__tmp_8,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_8,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( matched_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_8).clone(), ), - )), + ), }) as i32)) != 0 }; diff --git a/tests/unit/out/refcount/map_try_emplace.rs b/tests/unit/out/refcount/map_try_emplace.rs index 5ac115dcaa..02229caf6b 100644 --- a/tests/unit/out/refcount/map_try_emplace.rs +++ b/tests/unit/out/refcount/map_try_emplace.rs @@ -307,7 +307,7 @@ fn main_0() -> i32 { as i32)) != 0 }; - let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::, Value) > >>::bind(({ (*result.borrow()) .0 .as_pointer() })), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), )) } } ; + let mut found : bool = match (Rc::new(RefCell::new(m .as_pointer() .with(|__m: &Map, Value)>| __m.find(&key .as_pointer() )) )).as_pointer(),) { (__tmp_6,) => { Cpp17EqualityComparable::is_equal( LvalueRef::, Value) > >>::bind(({ (*result.borrow()) .0 .as_pointer() })), LvalueRef::, Value) > >>::bind((__tmp_6 ).clone()), ) } } ; ok = { ((ok as i32) & (found as i32)) != 0 }; ok = { ((ok as i32) diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index f8368dba61..0fe690bb5d 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -54,7 +54,16 @@ impl Bag { } impl LessThanComparable for Bag { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); @@ -78,37 +87,37 @@ fn main_0() -> i32 { let x4: Value = Rc::new(RefCell::new(20)); let mut p1: Ptr = (x1.as_pointer()); let mut p2: Ptr = (x2.as_pointer()); - let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r1: i32 = (if ::is_less( LvalueRef::>::bind(x1.as_pointer().clone()), LvalueRef::>::bind(x2.as_pointer().clone()), - )) { + ) { x2.as_pointer() } else { x1.as_pointer() } .read()); - let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r2: i32 = (if ::is_less( LvalueRef::>::bind(x4.as_pointer().clone()), LvalueRef::>::bind(x3.as_pointer().clone()), - )) { + ) { x4.as_pointer() } else { x3.as_pointer() } .read()); - let mut r3: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r3: i32 = (if ::is_less( LvalueRef::>::bind((p1).clone().clone()), LvalueRef::>::bind(x2.as_pointer().clone()), - )) { + ) { x2.as_pointer() } else { (p1).clone() } .read()); - let mut r4: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r4: i32 = (if ::is_less( LvalueRef::>::bind(x3.as_pointer().clone()), LvalueRef::>::bind((p2).clone().clone()), - )) { + ) { x3.as_pointer() } else { (p2).clone() @@ -117,10 +126,10 @@ fn main_0() -> i32 { let mut r5: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(30)); let __tmp_1: Value = Rc::new(RefCell::new(40)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(__tmp_1.as_pointer().clone()), - )) { + ) { __tmp_1.as_pointer() } else { __tmp_0.as_pointer() @@ -133,23 +142,19 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(values.decay())); let __last: Value> = Rc::new(RefCell::new(values.decay().offset((4) as isize))); let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + if as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), - )) { + ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -161,10 +166,10 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(0,) }), ({ pick_3(1,) }),) { (__tmp_2, __tmp_3) => { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind((__tmp_2).clone().clone()), LvalueRef::>::bind((__tmp_3).clone().clone()), - )) { + ) { (__tmp_3).clone() } else { (__tmp_2).clone() @@ -178,10 +183,10 @@ fn main_0() -> i32 { assert!( ((match (({ pick_3(1,) }), ({ pick_3(0,) }),) { (__tmp_4, __tmp_5) => { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind((__tmp_5).clone().clone()), LvalueRef::>::bind((__tmp_4).clone().clone()), - )) { + ) { (__tmp_5).clone() } else { (__tmp_4).clone() @@ -208,10 +213,10 @@ fn main_0() -> i32 { }, ) { (__tmp_6, __tmp_8) => { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind((__tmp_6).clone().clone()), LvalueRef::>::bind((__tmp_8).clone().clone()), - )) { + ) { (__tmp_8).clone() } else { (__tmp_6).clone() @@ -234,10 +239,10 @@ fn main_0() -> i32 { }, ) { (__tmp_10, __tmp_12) => { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind((__tmp_12).clone().clone()), LvalueRef::>::bind((__tmp_10).clone().clone()), - )) { + ) { (__tmp_12).clone() } else { (__tmp_10).clone() @@ -258,11 +263,9 @@ fn main_0() -> i32 { let __tmp_15: Value = Rc::new(RefCell::new((largest as u64))); (match (Rc::new(RefCell::new((({ size_of_2(i) }) as u64))).as_pointer(),) { (__tmp_14,) => { - if ConvertibleTo::::convert_value( - ::less( - LvalueRef::>::bind(__tmp_15.as_pointer().clone()), - LvalueRef::>::bind((__tmp_14).clone().clone()), - ), + if ::is_less( + LvalueRef::>::bind(__tmp_15.as_pointer().clone()), + LvalueRef::>::bind((__tmp_14).clone().clone()), ) { (__tmp_14).clone() } else { diff --git a/tests/unit/out/refcount/min_max_ptr2ptr.rs b/tests/unit/out/refcount/min_max_ptr2ptr.rs index 26d3f22ede..69d6fd3793 100644 --- a/tests/unit/out/refcount/min_max_ptr2ptr.rs +++ b/tests/unit/out/refcount/min_max_ptr2ptr.rs @@ -17,19 +17,19 @@ fn main_0() -> i32 { let pb: Value> = Rc::new(RefCell::new((b.as_pointer()))); let mut ppa: Ptr> = (pa.as_pointer()); let mut ppb: Ptr> = (pb.as_pointer()); - let mut r1: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r1: i32 = (if ::is_less( LvalueRef::>::bind((ppa.read()).clone()), LvalueRef::>::bind((ppb.read()).clone()), - )) { + ) { (ppb.read()) } else { (ppa.read()) } .read()); - let mut r2: i32 = (if ConvertibleTo::::convert_value(::less( + let mut r2: i32 = (if ::is_less( LvalueRef::>::bind((ppb.read()).clone()), LvalueRef::>::bind((ppa.read()).clone()), - )) { + ) { (ppb.read()) } else { (ppa.read()) @@ -42,10 +42,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value( as LessThanComparable>::less( + (if as LessThanComparable>::is_less( LvalueRef::>>::bind(high.as_pointer().clone()), LvalueRef::>>::bind(low.as_pointer().clone()), - )) { + ) { high.as_pointer() } else { low.as_pointer() @@ -57,10 +57,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value( as LessThanComparable>::less( + (if as LessThanComparable>::is_less( LvalueRef::>>::bind(low.as_pointer().clone()), LvalueRef::>>::bind(high.as_pointer().clone()), - )) { + ) { low.as_pointer() } else { high.as_pointer() @@ -72,10 +72,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value( as LessThanComparable>::less( + (if as LessThanComparable>::is_less( LvalueRef::>>::bind(low.as_pointer().clone()), LvalueRef::>>::bind(high.as_pointer().clone()), - )) { + ) { high.as_pointer() } else { low.as_pointer() @@ -87,10 +87,10 @@ fn main_0() -> i32 { assert!( ({ ({ - (if ConvertibleTo::::convert_value( as LessThanComparable>::less( + (if as LessThanComparable>::is_less( LvalueRef::>>::bind(high.as_pointer().clone()), LvalueRef::>>::bind(low.as_pointer().clone()), - )) { + ) { low.as_pointer() } else { high.as_pointer() diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 5fb5fc8445..ec928dbe2b 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -35,7 +35,16 @@ impl Eq { } impl Cpp17EqualityComparable for Eq { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -43,7 +52,16 @@ impl Cpp17EqualityComparable for Eq { } impl WeaklyEqualityComparableWith for Eq { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -99,7 +117,16 @@ impl Cmp { } impl Cpp17EqualityComparable for Cmp { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -108,9 +135,15 @@ impl Cpp17EqualityComparable for Cmp { impl WeaklyEqualityComparableWith for Cmp { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -118,7 +151,18 @@ impl WeaklyEqualityComparableWith for Cmp { } impl LessThanComparable for Cmp { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -126,31 +170,69 @@ impl LessThanComparable for Cmp { } impl PartiallyOrderedWith for Cmp { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -202,7 +284,16 @@ impl Both { } impl Cpp17EqualityComparable for Both { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -211,9 +302,15 @@ impl Cpp17EqualityComparable for Both { impl WeaklyEqualityComparableWith for Both { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -221,7 +318,18 @@ impl WeaklyEqualityComparableWith for Both { } impl LessThanComparable for Both { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -229,34 +337,69 @@ impl LessThanComparable for Both { } impl PartiallyOrderedWith for Both { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -305,7 +448,18 @@ impl OrdOnly { } impl LessThanComparable for OrdOnly { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -314,36 +468,71 @@ impl LessThanComparable for OrdOnly { impl PartiallyOrderedWith for OrdOnly { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -387,7 +576,16 @@ impl Inner { } impl Cpp17EqualityComparable for Inner { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -396,9 +594,15 @@ impl Cpp17EqualityComparable for Inner { impl WeaklyEqualityComparableWith for Inner { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -406,7 +610,18 @@ impl WeaklyEqualityComparableWith for Inner { } impl LessThanComparable for Inner { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -414,34 +629,69 @@ impl LessThanComparable for Inner { } impl PartiallyOrderedWith for Inner { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -505,7 +755,16 @@ impl Outer { } impl Cpp17EqualityComparable for Outer { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -514,9 +773,15 @@ impl Cpp17EqualityComparable for Outer { impl WeaklyEqualityComparableWith for Outer { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -524,7 +789,18 @@ impl WeaklyEqualityComparableWith for Outer { } impl LessThanComparable for Outer { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -532,34 +808,69 @@ impl LessThanComparable for Outer { } impl PartiallyOrderedWith for Outer { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -621,9 +932,15 @@ impl Secondary { impl Cpp17EqualityComparable for Secondary { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -632,9 +949,18 @@ impl Cpp17EqualityComparable for Secondary { impl WeaklyEqualityComparableWith for Secondary { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone()) }); @@ -643,9 +969,15 @@ impl WeaklyEqualityComparableWith for Secondary { impl LessThanComparable for Secondary { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); @@ -654,36 +986,70 @@ impl LessThanComparable for Secondary { impl PartiallyOrderedWith for Secondary { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone()) })); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone()) }); @@ -741,9 +1107,15 @@ impl PtrMember { impl Cpp17EqualityComparable for PtrMember { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -752,9 +1124,18 @@ impl Cpp17EqualityComparable for PtrMember { impl WeaklyEqualityComparableWith for PtrMember { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -763,9 +1144,17 @@ impl WeaklyEqualityComparableWith for PtrMember { impl LessThanComparable for PtrMember { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -774,36 +1163,74 @@ impl LessThanComparable for PtrMember { impl PartiallyOrderedWith for PtrMember { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 8ddc525e41..9fe5a9ec94 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -27,7 +27,16 @@ pub struct S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -35,7 +44,16 @@ impl Cpp17EqualityComparable for S { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); @@ -43,7 +61,12 @@ impl WeaklyEqualityComparableWith for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); @@ -51,28 +74,61 @@ impl LessThanComparable for S { } impl PartiallyOrderedWith for S { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_gt_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_gt_3((__lhs).clone(), (__rhs).clone()) }); } type LessEqualResult = bool; - fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_le_4((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_le_4((__lhs).clone(), (__rhs).clone()) }); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ge_5((__lhs).clone(), (__rhs).clone()) })); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ge_5((__lhs).clone(), (__rhs).clone()) }); @@ -123,7 +179,22 @@ pub struct V { } impl Cpp17EqualityComparable for V { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + operator_eq_8({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -135,7 +206,22 @@ impl Cpp17EqualityComparable for V { } impl WeaklyEqualityComparableWith for V { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + operator_ne_9({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ @@ -147,7 +233,18 @@ impl WeaklyEqualityComparableWith for V { } impl LessThanComparable for V { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + operator_lt_10({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index ff6dddc8e0..31b4fe984f 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -50,7 +50,16 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -58,7 +67,16 @@ impl Cpp17EqualityComparable for S { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_ne((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_ne((__lhs).clone(), (__rhs).clone()) }); @@ -66,7 +84,12 @@ impl WeaklyEqualityComparableWith for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); @@ -74,28 +97,61 @@ impl LessThanComparable for S { } impl PartiallyOrderedWith for S { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_gt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_gt((__lhs).clone(), (__rhs).clone()) }); } type LessEqualResult = bool; - fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_le((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_le((__lhs).clone(), (__rhs).clone()) }); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_ge((__lhs).clone(), (__rhs).clone()) })); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_ge((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 9ef437fe2c..40c667f66d 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -47,7 +47,16 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq((__lhs).clone(), (__rhs.read())) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs.read())) }); @@ -55,7 +64,16 @@ impl Cpp17EqualityComparable for S { } impl Cpp17EqualityComparable for i32 { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs.read()), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs.read()), (__rhs).clone()) }); @@ -63,7 +81,16 @@ impl Cpp17EqualityComparable for i32 { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_ne((__lhs).clone(), (__rhs.read())) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_ne((__lhs).clone(), (__rhs.read())) }); @@ -71,7 +98,16 @@ impl WeaklyEqualityComparableWith for S { } impl WeaklyEqualityComparableWith for i32 { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_1((__lhs.read()), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_1((__lhs.read()), (__rhs).clone()) }); @@ -79,7 +115,16 @@ impl WeaklyEqualityComparableWith for i32 { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); @@ -87,7 +132,16 @@ impl Cpp17EqualityComparable for S { } impl Cpp17EqualityComparable for f64 { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); @@ -95,7 +149,16 @@ impl Cpp17EqualityComparable for f64 { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); @@ -103,7 +166,16 @@ impl WeaklyEqualityComparableWith for S { } impl WeaklyEqualityComparableWith for f64 { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); @@ -111,7 +183,16 @@ impl WeaklyEqualityComparableWith for f64 { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); @@ -119,7 +200,16 @@ impl Cpp17EqualityComparable for S { } impl Cpp17EqualityComparable for i64 { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); @@ -127,7 +217,16 @@ impl Cpp17EqualityComparable for i64 { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); @@ -135,7 +234,16 @@ impl WeaklyEqualityComparableWith for S { } impl WeaklyEqualityComparableWith for i64 { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 61912f30aa..3b1c55c9a0 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -27,83 +27,181 @@ pub struct X { } impl Cpp17EqualityComparable for X { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_eq_0({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_eq_0({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } } impl WeaklyEqualityComparableWith for X { type NotEqualResult = i32; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_ne_1({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_ne_1({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } } impl LessThanComparable for X { type Result = i32; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_lt_2({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } } impl PartiallyOrderedWith for X { type LessResult = i32; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_lt_2({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } type GreaterResult = i32; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_gt_3({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_gt_3({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } type LessEqualResult = i32; - fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_le_4({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_le_4({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } type GreaterEqualResult = i32; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ + __return.write( + ({ + operator_ge_5({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ operator_ge_5({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }); + }) != 0); } } pub fn operator_eq_0(mut a: X, mut b: X) -> i32 { @@ -211,18 +309,36 @@ impl Mixed { } impl Cpp17EqualityComparable for Mixed { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) }); + return (({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) }) != 0); } } impl LessThanComparable for Mixed { type Result = i32; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) }); + return (({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) }) != 0); } } #[derive( @@ -257,9 +373,19 @@ impl MyBool { impl Cpp17EqualityComparable for MyBool { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } == { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } == { @@ -270,9 +396,19 @@ impl Cpp17EqualityComparable for MyBool { impl WeaklyEqualityComparableWith for MyBool { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } != { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } != { @@ -282,7 +418,20 @@ impl WeaklyEqualityComparableWith for MyBool { } impl LessThanComparable for MyBool { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { @@ -292,7 +441,20 @@ impl LessThanComparable for MyBool { } impl PartiallyOrderedWith for MyBool { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { @@ -301,9 +463,19 @@ impl PartiallyOrderedWith for MyBool { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } > { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } > { @@ -312,9 +484,19 @@ impl PartiallyOrderedWith for MyBool { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } <= { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } <= { @@ -323,9 +505,19 @@ impl PartiallyOrderedWith for MyBool { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } >= { + (({ MyBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } >= { @@ -369,27 +561,68 @@ pub struct Boolish { impl Cpp17EqualityComparable for Boolish { type EqualResult = MyBool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + operator_eq_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ - operator_eq_6({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) + MyBool::to_bool( + Rc::new(RefCell::new( + ({ + operator_eq_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + )) + .as_pointer(), + ) }); } } impl LessThanComparable for Boolish { type Result = MyBool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + operator_lt_7({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ - operator_lt_7({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) + MyBool::to_bool( + Rc::new(RefCell::new( + ({ + operator_lt_7({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + )) + .as_pointer(), + ) }); } } @@ -437,9 +670,19 @@ impl RefBool { impl Cpp17EqualityComparable for RefBool { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } == { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } == { @@ -450,9 +693,19 @@ impl Cpp17EqualityComparable for RefBool { impl WeaklyEqualityComparableWith for RefBool { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } != { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } != { @@ -462,7 +715,20 @@ impl WeaklyEqualityComparableWith for RefBool { } impl LessThanComparable for RefBool { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { @@ -473,9 +739,19 @@ impl LessThanComparable for RefBool { impl PartiallyOrderedWith for RefBool { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { @@ -484,9 +760,19 @@ impl PartiallyOrderedWith for RefBool { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } > { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } > { @@ -495,9 +781,19 @@ impl PartiallyOrderedWith for RefBool { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } <= { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } <= { @@ -506,9 +802,22 @@ impl PartiallyOrderedWith for RefBool { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } >= { + (({ RefBool::to_bool((__rhs).clone()) }) as i32) + }), + ); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } >= { @@ -564,12 +873,20 @@ impl RefInt { impl Cpp17EqualityComparable for RefInt { type EqualResult = LvalueRef; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(LvalueRef::bind( + ({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return LvalueRef::bind(({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) })); + return ({ RefBool::to_bool(({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) })) }); } } pub fn main() { @@ -666,17 +983,13 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(ris.decay())); let __last: Value> = Rc::new(RefCell::new(ris.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(ri2.as_pointer().clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index b0796a7a03..2d66f6d27a 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -31,7 +31,16 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -39,7 +48,12 @@ impl Cpp17EqualityComparable for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 38d80092ec..7e96a52819 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -34,9 +34,15 @@ pub struct Defaulted { impl Cpp17EqualityComparable for Defaulted { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -45,9 +51,18 @@ impl Cpp17EqualityComparable for Defaulted { impl WeaklyEqualityComparableWith for Defaulted { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -90,9 +105,18 @@ pub struct DefaultedOrd { impl Cpp17EqualityComparable for DefaultedOrd { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); @@ -101,9 +125,18 @@ impl Cpp17EqualityComparable for DefaultedOrd { impl WeaklyEqualityComparableWith for DefaultedOrd { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); @@ -112,9 +145,20 @@ impl WeaklyEqualityComparableWith for DefaultedOrd { impl LessThanComparable for DefaultedOrd { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); @@ -123,36 +167,80 @@ impl LessThanComparable for DefaultedOrd { impl PartiallyOrderedWith for DefaultedOrd { type LessResult = bool; fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); @@ -202,9 +290,15 @@ pub struct Inline { impl Cpp17EqualityComparable for Inline { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); @@ -213,9 +307,15 @@ impl Cpp17EqualityComparable for Inline { impl WeaklyEqualityComparableWith for Inline { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); @@ -223,7 +323,16 @@ impl WeaklyEqualityComparableWith for Inline { } impl LessThanComparable for Inline { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); @@ -251,9 +360,15 @@ pub struct OutOfLine { impl Cpp17EqualityComparable for OutOfLine { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_6((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_6((__lhs).clone(), (__rhs).clone()) }); @@ -262,9 +377,18 @@ impl Cpp17EqualityComparable for OutOfLine { impl WeaklyEqualityComparableWith for OutOfLine { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_ne_7((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_ne_7((__lhs).clone(), (__rhs).clone()) }); @@ -307,9 +431,15 @@ pub struct Tmpl_int_ { impl Cpp17EqualityComparable for Tmpl_int_ { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_8((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); @@ -318,9 +448,18 @@ impl Cpp17EqualityComparable for Tmpl_int_ { impl WeaklyEqualityComparableWith for Tmpl_int_ { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_8((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); @@ -329,9 +468,15 @@ impl WeaklyEqualityComparableWith for Tmpl_int_ { impl LessThanComparable for Tmpl_int_ { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_9((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_9((__lhs).clone(), (__rhs).clone()) }); @@ -365,9 +510,15 @@ pub struct Tmpl_long_ { impl Cpp17EqualityComparable for Tmpl_long_ { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_11((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); @@ -376,9 +527,18 @@ impl Cpp17EqualityComparable for Tmpl_long_ { impl WeaklyEqualityComparableWith for Tmpl_long_ { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_11((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); @@ -387,9 +547,15 @@ impl WeaklyEqualityComparableWith for Tmpl_long_ { impl LessThanComparable for Tmpl_long_ { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_12((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_12((__lhs).clone(), (__rhs).clone()) }); @@ -420,9 +586,18 @@ pub struct TmplDefaulted_int_ { impl Cpp17EqualityComparable for TmplDefaulted_int_ { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_13((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); @@ -431,9 +606,18 @@ impl Cpp17EqualityComparable for TmplDefaulted_int_ { impl WeaklyEqualityComparableWith for TmplDefaulted_int_ { type NotEqualResult = bool; fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_13((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index a4cde16240..d5334fcf02 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -72,7 +72,17 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) }); @@ -80,7 +90,17 @@ impl Cpp17EqualityComparable for S { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) }); @@ -88,7 +108,13 @@ impl WeaklyEqualityComparableWith for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); @@ -96,28 +122,65 @@ impl LessThanComparable for S { } impl PartiallyOrderedWith for S { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) }); } type LessEqualResult = bool; - fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) }); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return + .write(({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) })); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) }); diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index fcc0e067e9..8aeb5da3b0 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -58,42 +58,87 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) }); + __return.write(({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) }) != 0); } } impl Cpp17EqualityComparable for i32 { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) }); + return (({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) }) != 0); } } impl Cpp17EqualityComparable for S { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) }); + __return.write(({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return (({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) }) != 0); } } impl Cpp17EqualityComparable for i64 { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_1((__lhs.read()), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ operator_eq_1((__lhs.read()), (__rhs).clone()) }); + return (({ operator_eq_1((__lhs.read()), (__rhs).clone()) }) != 0); } } impl Cpp17EqualityComparable for S { type EqualResult = i32; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) }); + return (({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) }) != 0); } } pub fn operator_div_2(a: Ptr, b: Ptr) -> i32 { diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 11c787a918..31fa4148ee 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -41,7 +41,16 @@ impl S { } impl Cpp17EqualityComparable for S { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -49,7 +58,16 @@ impl Cpp17EqualityComparable for S { } impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -57,7 +75,14 @@ impl WeaklyEqualityComparableWith for S { } impl LessThanComparable for S { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -65,28 +90,69 @@ impl LessThanComparable for S { } impl PartiallyOrderedWith for S { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; - fn less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessEqualResult { + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index d8caa71307..284302d678 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -32,7 +32,12 @@ impl Lt { } impl LessThanComparable for Lt { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Lt::operator_lt((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Lt::operator_lt((__lhs).clone(), (__rhs).clone()) }); @@ -64,7 +69,16 @@ impl Eq { } impl Cpp17EqualityComparable for Eq { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -72,7 +86,16 @@ impl Cpp17EqualityComparable for Eq { } impl WeaklyEqualityComparableWith for Eq { type NotEqualResult = bool; - fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -110,7 +133,16 @@ impl Cmp { } impl Cpp17EqualityComparable for Cmp { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -119,9 +151,15 @@ impl Cpp17EqualityComparable for Cmp { impl WeaklyEqualityComparableWith for Cmp { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); @@ -129,7 +167,18 @@ impl WeaklyEqualityComparableWith for Cmp { } impl LessThanComparable for Cmp { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -137,31 +186,69 @@ impl LessThanComparable for Cmp { } impl PartiallyOrderedWith for Cmp { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterResult = bool; - fn greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::GreaterResult { + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), + )); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); @@ -196,7 +283,16 @@ pub struct Free { } impl Cpp17EqualityComparable for Free { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -205,9 +301,15 @@ impl Cpp17EqualityComparable for Free { impl WeaklyEqualityComparableWith for Free { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); @@ -215,7 +317,16 @@ impl WeaklyEqualityComparableWith for Free { } impl LessThanComparable for Free { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); @@ -255,9 +366,18 @@ pub struct Wrapped_int_ { impl Cpp17EqualityComparable for Wrapped_int_ { type EqualResult = bool; fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); @@ -266,9 +386,18 @@ impl Cpp17EqualityComparable for Wrapped_int_ { impl WeaklyEqualityComparableWith for Wrapped_int_ { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(!({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); @@ -277,9 +406,18 @@ impl WeaklyEqualityComparableWith for Wrapped_int_ { impl LessThanComparable for Wrapped_int_ { type Result = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::Result { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); @@ -319,16 +457,12 @@ fn main_0() -> i32 { ({ let __it: Value> = Rc::new(RefCell::new(eqs.decay().begin())); let __last: Value> = Rc::new(RefCell::new(eqs.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(two.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(two.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -342,16 +476,12 @@ fn main_0() -> i32 { Rc::new(RefCell::new({ let __it: Value> = Rc::new(RefCell::new(eqs.decay().begin())); let __last: Value> = Rc::new(RefCell::new(eqs.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(nine.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(nine.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -361,10 +491,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(eqs.decay().end())).as_pointer(), ) { (__tmp_1, __tmp_2) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_1).clone()), LvalueRef::>>::bind((__tmp_2).clone()), - )) + ) } }); let cmps: Value> = Rc::new(RefCell::new(Vec::from([ @@ -389,17 +519,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(cmps.decay().begin())); let __last: Value> = Rc::new(RefCell::new(cmps.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(three.as_pointer().clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -424,17 +550,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(frees.decay().begin())); let __last: Value> = Rc::new(RefCell::new(frees.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(ftwo.as_pointer().clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index a4ca61d62d..8b9e71a135 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -59,9 +59,19 @@ impl Meters { impl Cpp17EqualityComparable for Meters { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } == { + ({ Meters::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } == { @@ -72,9 +82,19 @@ impl Cpp17EqualityComparable for Meters { impl WeaklyEqualityComparableWith for Meters { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } != { + ({ Meters::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } != { @@ -84,7 +104,18 @@ impl WeaklyEqualityComparableWith for Meters { } impl LessThanComparable for Meters { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { @@ -94,7 +125,18 @@ impl LessThanComparable for Meters { } impl PartiallyOrderedWith for Meters { type LessResult = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::LessResult { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { @@ -103,9 +145,17 @@ impl PartiallyOrderedWith for Meters { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } > { ({ Meters::to_i32((__rhs).clone()) }) }), + ); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } > { @@ -114,9 +164,19 @@ impl PartiallyOrderedWith for Meters { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { + ({ Meters::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { @@ -125,9 +185,19 @@ impl PartiallyOrderedWith for Meters { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { + ({ Meters::to_i32((__rhs).clone()) }) + }), + ); + } + fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { diff --git a/tests/unit/out/refcount/push_emplace_back.rs b/tests/unit/out/refcount/push_emplace_back.rs index 997c3be8a8..a0a040a9ea 100644 --- a/tests/unit/out/refcount/push_emplace_back.rs +++ b/tests/unit/out/refcount/push_emplace_back.rs @@ -96,11 +96,9 @@ pub fn push_local_from_field_1(mut jpg: Ptr, mut cond: bool) { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -138,11 +136,9 @@ pub fn emplace_local_from_field_4(mut jpg: Ptr, mut cond: bool) { let __it: Value> = Rc::new(RefCell::new(head.decay())); let __last: Value> = Rc::new(RefCell::new(head.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -415,11 +411,9 @@ pub fn emplace_from_element_14(mut v: Ptr>>) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -532,11 +526,9 @@ pub fn emplace_from_sibling_18(mut s: Ptr) { let __it: Value> = Rc::new(RefCell::new(({ (*p.borrow()).clone() }))); let __last: Value> = Rc::new(RefCell::new((*p.borrow()).offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/redundant_copy_in_conversion.rs b/tests/unit/out/refcount/redundant_copy_in_conversion.rs index ba61cee2c9..06348e736c 100644 --- a/tests/unit/out/refcount/redundant_copy_in_conversion.rs +++ b/tests/unit/out/refcount/redundant_copy_in_conversion.rs @@ -17,14 +17,14 @@ pub fn sink_0(it: BidirectionalIterator<(Value, Value)>) -> i32 { )>>::from(({ (*it.borrow()).clone() })))) .as_pointer(),) { - (__tmp_0,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_0,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( cit.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_0).clone(), ), - )), + ), } { (*(*({ (*it.borrow()).iter_deref() }).upgrade().deref()) .1 @@ -65,24 +65,24 @@ fn main_0() -> i32 { )>>::from(({ (*end.borrow()).clone() })))) .as_pointer(),) { - (__tmp_3,) => ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + (__tmp_3,) => Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( const_it.as_pointer(), ), LvalueRef::, Value)>>>::bind( (__tmp_3).clone(), ), - )), + ), } { 0 } else { 1 }; r += ({ sink_0({ (*it0.borrow()).clone() }) }); - r += if ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + r += if Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind(end.as_pointer()), LvalueRef::, Value)>>>::bind(end.as_pointer()), - )) { + ) { 0 } else { 1 @@ -95,11 +95,9 @@ fn main_0() -> i32 { >::from(({ (*middle.borrow()).clone() })), )); assert!(((({ (*const_middle.borrow()).iter_deref() }).read()) == 8_u32)); - assert!(ConvertibleTo::::convert_value( - Cpp17EqualityComparable::equal( - LvalueRef::>>::bind(const_middle.as_pointer()), - LvalueRef::>>::bind(middle.as_pointer()), - ) + assert!(Cpp17EqualityComparable::is_equal( + LvalueRef::>>::bind(const_middle.as_pointer()), + LvalueRef::>>::bind(middle.as_pointer()), )); return 0; } diff --git a/tests/unit/out/refcount/size_t_ssize_t.rs b/tests/unit/out/refcount/size_t_ssize_t.rs index 84043a5d38..e288f936d4 100644 --- a/tests/unit/out/refcount/size_t_ssize_t.rs +++ b/tests/unit/out/refcount/size_t_ssize_t.rs @@ -36,11 +36,9 @@ pub fn size_t_in_rules_3() { let __first: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); let mut __out = (dst.decay()).reinterpret_cast::(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { object!(__value, u64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), @@ -123,14 +121,14 @@ pub fn size_t_in_rules_3() { .as_pointer(), ) { (__tmp_2, __tmp_4) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + WeaklyEqualityComparableWith::is_not_equal( LvalueRef::, Value)>>>::bind( (__tmp_2).clone(), ), LvalueRef::, Value)>>>::bind( (__tmp_4).clone(), ), - )) + ) } }); assert!( @@ -270,11 +268,9 @@ pub fn size_t_in_rules_3() { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -298,11 +294,9 @@ pub fn size_t_in_rules_3() { { let __it: Value> = Rc::new(RefCell::new(v.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { __it.borrow() .iter_deref() @@ -318,10 +312,10 @@ pub fn size_t_in_rules_3() { let __tmp_10: Value = Rc::new(RefCell::new(((*k.borrow()) as u64))); (match (v.decay().offset(1_usize),) { (__tmp_9,) => { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind((__tmp_9).clone().clone()), LvalueRef::>::bind(__tmp_10.as_pointer().clone()), - )) { + ) { __tmp_10.as_pointer() } else { (__tmp_9).clone() @@ -412,18 +406,12 @@ pub fn size_t_in_rules_3() { Rc::new(RefCell::new(v3.decay().begin())); let __last: Value> = Rc::new(RefCell::new(v3.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_19.as_pointer().clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_19.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } @@ -435,10 +423,10 @@ pub fn size_t_in_rules_3() { Rc::new(RefCell::new(v3.decay().end())).as_pointer(), ) { (__tmp_18, __tmp_20) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( + WeaklyEqualityComparableWith::is_not_equal( LvalueRef::>>::bind((__tmp_18).clone()), LvalueRef::>>::bind((__tmp_20).clone()), - )) + ) } }); assert!( @@ -499,10 +487,10 @@ fn main_0() -> i32 { (::std::mem::size_of::() as u64).wrapping_add((*ul.borrow())), )); let __tmp_22: Value = Rc::new(RefCell::new((sz as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_21.as_pointer().clone()), LvalueRef::>::bind(__tmp_22.as_pointer().clone()), - )) { + ) { __tmp_21.as_pointer() } else { __tmp_22.as_pointer() @@ -513,10 +501,10 @@ fn main_0() -> i32 { let __tmp_23: Value = Rc::new(RefCell::new( (::std::mem::size_of::() as u64).wrapping_add((sz as u64)), )); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_23.as_pointer().clone()), LvalueRef::>::bind(ul.as_pointer().clone()), - )) { + ) { ul.as_pointer() } else { __tmp_23.as_pointer() @@ -528,10 +516,10 @@ fn main_0() -> i32 { let mut bound: usize = (({ let __tmp_24: Value = Rc::new(RefCell::new((4_usize as u64))); let __tmp_25: Value = Rc::new(RefCell::new((sz as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_24.as_pointer().clone()), LvalueRef::>::bind(__tmp_25.as_pointer().clone()), - )) { + ) { __tmp_24.as_pointer() } else { __tmp_25.as_pointer() @@ -587,10 +575,10 @@ fn main_0() -> i32 { let mut smin: isize = (({ let __tmp_26: Value = Rc::new(RefCell::new((sm as i64))); let __tmp_27: Value = Rc::new(RefCell::new((sd as i64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_26.as_pointer().clone()), LvalueRef::>::bind(__tmp_27.as_pointer().clone()), - )) { + ) { __tmp_26.as_pointer() } else { __tmp_27.as_pointer() @@ -600,10 +588,10 @@ fn main_0() -> i32 { let mut smax: isize = (({ let __tmp_28: Value = Rc::new(RefCell::new((sd as i64))); let __tmp_29: Value = Rc::new(RefCell::new((sm as i64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_28.as_pointer().clone()), LvalueRef::>::bind(__tmp_29.as_pointer().clone()), - )) { + ) { __tmp_29.as_pointer() } else { __tmp_28.as_pointer() @@ -630,10 +618,10 @@ fn main_0() -> i32 { (({ let __tmp_30: Value = Rc::new(RefCell::new((mx as u64))); let __tmp_31: Value = Rc::new(RefCell::new(1_u64)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_30.as_pointer().clone()), LvalueRef::>::bind(__tmp_31.as_pointer().clone()), - )) { + ) { __tmp_30.as_pointer() } else { __tmp_31.as_pointer() @@ -643,10 +631,10 @@ fn main_0() -> i32 { (({ let __tmp_32: Value = Rc::new(RefCell::new(((mx).wrapping_sub(3_usize) as u64))); let __tmp_33: Value = Rc::new(RefCell::new((mx as u64))); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_32.as_pointer().clone()), LvalueRef::>::bind(__tmp_33.as_pointer().clone()), - )) { + ) { __tmp_32.as_pointer() } else { __tmp_33.as_pointer() diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index 8ac37d492b..ff39be106d 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -54,7 +54,16 @@ impl MoveAssignable for Tracked { } impl LessThanComparable for Tracked { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); @@ -103,7 +112,16 @@ impl MoveOnly { } impl LessThanComparable for MoveOnly { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_3((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); @@ -132,7 +150,16 @@ impl Bag { } impl Cpp17EqualityComparable for Bag { type EqualResult = bool; - fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_eq_4((__lhs).clone(), (__rhs).clone()) })); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_4((__lhs).clone(), (__rhs).clone()) }); @@ -140,7 +167,16 @@ impl Cpp17EqualityComparable for Bag { } impl LessThanComparable for Bag { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(({ operator_lt_5((__lhs).clone(), (__rhs).clone()) })); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_lt_5((__lhs).clone(), (__rhs).clone()) }); @@ -453,17 +489,13 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin())); let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), - ) && !ConvertibleTo::::convert_value(>::equal( + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(bags.decay().offset(1).clone()), - )) { + ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -472,10 +504,10 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(1_isize))).as_pointer(), ) { (__tmp_20, __tmp_21) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_20).clone()), LvalueRef::>>::bind((__tmp_21).clone()), - )) + ) } }); assert!(match ( @@ -485,23 +517,19 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(bag_vec.decay().end())); let mut __best = __it.borrow().clone(); - if ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + if as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { __it.borrow_mut().iter_inc(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), - )) { + ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); @@ -513,27 +541,27 @@ fn main_0() -> i32 { Rc::new(RefCell::new(bag_vec.decay().begin().iter_add(2_isize))).as_pointer(), ) { (__tmp_22, __tmp_23) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::>>::bind((__tmp_22).clone()), LvalueRef::>>::bind((__tmp_23).clone()), - )) + ) } }); assert!( - ((if ConvertibleTo::::convert_value(::less( + ((if ::is_less( LvalueRef::>::bind(bags.decay().offset(2).clone()), LvalueRef::>::bind(bags.decay().offset(0).clone()), - )) { + ) { bags.decay().offset(2) } else { bags.decay().offset(0) }) == (bags.decay().offset(0))) ); assert!( - ((if ConvertibleTo::::convert_value(::less( + ((if ::is_less( LvalueRef::>::bind(bags.decay().offset(0).clone()), LvalueRef::>::bind(bags.decay().offset(2).clone()), - )) { + ) { bags.decay().offset(2) } else { bags.decay().offset(0) @@ -577,14 +605,14 @@ fn main_0() -> i32 { .as_pointer(), ) { (__tmp_26, __tmp_27) => { - ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( + Cpp17EqualityComparable::is_equal( LvalueRef::, Value)>>>::bind( (__tmp_26).clone(), ), LvalueRef::, Value)>>>::bind( (__tmp_27).clone(), ), - )) + ) } }); assert!((copies_0.with(|rc| *rc.borrow()) == 0)); diff --git a/tests/unit/out/refcount/stdcopy.rs b/tests/unit/out/refcount/stdcopy.rs index 50b7043c9c..8918eee1dd 100644 --- a/tests/unit/out/refcount/stdcopy.rs +++ b/tests/unit/out/refcount/stdcopy.rs @@ -43,11 +43,9 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = output.decay(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { object!(__value, i32, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), @@ -71,11 +69,9 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = widened.decay().begin(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { object!(__value, i64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), @@ -109,11 +105,9 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(input.decay())); let __last: Value> = Rc::new(RefCell::new(input.decay().offset((3) as isize))); let mut __out = constructed.decay().begin(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { object!(__value, Degrees, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), @@ -142,11 +136,9 @@ fn main_0() -> i32 { let __first: Value> = Rc::new(RefCell::new(wide.decay())); let __last: Value> = Rc::new(RefCell::new(wide.decay().offset((2) as isize))); let mut __out = floating.decay().begin(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__first.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__first.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { object!(__value, f64, |__this| ConvertibleTo::convert( LvalueRef::::bind(__first.borrow().iter_deref()), diff --git a/tests/unit/out/refcount/stdcopy_ostream.rs b/tests/unit/out/refcount/stdcopy_ostream.rs index 4da0406cce..c1927139dd 100644 --- a/tests/unit/out/refcount/stdcopy_ostream.rs +++ b/tests/unit/out/refcount/stdcopy_ostream.rs @@ -32,11 +32,9 @@ fn main_0() -> i32 { let __last: Value> = Rc::new(RefCell::new(__tmp_1)); let __out = &mut (*ofs.borrow_mut()); let mut __bytes: Vec = Vec::new(); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { __bytes.push(__it.borrow().iter_deref().read() as u8); __it.borrow_mut().iter_inc(); diff --git a/tests/unit/out/refcount/stdmin_fpoint.rs b/tests/unit/out/refcount/stdmin_fpoint.rs index 71c056fe36..bc2fa581d2 100644 --- a/tests/unit/out/refcount/stdmin_fpoint.rs +++ b/tests/unit/out/refcount/stdmin_fpoint.rs @@ -13,10 +13,10 @@ pub fn main() { fn main_0() -> i32 { let a0: Value = Rc::new(RefCell::new(3.14_f64)); let a1: Value = Rc::new(RefCell::new(2.71_f64)); - if ConvertibleTo::::convert_value(::less( + if ::is_less( LvalueRef::>::bind(a1.as_pointer().clone()), LvalueRef::>::bind(a0.as_pointer().clone()), - )) { + ) { a1.as_pointer() } else { a0.as_pointer() diff --git a/tests/unit/out/refcount/unboxed_conditional_iterator.rs b/tests/unit/out/refcount/unboxed_conditional_iterator.rs index 4ec2948cee..00656fbc53 100644 --- a/tests/unit/out/refcount/unboxed_conditional_iterator.rs +++ b/tests/unit/out/refcount/unboxed_conditional_iterator.rs @@ -59,18 +59,12 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { Rc::new(RefCell::new(items.decay().begin())); let __last: Value> = Rc::new(RefCell::new(items.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind( - __last.as_pointer(), - ), - ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(sigma.offset((i) as isize).clone()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), + ) && !>::is_equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(sigma.offset((i) as isize).clone()), ) { __it.borrow_mut().iter_inc(); } @@ -79,14 +73,12 @@ pub fn lehmer_3(mut sigma: Ptr, mut len: u32, mut code: Ptr) { assert!( match (Rc::new(RefCell::new(items.decay().end())).as_pointer(),) { (__tmp_0,) => { - ConvertibleTo::::convert_value( - WeaklyEqualityComparableWith::not_equal( - LvalueRef::>>::bind( - it.as_pointer(), - ), - LvalueRef::>>::bind( - (__tmp_0).clone(), - ), + WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind( + it.as_pointer(), + ), + LvalueRef::>>::bind( + (__tmp_0).clone(), ), ) } @@ -112,12 +104,10 @@ pub fn sum_4(v: Ptr>) -> i32 { { let it: Value> = Rc::new(RefCell::new(v.decay().begin())); 'loop_: while match (Rc::new(RefCell::new(v.decay().end())).as_pointer(),) { - (__tmp_2,) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::not_equal( - LvalueRef::>>::bind(it.as_pointer()), - LvalueRef::>>::bind((__tmp_2).clone()), - )) - } + (__tmp_2,) => WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind(it.as_pointer()), + LvalueRef::>>::bind((__tmp_2).clone()), + ), } { 'for_body: { s += (({ (*it.borrow()).iter_deref() }).read()); diff --git a/tests/unit/out/refcount/unboxed_locals.rs b/tests/unit/out/refcount/unboxed_locals.rs index 745a28a397..ab412a64da 100644 --- a/tests/unit/out/refcount/unboxed_locals.rs +++ b/tests/unit/out/refcount/unboxed_locals.rs @@ -176,10 +176,10 @@ fn main_0() -> i32 { let high: Value = Rc::new(RefCell::new(3)); let mut low: i32 = { let __tmp_0: Value = Rc::new(RefCell::new(2)); - (if ConvertibleTo::::convert_value(::less( + (if ::is_less( LvalueRef::>::bind(__tmp_0.as_pointer().clone()), LvalueRef::>::bind(high.as_pointer().clone()), - )) { + ) { __tmp_0.as_pointer() } else { high.as_pointer() diff --git a/tests/unit/out/refcount/vector.rs b/tests/unit/out/refcount/vector.rs index b1fb8c5a22..b014105313 100644 --- a/tests/unit/out/refcount/vector.rs +++ b/tests/unit/out/refcount/vector.rs @@ -192,11 +192,9 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay().begin())); let __last: Value> = Rc::new(RefCell::new(src.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -711,11 +709,9 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -750,11 +746,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -782,11 +776,9 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -817,11 +809,9 @@ fn main_0() -> i32 { let temp_vec: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); @@ -854,11 +844,9 @@ fn main_0() -> i32 { Rc::new(RefCell::new(more.decay().begin())); let __last: Value> = Rc::new(RefCell::new(more.decay().end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index cf580172f9..72b0306d5a 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -59,9 +59,19 @@ impl Reading { impl Cpp17EqualityComparable for Reading { type EqualResult = bool; fn equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::EqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } == { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } == { @@ -72,9 +82,19 @@ impl Cpp17EqualityComparable for Reading { impl WeaklyEqualityComparableWith for Reading { type NotEqualResult = bool; fn not_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::NotEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } != { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } != { @@ -84,7 +104,20 @@ impl WeaklyEqualityComparableWith for Reading { } impl LessThanComparable for Reading { type Result = bool; - fn less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Result { + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } < { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { @@ -95,9 +128,19 @@ impl LessThanComparable for Reading { impl PartiallyOrderedWith for Reading { type LessResult = bool; fn less( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } < { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { @@ -106,9 +149,19 @@ impl PartiallyOrderedWith for Reading { } type GreaterResult = bool; fn greater( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } > { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } > { @@ -117,9 +170,19 @@ impl PartiallyOrderedWith for Reading { } type LessEqualResult = bool; fn less_equal( + __return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::LessEqualResult { + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } <= { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } <= { @@ -128,9 +191,22 @@ impl PartiallyOrderedWith for Reading { } type GreaterEqualResult = bool; fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ ({ Reading::to_i64((__lhs).clone()) }) } >= { + ({ Reading::to_i64((__rhs).clone()) }) + }), + ); + } + fn is_greater_equal( __lhs: LvalueRef>, __rhs: LvalueRef>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ ({ Reading::to_i64((__lhs).clone()) }) } >= { @@ -148,11 +224,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -170,11 +244,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -192,11 +264,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -215,11 +285,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -244,11 +312,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -291,7 +357,7 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while ConvertibleTo::::convert_value(, Value) > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), )) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( __v.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } + while , Value) > as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( __v.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } Rc::try_unwrap(__v).ok().unwrap().into_inner() })); assert!(({ ((*v6.borrow()).len() == 3_usize) })); @@ -323,7 +389,7 @@ fn main_0() -> i32 { m.as_pointer() .with(|__m: &Map, Value)>| __m.end()), )); - while ConvertibleTo::::convert_value(, Value) > as WeaklyEqualityComparableWith>::not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), )) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( temp_vec.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } + while , Value) > as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef::, Value) > >>::bind(__it.as_pointer()), LvalueRef::, Value) > >>::bind(__last.as_pointer()), ) { let __i = temp_vec.borrow().len(); temp_vec.borrow_mut().push(ZeroInitialization::zero_init()); ConstructibleFrom::construct( temp_vec.as_pointer().decay().offset(__i), (LvalueRef::, Value) >>::bind(__it.borrow().iter_deref()),), ); __it.borrow_mut().iter_inc(); } v6.as_pointer() .with_mut(|v: &mut Vec<(Value, Value)>| { v.splice( @@ -346,11 +412,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(ints.decay())); let __last: Value> = Rc::new(RefCell::new(ints.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -372,11 +436,9 @@ fn main_0() -> i32 { let __it: Value> = Rc::new(RefCell::new(readings.decay())); let __last: Value> = Rc::new(RefCell::new(readings.decay().offset((2) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/refcount/vector_with_allocator.rs b/tests/unit/out/refcount/vector_with_allocator.rs index 89866c6e53..87fdf8bbbd 100644 --- a/tests/unit/out/refcount/vector_with_allocator.rs +++ b/tests/unit/out/refcount/vector_with_allocator.rs @@ -405,11 +405,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -427,11 +425,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -449,11 +445,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src.decay())); let __last: Value> = Rc::new(RefCell::new(src.decay().offset((3) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -472,11 +466,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new(src1.decay())); let __last: Value> = Rc::new(RefCell::new(src1.decay().to_end())); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); @@ -498,11 +490,9 @@ fn main_0() -> i32 { let __v: Value> = Rc::new(RefCell::new(Vec::new())); let __it: Value> = Rc::new(RefCell::new((start).clone())); let __last: Value> = Rc::new(RefCell::new(start.offset((len) as isize))); - while ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::not_equal( - LvalueRef::>>::bind(__it.as_pointer()), - LvalueRef::>>::bind(__last.as_pointer()), - ), + while as WeaklyEqualityComparableWith>::is_not_equal( + LvalueRef::>>::bind(__it.as_pointer()), + LvalueRef::>>::bind(__last.as_pointer()), ) { let __i = __v.borrow().len(); __v.borrow_mut().push(ZeroInitialization::zero_init()); diff --git a/tests/unit/out/unsafe/cast.rs b/tests/unit/out/unsafe/cast.rs index f76c89f894..d2190a8a22 100644 --- a/tests/unit/out/unsafe/cast.rs +++ b/tests/unit/out/unsafe/cast.rs @@ -190,18 +190,14 @@ pub unsafe fn order_physical_2() { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const *mut i32; let __b = __tmp_0.iter_at(__y) as *const *mut i32; - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 5ac48621af..36d165a26e 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -106,9 +106,18 @@ impl Counter { impl Cpp17EqualityComparableUnsafe for Counter { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Counter); + let __rhs = (__rhs.as_ptr() as *const Counter); + __return.write((unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Counter); let __rhs = (__rhs.as_ptr() as *const Counter); return (unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs) }); diff --git a/tests/unit/out/unsafe/container_element_receiver.rs b/tests/unit/out/unsafe/container_element_receiver.rs index fc72cdc5d2..a829cfcba2 100644 --- a/tests/unit/out/unsafe/container_element_receiver.rs +++ b/tests/unit/out/unsafe/container_element_receiver.rs @@ -34,11 +34,9 @@ pub unsafe fn sum_1(v: *const Vec) -> i32 { let mut total: i32 = 0; { let mut it: UnsafeRandomAccessIterator = (*v).begin(); - 'loop_: while ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&(*v).end()), - ), + 'loop_: while WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&(*v).end()), ) { 'for_body: { total += (*it.iter_deref()); diff --git a/tests/unit/out/unsafe/copy_ctor.rs b/tests/unit/out/unsafe/copy_ctor.rs index 220e91c76c..08e044ed73 100644 --- a/tests/unit/out/unsafe/copy_ctor.rs +++ b/tests/unit/out/unsafe/copy_ctor.rs @@ -420,19 +420,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { vec_.end() }; let mut __v: Vec = Vec::new(); let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_1), - ), - ) { - __v.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __v.as_mut_ptr().add(__v.len() - 1), - (LvalueRefUnsafe::>::bind(__it.iter_deref()),), - ); - __it.iter_inc(); - } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } __v }; assert!( diff --git a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs index 06fd5a8abf..fee05f3e3e 100644 --- a/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/unsafe/elidable_iterator_copy_cxx11.rs @@ -26,26 +26,20 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { v.begin() }; let mut __tmp_3 = { v.end() }; let mut __it = (__tmp_2).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_3), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&7), - ), + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_3), + ) && !>::is_equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&7), ) { __it.iter_inc(); } __it }; - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&v.end()), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&v.end()), )); assert!(((*it.iter_deref()) == (7))); { @@ -63,16 +57,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_5.iter_at(__x) as *const i32; let __b = __tmp_5.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { diff --git a/tests/unit/out/unsafe/emplace_receiver_alias.rs b/tests/unit/out/unsafe/emplace_receiver_alias.rs index 559098fe0a..a10b8081da 100644 --- a/tests/unit/out/unsafe/emplace_receiver_alias.rs +++ b/tests/unit/out/unsafe/emplace_receiver_alias.rs @@ -32,11 +32,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { (&mut (*alias))[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_1), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( diff --git a/tests/unit/out/unsafe/emplace_receiver_order.rs b/tests/unit/out/unsafe/emplace_receiver_order.rs index cdce826975..907e754b3e 100644 --- a/tests/unit/out/unsafe/emplace_receiver_order.rs +++ b/tests/unit/out/unsafe/emplace_receiver_order.rs @@ -40,11 +40,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_0; - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_1), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -72,11 +70,9 @@ unsafe fn main_0() -> i32 { { rows[(0_usize)].as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = __tmp_3; - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_4), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_4), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index a0389c4cc8..2754b6c1ed 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -30,9 +30,15 @@ impl P { impl Cpp17EqualityComparableUnsafe for P { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const P); + let __rhs = (__rhs.as_ptr() as *const P); + __return.write((unsafe { P::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const P); let __rhs = (__rhs.as_ptr() as *const P); return (unsafe { P::operator_eq(&raw const (*__lhs), __rhs) }); @@ -63,26 +69,21 @@ unsafe fn main_0() -> i32 { let mut it: UnsafeRandomAccessIterator = { let mut __tmp_3 = { (v_end).clone() }; let mut __it = (v_begin).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_3), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&2), - ), + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_3), + ) && !>::is_equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&2), ) { __it.iter_inc(); } __it }; - let mut v_result_true: bool = - ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&v.end()), - )); + let mut v_result_true: bool = WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&v.end()), + ); let mut m: UnsafeMap = UnsafeMap::new(); { let mut __tmp_4: i32; @@ -107,79 +108,78 @@ unsafe fn main_0() -> i32 { }; let mut m_begin: UnsafeBidirectionalIterator<(i32, f64)> = m.begin(); let mut m_end: UnsafeBidirectionalIterator<(i32, f64)> = m.end(); - let mut m_result_true: bool = - ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&m_begin), - LvalueRefUnsafe::>>::bind(&m_end), - )); + let mut m_result_true: bool = WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&m_begin), + LvalueRefUnsafe::>>::bind(&m_end), + ); assert!( ((v_result_true) && (m_result_true)) - && (ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + && (Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&{ let mut __tmp_7 = { v.begin() }; let mut __tmp_8 = { v.begin() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), )) { __it.iter_inc(); } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind(&v.begin()), - ))) + )) ); let mut w: Vec = Vec::from([1, 2, 3, 4, 5]); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_9 = { w.begin().iter_add(2_isize) }; - let mut __tmp_10 = { w.end() }; - let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind( - &w.begin().iter_add(3_isize) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_9 = { w.begin().iter_add(2_isize) }; + let mut __tmp_10 = { w.end() }; + let mut __it = (__tmp_9).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&4 ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind( + &w.begin().iter_add(3_isize) + ), )); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_11 = { w.begin().iter_add(2_isize) }; - let mut __tmp_12 = { w.end() }; - let mut __it = (__tmp_11).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind(&w.end()), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_11 = { w.begin().iter_add(2_isize) }; + let mut __tmp_12 = { w.end() }; + let mut __it = (__tmp_11).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_12 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&1 ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind(&w.end()), )); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_13 = { w.begin().iter_add(2_isize) }; - let mut __tmp_14 = { w.begin().iter_add(4_isize) }; - let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind( - &w.begin().iter_add(4_isize) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_13 = { w.begin().iter_add(2_isize) }; + let mut __tmp_14 = { w.begin().iter_add(4_isize) }; + let mut __it = (__tmp_13).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&5 ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind( + &w.begin().iter_add(4_isize) + ), )); let mut p: Vec

= Vec::from([P { x: 0 }, P { x: 1 }, P { x: 2 }]); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_15 = { p.begin() }; - let mut __tmp_16 = { p.end() }; - let mut __it = (__tmp_15).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ), ) && !ConvertibleToUnsafe::::convert_value(

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind( - &p.begin().iter_add(1_isize) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_15 = { p.begin() }; + let mut __tmp_16 = { p.end() }; + let mut __it = (__tmp_15).clone(); + while + as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_16), + ) && !

>::is_equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&(P { x: 1 })), + ) + { + __it.iter_inc(); + } + __it + }), + LvalueRefUnsafe::>>::bind(&p.begin().iter_add(1_isize)), )); return 0; } diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index fc4ec140a9..89deb42c78 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -37,9 +37,20 @@ pub struct V { impl Cpp17EqualityComparableUnsafe for V { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + __return.write( + (unsafe { + let _a: *const V = __lhs; + operator_eq_1(_a, __rhs) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const V); let __rhs = (__rhs.as_ptr() as *const V); return (unsafe { diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index 3287e46f21..fba99d9e71 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -20,11 +20,9 @@ pub static mut selected_1: std::cell::LazyCell = std::cell::LazyCell::new(| { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -48,11 +46,9 @@ pub static mut assigned_4: std::cell::LazyCell = std::cell::LazyCell::new(| (*{ let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -75,11 +71,9 @@ pub static mut accumulated_5: std::cell::LazyCell = std::cell::LazyCell::ne (*{ let __a: *const _ = &mut __tmp_4; let __b: *const _ = &mut __tmp_5; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -141,11 +135,9 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_8; let __b: *const _ = &mut __tmp_9; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -162,11 +154,9 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_11; let __b: *const _ = &mut __tmp_12; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -192,11 +182,9 @@ pub static mut mapped_selected_12: std::cell::LazyCell = let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_13; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -217,11 +205,9 @@ static mut value_14: std::cell::LazyCell = std::cell::LazyCell::new(|| un (*{ let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_14; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -263,11 +249,9 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_16; let __b: *const _ = &mut __tmp_17; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -284,11 +268,9 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_19; let __b: *const _ = &mut __tmp_20; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index c75104abee..14eaa7b0e1 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -225,49 +225,45 @@ unsafe fn main_0() -> i32 { let mut it: UnsafeBidirectionalIterator<(i16, u32)> = m.find(&1_i16); let mut const_it: UnsafeBidirectionalIterator<(i16, u32)> = >::from(m.find(&10_i16)); - let mut x1: u32 = - if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&end), - )) { - 0_u32 - } else { - (*it.iter_deref()).1 - }; + let mut x1: u32 = if Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&end), + ) { + 0_u32 + } else { + (*it.iter_deref()).1 + }; assert!(((x1) == (4_u32))); - let mut x2: u32 = - if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&const_it), - LvalueRefUnsafe::>>::bind( - &>::from((end).clone()), - ), - )) { - 0_u32 - } else { - (*const_it.iter_deref()).1 - }; + let mut x2: u32 = if Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&const_it), + LvalueRefUnsafe::>>::bind( + &>::from((end).clone()), + ), + ) { + 0_u32 + } else { + (*const_it.iter_deref()).1 + }; assert!(((x2) == (0_u32))); - let mut x3: u32 = - if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&m.end()), - )) { - 0_u32 - } else { - (*it.iter_deref()).1 - }; + let mut x3: u32 = if Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&m.end()), + ) { + 0_u32 + } else { + (*it.iter_deref()).1 + }; assert!(((x3) == (4_u32))); - let mut x4: u32 = - if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&const_it), - LvalueRefUnsafe::>>::bind( - &>::from(m.end()), - ), - )) { - 0_u32 - } else { - (*const_it.iter_deref()).1 - }; + let mut x4: u32 = if Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&const_it), + LvalueRefUnsafe::>>::bind( + &>::from(m.end()), + ), + ) { + 0_u32 + } else { + (*const_it.iter_deref()).1 + }; assert!(((x4) == (0_u32))); { let mut __tmp_18: i16; @@ -309,23 +305,15 @@ unsafe fn main_0() -> i32 { assert!((((*const_it4.iter_deref()).1) == (6_u32))); let r: *mut UnsafeMap = &mut m; assert!((((*r).len()) == (4_usize))); - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind( - &m.find(&4_i16) - ), - LvalueRefUnsafe::>>::bind(&m.end()), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&m.find(&4_i16)), + LvalueRefUnsafe::>>::bind(&m.end()), )); (*r).erase(&(it4).clone()); assert!((((*r).len()) == (3_usize))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &m.find(&4_i16) - ), - LvalueRefUnsafe::>>::bind(&m.end()), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&m.find(&4_i16)), + LvalueRefUnsafe::>>::bind(&m.end()), )); { let mut __tmp_21: i16; @@ -356,31 +344,21 @@ unsafe fn main_0() -> i32 { let mut cit: UnsafeBidirectionalIterator<(i16, u32)> = >::from(m.find(&7_i16)); let mut next: UnsafeBidirectionalIterator<(i16, u32)> = m.erase(&(cit).clone()); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&next), - LvalueRefUnsafe::>>::bind( - &m.find(&8_i16) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&next), + LvalueRefUnsafe::>>::bind(&m.find(&8_i16)), )); { next = m.erase(&(next).clone()); }; - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&next), - LvalueRefUnsafe::>>::bind(&m.end()), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&next), + LvalueRefUnsafe::>>::bind(&m.end()), )); assert!((((*r).len()) == (3_usize))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &m.find(&8_i16) - ), - LvalueRefUnsafe::>>::bind(&m.end()), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&m.find(&8_i16)), + LvalueRefUnsafe::>>::bind(&m.end()), )); let mut other_map: UnsafeMap<(i32, i64), ((i32, i64), f64)> = UnsafeMap::new(); assert!(((other_map.len()) == (0_usize))); diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 89dd76ab6b..33a054dfcc 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -41,9 +41,18 @@ impl Key { impl LessThanComparableUnsafe for Key { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + __return.write((unsafe { Key::operator_lt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Key); let __rhs = (__rhs.as_ptr() as *const Key); return (unsafe { Key::operator_lt(&raw const (*__lhs), __rhs) }); diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index a1e3d15c38..ae939ec3ff 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -28,9 +28,23 @@ pub struct Key { impl Cpp17EqualityComparableUnsafe for Key { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + __return.write( + (unsafe { + let _a: *const Key = __lhs; + operator_eq_1(_a, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Key); let __rhs = (__rhs.as_ptr() as *const Key); return (unsafe { @@ -42,9 +56,23 @@ impl Cpp17EqualityComparableUnsafe for Key { impl LessThanComparableUnsafe for Key { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Key); + let __rhs = (__rhs.as_ptr() as *const Key); + __return.write( + (unsafe { + let _a: *const Key = __lhs; + operator_lt_2(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Key); let __rhs = (__rhs.as_ptr() as *const Key); return (unsafe { @@ -133,28 +161,26 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((a) != (b)) as i32)) != 0; ok = ((ok as i32) & (((((*a).value) == (11)) && (((*b).value) == (22))) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&a_it), LvalueRefUnsafe::>>::bind( &distinct.find(&distinct_a), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&b_it), LvalueRefUnsafe::>>::bind( &distinct.find(&distinct_b), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&b_it), - LvalueRefUnsafe::>>::bind( - &distinct.end(), - ), + & ((WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&b_it), + LvalueRefUnsafe::>>::bind( + &distinct.end(), ), )) as i32)) != 0; @@ -213,37 +239,35 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((equivalent.len()) == (1_usize)) as i32)) != 0; if reused { ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind( - &first_it, - ), - LvalueRefUnsafe::>>::bind( - &equivalent.end(), - ), + & ((WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind( + &first_it, + ), + LvalueRefUnsafe::>>::bind( + &equivalent.end(), ), )) as i32)) != 0; ok = ((ok as i32) & (((first) == (second)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind( &first_it, ), LvalueRefUnsafe::>>::bind( &equivalent.find(&equivalent_a), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind( &first_it, ), LvalueRefUnsafe::>>::bind( &equivalent.find(&equivalent_b), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) & (((&mut (*first_it.iter_deref()).1 as *mut Mapped) == (first_value)) as i32)) @@ -281,14 +305,14 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((equivalent.len()) == (2_usize)) as i32)) != 0; if reused { ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind( &first_it, ), LvalueRefUnsafe::>>::bind( &equivalent.find(&equivalent_a), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) & (((&mut (*first_it.iter_deref()).1 as *mut Mapped) == (first_value)) as i32)) @@ -327,12 +351,12 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((matching.len()) == (1_usize)) as i32)) != 0; ok = ((ok as i32) & (((matched) == (matched_again)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( &matching.find(&matching_b), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) & (((&mut (*matched_it.iter_deref()).1 as *mut Mapped) == (matched_value)) as i32)) @@ -346,12 +370,12 @@ unsafe fn main_0() -> i32 { != 0; ok = ((ok as i32) & (((matching.len()) == (2_usize)) as i32)) != 0; ok = ((ok as i32) - & ((ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + & ((Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( &matching.find(&matching_a), ), - ))) as i32)) + )) as i32)) != 0; ok = ((ok as i32) & (((&mut (*matched_it.iter_deref()).1 as *mut Mapped) == (matched_value)) as i32)) diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 9f184fe05b..fe8265d1b5 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -220,26 +220,26 @@ unsafe fn main_0() -> i32 { as i32)) != 0; let mut found: bool = - ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::< - Const< - UnsafeBidirectionalIterator< - (i32, i32), - >, - >, - >::bind( - &result.0 - ), - LvalueRefUnsafe::< - Const< - UnsafeBidirectionalIterator< - (i32, i32), - >, - >, - >::bind( - &m.find(&key) - ), + Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::< + Const< + UnsafeBidirectionalIterator<( + i32, + i32, + )>, + >, + >::bind( + &result.0 + ), + LvalueRefUnsafe::< + Const< + UnsafeBidirectionalIterator<( + i32, + i32, + )>, + >, + >::bind( + &m.find(&key) ), ); ok = ((ok as i32) & (found as i32)) != 0; diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index f7b84612b1..89a413dddb 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -48,9 +48,23 @@ impl Bag { impl LessThanComparableUnsafe for Bag { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + __return.write( + (unsafe { + let _a: *const Bag = __lhs; + operator_lt_4(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Bag); let __rhs = (__rhs.as_ptr() as *const Bag); return (unsafe { @@ -82,10 +96,10 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = &mut x1; let __b: *const _ = &mut x2; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -94,10 +108,10 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = &mut x3; let __b: *const _ = &mut x4; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -106,10 +120,10 @@ unsafe fn main_0() -> i32 { let mut r3: i32 = (*{ let __a: *const _ = p1; let __b: *const _ = &mut x2; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -118,10 +132,10 @@ unsafe fn main_0() -> i32 { let mut r4: i32 = (*{ let __a: *const _ = p2; let __b: *const _ = &mut x3; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -133,10 +147,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -149,25 +163,19 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { values.as_mut_ptr() }; let mut __tmp_3 = { values.as_mut_ptr().offset((4) as isize) }; let mut __best = __tmp_2.clone(); - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__tmp_2), - LvalueRefUnsafe::>::bind(&__tmp_3), - ), + if <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__tmp_2), + LvalueRefUnsafe::>::bind(&__tmp_3), ) { let mut __it = __tmp_2; __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_3), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), ) { - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__best.iter_deref()), - LvalueRefUnsafe::>::bind(__it.iter_deref()), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__best.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } @@ -181,10 +189,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(0) }); let __b: *const _ = (unsafe { pick_3(1) }); - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -196,10 +204,10 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(1) }); let __b: *const _ = (unsafe { pick_3(0) }); - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -225,11 +233,9 @@ unsafe fn main_0() -> i32 { (__tmp_4, __tmp_6) => { let __a: *const _ = __tmp_4; let __b: *const _ = __tmp_6; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -254,11 +260,9 @@ unsafe fn main_0() -> i32 { (__tmp_8, __tmp_10) => { let __a: *const _ = __tmp_8; let __b: *const _ = __tmp_10; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -281,11 +285,9 @@ unsafe fn main_0() -> i32 { (__tmp_12,) => { let __a: *const _ = &mut __tmp_13; let __b: *const _ = __tmp_12; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { diff --git a/tests/unit/out/unsafe/min_max_ptr2ptr.rs b/tests/unit/out/unsafe/min_max_ptr2ptr.rs index 9d5fdf97eb..1958933cd7 100644 --- a/tests/unit/out/unsafe/min_max_ptr2ptr.rs +++ b/tests/unit/out/unsafe/min_max_ptr2ptr.rs @@ -22,10 +22,10 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -34,10 +34,10 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -51,11 +51,9 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -67,11 +65,9 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -83,11 +79,9 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { @@ -99,11 +93,9 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if ConvertibleToUnsafe::::convert_value( - <*mut i32 as LessThanComparableUnsafe>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if <*mut i32 as LessThanComparableUnsafe>::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { __b } else { diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index 07dca2df96..e8630573ba 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -31,9 +31,18 @@ impl Eq { impl Cpp17EqualityComparableUnsafe for Eq { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + __return.write((unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Eq); let __rhs = (__rhs.as_ptr() as *const Eq); return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); @@ -42,9 +51,18 @@ impl Cpp17EqualityComparableUnsafe for Eq { impl WeaklyEqualityComparableWithUnsafe for Eq { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + __return.write(!(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Eq); let __rhs = (__rhs.as_ptr() as *const Eq); return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); @@ -92,9 +110,18 @@ impl Cmp { impl Cpp17EqualityComparableUnsafe for Cmp { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write((unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); @@ -103,9 +130,18 @@ impl Cpp17EqualityComparableUnsafe for Cmp { impl WeaklyEqualityComparableWithUnsafe for Cmp { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(!(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); @@ -114,9 +150,20 @@ impl WeaklyEqualityComparableWithUnsafe for Cmp { impl LessThanComparableUnsafe for Cmp { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -125,36 +172,80 @@ impl LessThanComparableUnsafe for Cmp { impl PartiallyOrderedWithUnsafe for Cmp { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_gt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lteq( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_gteq( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -205,9 +296,18 @@ impl Both { impl Cpp17EqualityComparableUnsafe for Both { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write((unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return (unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); @@ -216,9 +316,18 @@ impl Cpp17EqualityComparableUnsafe for Both { impl WeaklyEqualityComparableWithUnsafe for Both { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(!(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return !(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); @@ -227,9 +336,20 @@ impl WeaklyEqualityComparableWithUnsafe for Both { impl LessThanComparableUnsafe for Both { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(libcc2rs::is_lt( + (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -238,36 +358,80 @@ impl LessThanComparableUnsafe for Both { impl PartiallyOrderedWithUnsafe for Both { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(libcc2rs::is_lt( + (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(libcc2rs::is_gt( + (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return libcc2rs::is_gt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(libcc2rs::is_lteq( + (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return libcc2rs::is_lteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Both); + let __rhs = (__rhs.as_ptr() as *const Both); + __return.write(libcc2rs::is_gteq( + (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Both); let __rhs = (__rhs.as_ptr() as *const Both); return libcc2rs::is_gteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -315,9 +479,20 @@ impl OrdOnly { impl LessThanComparableUnsafe for OrdOnly { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + __return.write(libcc2rs::is_lt( + (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OrdOnly); let __rhs = (__rhs.as_ptr() as *const OrdOnly); return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -326,36 +501,80 @@ impl LessThanComparableUnsafe for OrdOnly { impl PartiallyOrderedWithUnsafe for OrdOnly { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + __return.write(libcc2rs::is_lt( + (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OrdOnly); let __rhs = (__rhs.as_ptr() as *const OrdOnly); return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + __return.write(libcc2rs::is_gt( + (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OrdOnly); let __rhs = (__rhs.as_ptr() as *const OrdOnly); return libcc2rs::is_gt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + __return.write(libcc2rs::is_lteq( + (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OrdOnly); let __rhs = (__rhs.as_ptr() as *const OrdOnly); return libcc2rs::is_lteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const OrdOnly); + let __rhs = (__rhs.as_ptr() as *const OrdOnly); + __return.write(libcc2rs::is_gteq( + (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OrdOnly); let __rhs = (__rhs.as_ptr() as *const OrdOnly); return libcc2rs::is_gteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -395,9 +614,18 @@ impl Inner { impl Cpp17EqualityComparableUnsafe for Inner { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write((unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return (unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); @@ -406,9 +634,18 @@ impl Cpp17EqualityComparableUnsafe for Inner { impl WeaklyEqualityComparableWithUnsafe for Inner { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(!(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return !(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); @@ -417,9 +654,20 @@ impl WeaklyEqualityComparableWithUnsafe for Inner { impl LessThanComparableUnsafe for Inner { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(libcc2rs::is_lt( + (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -428,36 +676,80 @@ impl LessThanComparableUnsafe for Inner { impl PartiallyOrderedWithUnsafe for Inner { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(libcc2rs::is_lt( + (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(libcc2rs::is_gt( + (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return libcc2rs::is_gt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(libcc2rs::is_lteq( + (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return libcc2rs::is_lteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Inner); + let __rhs = (__rhs.as_ptr() as *const Inner); + __return.write(libcc2rs::is_gteq( + (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inner); let __rhs = (__rhs.as_ptr() as *const Inner); return libcc2rs::is_gteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -521,9 +813,18 @@ impl Outer { impl Cpp17EqualityComparableUnsafe for Outer { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write((unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return (unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); @@ -532,9 +833,18 @@ impl Cpp17EqualityComparableUnsafe for Outer { impl WeaklyEqualityComparableWithUnsafe for Outer { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(!(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return !(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); @@ -543,9 +853,20 @@ impl WeaklyEqualityComparableWithUnsafe for Outer { impl LessThanComparableUnsafe for Outer { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(libcc2rs::is_lt( + (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -554,36 +875,80 @@ impl LessThanComparableUnsafe for Outer { impl PartiallyOrderedWithUnsafe for Outer { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(libcc2rs::is_lt( + (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(libcc2rs::is_gt( + (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return libcc2rs::is_gt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(libcc2rs::is_lteq( + (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return libcc2rs::is_lteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Outer); + let __rhs = (__rhs.as_ptr() as *const Outer); + __return.write(libcc2rs::is_gteq( + (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Outer); let __rhs = (__rhs.as_ptr() as *const Outer); return libcc2rs::is_gteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -646,9 +1011,18 @@ impl Secondary { impl Cpp17EqualityComparableUnsafe for Secondary { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write((unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return (unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs) }); @@ -657,9 +1031,18 @@ impl Cpp17EqualityComparableUnsafe for Secondary { impl WeaklyEqualityComparableWithUnsafe for Secondary { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write((unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return (unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs) }); @@ -668,9 +1051,18 @@ impl WeaklyEqualityComparableWithUnsafe for Secondary { impl LessThanComparableUnsafe for Secondary { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write((unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); @@ -679,36 +1071,76 @@ impl LessThanComparableUnsafe for Secondary { impl PartiallyOrderedWithUnsafe for Secondary { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write((unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write(libcc2rs::is_gt( + (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return libcc2rs::is_gt((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write(libcc2rs::is_lteq( + (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return libcc2rs::is_lteq((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Secondary); + let __rhs = (__rhs.as_ptr() as *const Secondary); + __return.write((unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Secondary); let __rhs = (__rhs.as_ptr() as *const Secondary); return (unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs) }); @@ -762,9 +1194,18 @@ impl PtrMember { impl Cpp17EqualityComparableUnsafe for PtrMember { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write((unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return (unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); @@ -773,9 +1214,18 @@ impl Cpp17EqualityComparableUnsafe for PtrMember { impl WeaklyEqualityComparableWithUnsafe for PtrMember { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(!(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return !(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); @@ -784,9 +1234,20 @@ impl WeaklyEqualityComparableWithUnsafe for PtrMember { impl LessThanComparableUnsafe for PtrMember { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(libcc2rs::is_lt( + (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -795,36 +1256,80 @@ impl LessThanComparableUnsafe for PtrMember { impl PartiallyOrderedWithUnsafe for PtrMember { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(libcc2rs::is_lt( + (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(libcc2rs::is_gt( + (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return libcc2rs::is_gt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(libcc2rs::is_lteq( + (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return libcc2rs::is_lteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const PtrMember); + let __rhs = (__rhs.as_ptr() as *const PtrMember); + __return.write(libcc2rs::is_gteq( + (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const PtrMember); let __rhs = (__rhs.as_ptr() as *const PtrMember); return libcc2rs::is_gteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 45871f4182..6f433a73fd 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -25,9 +25,20 @@ pub struct S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -39,9 +50,23 @@ impl Cpp17EqualityComparableUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_ne_1(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -53,9 +78,20 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_lt_2(_a, __rhs) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -67,9 +103,20 @@ impl LessThanComparableUnsafe for S { impl PartiallyOrderedWithUnsafe for S { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_lt_2(_a, __rhs) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -79,9 +126,23 @@ impl PartiallyOrderedWithUnsafe for S { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_gt_3(_a, __rhs) + }), + ); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -91,9 +152,23 @@ impl PartiallyOrderedWithUnsafe for S { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_le_4(_a, __rhs) + }), + ); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -103,9 +178,23 @@ impl PartiallyOrderedWithUnsafe for S { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: *const S = __lhs; + operator_ge_5(_a, __rhs) + }), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -157,9 +246,20 @@ pub struct V { impl Cpp17EqualityComparableUnsafe for V { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + __return.write( + (unsafe { + let _a: V = (*__lhs); + operator_eq_8(_a, (*__rhs)) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const V); let __rhs = (__rhs.as_ptr() as *const V); return (unsafe { @@ -171,9 +271,23 @@ impl Cpp17EqualityComparableUnsafe for V { impl WeaklyEqualityComparableWithUnsafe for V { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + __return.write( + (unsafe { + let _a: V = (*__lhs); + operator_ne_9(_a, (*__rhs)) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const V); let __rhs = (__rhs.as_ptr() as *const V); return (unsafe { @@ -185,9 +299,20 @@ impl WeaklyEqualityComparableWithUnsafe for V { impl LessThanComparableUnsafe for V { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const V); + let __rhs = (__rhs.as_ptr() as *const V); + __return.write( + (unsafe { + let _a: V = (*__lhs); + operator_lt_10(_a, (*__rhs)) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const V); let __rhs = (__rhs.as_ptr() as *const V); return (unsafe { diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 9199da3513..c136fe694d 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -48,9 +48,15 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); @@ -59,9 +65,18 @@ impl Cpp17EqualityComparableUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_ne(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_ne(&raw const (*__lhs), __rhs) }); @@ -70,9 +85,15 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); @@ -81,36 +102,69 @@ impl LessThanComparableUnsafe for S { impl PartiallyOrderedWithUnsafe for S { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_gt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_gt(&raw const (*__lhs), __rhs) }); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_le(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_le(&raw const (*__lhs), __rhs) }); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_ge(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_ge(&raw const (*__lhs), __rhs) }); diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index f278efaae9..51dd25d18c 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -45,9 +45,18 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write((unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) }); @@ -56,9 +65,23 @@ impl Cpp17EqualityComparableUnsafe for S { impl Cpp17EqualityComparableUnsafe for i32 { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = (*__lhs); + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -70,9 +93,18 @@ impl Cpp17EqualityComparableUnsafe for i32 { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write((unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) }); @@ -81,9 +113,23 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for i32 { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = (*__lhs); + operator_ne_1(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -95,9 +141,18 @@ impl WeaklyEqualityComparableWithUnsafe for i32 { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + __return.write((unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const f64); return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); @@ -106,9 +161,23 @@ impl Cpp17EqualityComparableUnsafe for S { impl Cpp17EqualityComparableUnsafe for f64 { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const f64); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const f64); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -120,9 +189,18 @@ impl Cpp17EqualityComparableUnsafe for f64 { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + __return.write((unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const f64); return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); @@ -131,9 +209,23 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for f64 { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const f64); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_ne_1(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const f64); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -145,9 +237,18 @@ impl WeaklyEqualityComparableWithUnsafe for f64 { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + __return.write((unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i64); return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); @@ -156,9 +257,23 @@ impl Cpp17EqualityComparableUnsafe for S { impl Cpp17EqualityComparableUnsafe for i64 { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i64); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -170,9 +285,18 @@ impl Cpp17EqualityComparableUnsafe for i64 { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + __return.write((unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) })); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i64); return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); @@ -181,9 +305,23 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for i64 { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_ne_1(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i64); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index a1b43366d0..2b53d9691b 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -25,93 +25,182 @@ pub struct X { impl Cpp17EqualityComparableUnsafe for X { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_eq_0(_a, (*__rhs)) - }); + }) != 0); } } impl WeaklyEqualityComparableWithUnsafe for X { type NotEqualResult = i32; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_ne_1(_a, (*__rhs)) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_ne_1(_a, (*__rhs)) - }); + }) != 0); } } impl LessThanComparableUnsafe for X { type Result = i32; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_lt_2(_a, (*__rhs)) - }); + }) != 0); } } impl PartiallyOrderedWithUnsafe for X { type LessResult = i32; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_lt_2(_a, (*__rhs)) - }); + }) != 0); } type GreaterResult = i32; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_gt_3(_a, (*__rhs)) + }), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_gt_3(_a, (*__rhs)) - }); + }) != 0); } type LessEqualResult = i32; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_le_4(_a, (*__rhs)) + }), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_le_4(_a, (*__rhs)) - }); + }) != 0); } type GreaterEqualResult = i32; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const X); let __rhs = (__rhs.as_ptr() as *const X); - return (unsafe { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_ge_5(_a, (*__rhs)) + }), + ); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const X); + let __rhs = (__rhs.as_ptr() as *const X); + return ((unsafe { let _a: X = (*__lhs); operator_ge_5(_a, (*__rhs)) - }); + }) != 0); } } pub unsafe fn operator_eq_0(mut a: X, mut b: X) -> i32 { @@ -203,23 +292,41 @@ impl Mixed { impl Cpp17EqualityComparableUnsafe for Mixed { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const Mixed); let __rhs = (__rhs.as_ptr() as *const Mixed); - return (unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) }); + __return.write((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const Mixed); + let __rhs = (__rhs.as_ptr() as *const Mixed); + return ((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) }) != 0); } } impl LessThanComparableUnsafe for Mixed { type Result = i32; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Mixed); + let __rhs = (__rhs.as_ptr() as *const Mixed); + __return.write((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Mixed); let __rhs = (__rhs.as_ptr() as *const Mixed); - return (unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) }); + return ((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) }) != 0); } } #[repr(C)] @@ -251,9 +358,21 @@ impl MyBool { impl Cpp17EqualityComparableUnsafe for MyBool { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -263,9 +382,21 @@ impl Cpp17EqualityComparableUnsafe for MyBool { impl WeaklyEqualityComparableWithUnsafe for MyBool { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + != ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -275,9 +406,21 @@ impl WeaklyEqualityComparableWithUnsafe for MyBool { impl LessThanComparableUnsafe for MyBool { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -287,9 +430,21 @@ impl LessThanComparableUnsafe for MyBool { impl PartiallyOrderedWithUnsafe for MyBool { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -297,9 +452,21 @@ impl PartiallyOrderedWithUnsafe for MyBool { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + > ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -307,9 +474,21 @@ impl PartiallyOrderedWithUnsafe for MyBool { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + <= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -317,9 +496,21 @@ impl PartiallyOrderedWithUnsafe for MyBool { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const MyBool); + let __rhs = (__rhs.as_ptr() as *const MyBool); + __return.write( + (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) + >= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MyBool); let __rhs = (__rhs.as_ptr() as *const MyBool); return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -359,28 +550,64 @@ pub struct Boolish { impl Cpp17EqualityComparableUnsafe for Boolish { type EqualResult = MyBool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Boolish); + let __rhs = (__rhs.as_ptr() as *const Boolish); + __return.write( + (unsafe { + let _a: Boolish = (*__lhs); + operator_eq_6(_a, (*__rhs)) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Boolish); let __rhs = (__rhs.as_ptr() as *const Boolish); return (unsafe { - let _a: Boolish = (*__lhs); - operator_eq_6(_a, (*__rhs)) + MyBool::to_bool( + &(unsafe { + let _a: Boolish = (*__lhs); + operator_eq_6(_a, (*__rhs)) + }), + ) }); } } impl LessThanComparableUnsafe for Boolish { type Result = MyBool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Boolish); + let __rhs = (__rhs.as_ptr() as *const Boolish); + __return.write( + (unsafe { + let _a: Boolish = (*__lhs); + operator_lt_7(_a, (*__rhs)) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Boolish); let __rhs = (__rhs.as_ptr() as *const Boolish); return (unsafe { - let _a: Boolish = (*__lhs); - operator_lt_7(_a, (*__rhs)) + MyBool::to_bool( + &(unsafe { + let _a: Boolish = (*__lhs); + operator_lt_7(_a, (*__rhs)) + }), + ) }); } } @@ -425,9 +652,21 @@ impl RefBool { impl Cpp17EqualityComparableUnsafe for RefBool { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -437,9 +676,21 @@ impl Cpp17EqualityComparableUnsafe for RefBool { impl WeaklyEqualityComparableWithUnsafe for RefBool { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + != ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -449,9 +700,21 @@ impl WeaklyEqualityComparableWithUnsafe for RefBool { impl LessThanComparableUnsafe for RefBool { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -461,9 +724,21 @@ impl LessThanComparableUnsafe for RefBool { impl PartiallyOrderedWithUnsafe for RefBool { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -471,9 +746,21 @@ impl PartiallyOrderedWithUnsafe for RefBool { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + > ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -481,9 +768,21 @@ impl PartiallyOrderedWithUnsafe for RefBool { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + <= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -491,9 +790,21 @@ impl PartiallyOrderedWithUnsafe for RefBool { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const RefBool); + let __rhs = (__rhs.as_ptr() as *const RefBool); + __return.write( + (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) + >= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), + ); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const RefBool); let __rhs = (__rhs.as_ptr() as *const RefBool); return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) @@ -545,14 +856,27 @@ impl RefInt { impl Cpp17EqualityComparableUnsafe for RefInt { type EqualResult = LvalueRefUnsafe; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const RefInt); let __rhs = (__rhs.as_ptr() as *const RefInt); - return LvalueRefUnsafe::bind( + __return.write(LvalueRefUnsafe::bind( &mut (*(unsafe { RefInt::operator_eq(&raw const (*__lhs), __rhs) })), - ); + )); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const RefInt); + let __rhs = (__rhs.as_ptr() as *const RefInt); + return (unsafe { + RefBool::to_bool( + &raw const (*(unsafe { RefInt::operator_eq(&raw const (*__lhs), __rhs) })), + ) + }); } } pub fn main() { @@ -615,16 +939,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const X; let __b = __tmp_0.iter_at(__y) as *const X; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -659,18 +981,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_1.iter_at(__x) as *const Mixed; let __b = __tmp_1.iter_at(__y) as *const Mixed; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -730,18 +1048,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_2.iter_at(__x) as *const Boolish; let __b = __tmp_2.iter_at(__y) as *const Boolish; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -772,16 +1086,12 @@ unsafe fn main_0() -> i32 { (({ let mut __tmp_3 = { ris.as_mut_ptr().offset((2) as isize) }; let mut __it = ris.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut RefInt as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_3), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&ri2), - ), + while <*mut RefInt as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), + ) && !>::is_equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&ri2), ) { __it.iter_inc(); } diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index dca006b330..9a58bc8319 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -31,9 +31,20 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _x: *const S = __lhs; + operator_eq_0(_x, __rhs) + }), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { @@ -45,9 +56,20 @@ impl Cpp17EqualityComparableUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _x: *const S = __lhs; + operator_lt_1(_x, __rhs) + }), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 945ec78f03..3a2e59172e 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -29,9 +29,23 @@ pub struct Defaulted { impl Cpp17EqualityComparableUnsafe for Defaulted { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Defaulted); + let __rhs = (__rhs.as_ptr() as *const Defaulted); + __return.write( + (unsafe { + let _arg0: *const Defaulted = __lhs; + operator_eq_0(_arg0, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Defaulted); let __rhs = (__rhs.as_ptr() as *const Defaulted); return (unsafe { @@ -43,9 +57,23 @@ impl Cpp17EqualityComparableUnsafe for Defaulted { impl WeaklyEqualityComparableWithUnsafe for Defaulted { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Defaulted); + let __rhs = (__rhs.as_ptr() as *const Defaulted); + __return.write( + !(unsafe { + let _arg0: *const Defaulted = __lhs; + operator_eq_0(_arg0, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Defaulted); let __rhs = (__rhs.as_ptr() as *const Defaulted); return !(unsafe { @@ -89,9 +117,23 @@ pub struct DefaultedOrd { impl Cpp17EqualityComparableUnsafe for DefaultedOrd { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_eq_2(_arg0, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return (unsafe { @@ -103,9 +145,23 @@ impl Cpp17EqualityComparableUnsafe for DefaultedOrd { impl WeaklyEqualityComparableWithUnsafe for DefaultedOrd { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write( + !(unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_eq_2(_arg0, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return !(unsafe { @@ -117,9 +173,23 @@ impl WeaklyEqualityComparableWithUnsafe for DefaultedOrd { impl LessThanComparableUnsafe for DefaultedOrd { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write(libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return libcc2rs::is_lt( @@ -133,9 +203,23 @@ impl LessThanComparableUnsafe for DefaultedOrd { impl PartiallyOrderedWithUnsafe for DefaultedOrd { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write(libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return libcc2rs::is_lt( @@ -147,9 +231,23 @@ impl PartiallyOrderedWithUnsafe for DefaultedOrd { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write(libcc2rs::is_gt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + )); + } + unsafe fn is_greater( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return libcc2rs::is_gt( @@ -161,9 +259,23 @@ impl PartiallyOrderedWithUnsafe for DefaultedOrd { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write(libcc2rs::is_lteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return libcc2rs::is_lteq( @@ -175,9 +287,23 @@ impl PartiallyOrderedWithUnsafe for DefaultedOrd { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); + let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); + __return.write(libcc2rs::is_gteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); return libcc2rs::is_gteq( @@ -232,9 +358,23 @@ pub struct Inline { impl Cpp17EqualityComparableUnsafe for Inline { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + __return.write( + (unsafe { + let _x: *const Inline = __lhs; + operator_eq_3(_x, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inline); let __rhs = (__rhs.as_ptr() as *const Inline); return (unsafe { @@ -246,9 +386,23 @@ impl Cpp17EqualityComparableUnsafe for Inline { impl WeaklyEqualityComparableWithUnsafe for Inline { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + __return.write( + !(unsafe { + let _x: *const Inline = __lhs; + operator_eq_3(_x, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inline); let __rhs = (__rhs.as_ptr() as *const Inline); return !(unsafe { @@ -260,9 +414,23 @@ impl WeaklyEqualityComparableWithUnsafe for Inline { impl LessThanComparableUnsafe for Inline { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Inline); + let __rhs = (__rhs.as_ptr() as *const Inline); + __return.write( + (unsafe { + let _x: *const Inline = __lhs; + operator_lt_4(_x, __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Inline); let __rhs = (__rhs.as_ptr() as *const Inline); return (unsafe { @@ -290,9 +458,23 @@ pub struct OutOfLine { impl Cpp17EqualityComparableUnsafe for OutOfLine { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const OutOfLine); + let __rhs = (__rhs.as_ptr() as *const OutOfLine); + __return.write( + (unsafe { + let _x: *const OutOfLine = __lhs; + operator_eq_6(_x, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OutOfLine); let __rhs = (__rhs.as_ptr() as *const OutOfLine); return (unsafe { @@ -304,9 +486,23 @@ impl Cpp17EqualityComparableUnsafe for OutOfLine { impl WeaklyEqualityComparableWithUnsafe for OutOfLine { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const OutOfLine); + let __rhs = (__rhs.as_ptr() as *const OutOfLine); + __return.write( + (unsafe { + let _x: *const OutOfLine = __lhs; + operator_ne_7(_x, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const OutOfLine); let __rhs = (__rhs.as_ptr() as *const OutOfLine); return (unsafe { @@ -352,9 +548,23 @@ pub struct Tmpl_int_ { impl Cpp17EqualityComparableUnsafe for Tmpl_int_ { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + __return.write( + (unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_eq_8(_x, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); return (unsafe { @@ -366,9 +576,23 @@ impl Cpp17EqualityComparableUnsafe for Tmpl_int_ { impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + __return.write( + !(unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_eq_8(_x, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); return !(unsafe { @@ -380,9 +604,23 @@ impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { impl LessThanComparableUnsafe for Tmpl_int_ { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); + __return.write( + (unsafe { + let _x: *const Tmpl_int_ = __lhs; + operator_lt_9(_x, __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); return (unsafe { @@ -416,9 +654,23 @@ pub struct Tmpl_long_ { impl Cpp17EqualityComparableUnsafe for Tmpl_long_ { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + __return.write( + (unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_eq_11(_x, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); return (unsafe { @@ -430,9 +682,23 @@ impl Cpp17EqualityComparableUnsafe for Tmpl_long_ { impl WeaklyEqualityComparableWithUnsafe for Tmpl_long_ { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + __return.write( + !(unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_eq_11(_x, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); return !(unsafe { @@ -444,9 +710,23 @@ impl WeaklyEqualityComparableWithUnsafe for Tmpl_long_ { impl LessThanComparableUnsafe for Tmpl_long_ { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); + let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); + __return.write( + (unsafe { + let _x: *const Tmpl_long_ = __lhs; + operator_lt_12(_x, __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); return (unsafe { @@ -480,9 +760,23 @@ pub struct TmplDefaulted_int_ { impl Cpp17EqualityComparableUnsafe for TmplDefaulted_int_ { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); + let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); + __return.write( + (unsafe { + let _arg0: *const TmplDefaulted_int_ = __lhs; + operator_eq_13(_arg0, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); return (unsafe { @@ -494,9 +788,23 @@ impl Cpp17EqualityComparableUnsafe for TmplDefaulted_int_ { impl WeaklyEqualityComparableWithUnsafe for TmplDefaulted_int_ { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); + let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); + __return.write( + !(unsafe { + let _arg0: *const TmplDefaulted_int_ = __lhs; + operator_eq_13(_arg0, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); return !(unsafe { diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index 7565b4f1c1..8cce81ca50 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -68,9 +68,18 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + == (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -80,9 +89,21 @@ impl Cpp17EqualityComparableUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + != (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -92,9 +113,18 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + < (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -104,9 +134,18 @@ impl LessThanComparableUnsafe for S { impl PartiallyOrderedWithUnsafe for S { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + < (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -114,9 +153,21 @@ impl PartiallyOrderedWithUnsafe for S { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + > (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -124,9 +175,21 @@ impl PartiallyOrderedWithUnsafe for S { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + <= (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) @@ -134,9 +197,21 @@ impl PartiallyOrderedWithUnsafe for S { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + ((unsafe { S::to_i32(&raw const (*__lhs)) }) + >= (unsafe { S::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return ((unsafe { S::to_i32(&raw const (*__lhs)) }) diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 6a1fafdb74..1feeabcb33 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -48,62 +48,117 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) }); + __return.write((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i32); + return ((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) }) != 0); } } impl Cpp17EqualityComparableUnsafe for i32 { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const i32); let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { + __return.write( + (unsafe { + let _a: i32 = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const S); + return ((unsafe { let _a: i32 = (*__lhs); operator_eq_0(_a, (*__rhs)) - }); + }) != 0); } } impl Cpp17EqualityComparableUnsafe for S { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const i64); - return (unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) }); + __return.write((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const i64); + return ((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) }) != 0); } } impl Cpp17EqualityComparableUnsafe for i64 { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const i64); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write( + (unsafe { + let _a: i64 = (*__lhs); + operator_eq_1(_a, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const i64); let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { + return ((unsafe { let _a: i64 = (*__lhs); operator_eq_1(_a, __rhs) - }); + }) != 0); } } impl Cpp17EqualityComparableUnsafe for S { type EqualResult = i32; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const f64); + __return.write((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) })); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const f64); - return (unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) }); + return ((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) }) != 0); } } pub unsafe fn operator_div_2(a: *const S, b: *const S) -> i32 { diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 8e3904bb57..4323f5b3c4 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -39,9 +39,15 @@ impl S { impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write((unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); @@ -50,9 +56,18 @@ impl Cpp17EqualityComparableUnsafe for S { impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(!(unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return !(unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); @@ -61,9 +76,17 @@ impl WeaklyEqualityComparableWithUnsafe for S { impl LessThanComparableUnsafe for S { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(libcc2rs::is_lt( + (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -72,36 +95,77 @@ impl LessThanComparableUnsafe for S { impl PartiallyOrderedWithUnsafe for S { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(libcc2rs::is_lt( + (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(libcc2rs::is_gt( + (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return libcc2rs::is_gt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(libcc2rs::is_lteq( + (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return libcc2rs::is_lteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const S); + let __rhs = (__rhs.as_ptr() as *const S); + __return.write(libcc2rs::is_gteq( + (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const S); let __rhs = (__rhs.as_ptr() as *const S); return libcc2rs::is_gteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index cbd6e1f458..e046a16498 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -30,9 +30,18 @@ impl Lt { impl LessThanComparableUnsafe for Lt { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Lt); + let __rhs = (__rhs.as_ptr() as *const Lt); + __return.write((unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Lt); let __rhs = (__rhs.as_ptr() as *const Lt); return (unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs) }); @@ -62,9 +71,18 @@ impl Eq { impl Cpp17EqualityComparableUnsafe for Eq { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + __return.write((unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Eq); let __rhs = (__rhs.as_ptr() as *const Eq); return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); @@ -73,9 +91,18 @@ impl Cpp17EqualityComparableUnsafe for Eq { impl WeaklyEqualityComparableWithUnsafe for Eq { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Eq); + let __rhs = (__rhs.as_ptr() as *const Eq); + __return.write(!(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Eq); let __rhs = (__rhs.as_ptr() as *const Eq); return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); @@ -108,9 +135,18 @@ impl Cmp { impl Cpp17EqualityComparableUnsafe for Cmp { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write((unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); @@ -119,9 +155,18 @@ impl Cpp17EqualityComparableUnsafe for Cmp { impl WeaklyEqualityComparableWithUnsafe for Cmp { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(!(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); @@ -130,9 +175,20 @@ impl WeaklyEqualityComparableWithUnsafe for Cmp { impl LessThanComparableUnsafe for Cmp { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -141,36 +197,80 @@ impl LessThanComparableUnsafe for Cmp { impl PartiallyOrderedWithUnsafe for Cmp { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_gt( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_lteq( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Cmp); + let __rhs = (__rhs.as_ptr() as *const Cmp); + __return.write(libcc2rs::is_gteq( + (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Cmp); let __rhs = (__rhs.as_ptr() as *const Cmp); return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); @@ -206,9 +306,23 @@ pub struct Free { impl Cpp17EqualityComparableUnsafe for Free { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + __return.write( + (unsafe { + let _a: *const Free = __lhs; + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Free); let __rhs = (__rhs.as_ptr() as *const Free); return (unsafe { @@ -220,9 +334,23 @@ impl Cpp17EqualityComparableUnsafe for Free { impl WeaklyEqualityComparableWithUnsafe for Free { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + __return.write( + !(unsafe { + let _a: *const Free = __lhs; + operator_eq_0(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Free); let __rhs = (__rhs.as_ptr() as *const Free); return !(unsafe { @@ -234,9 +362,23 @@ impl WeaklyEqualityComparableWithUnsafe for Free { impl LessThanComparableUnsafe for Free { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Free); + let __rhs = (__rhs.as_ptr() as *const Free); + __return.write( + (unsafe { + let _a: *const Free = __lhs; + operator_lt_1(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Free); let __rhs = (__rhs.as_ptr() as *const Free); return (unsafe { @@ -276,9 +418,23 @@ pub struct Wrapped_int_ { impl Cpp17EqualityComparableUnsafe for Wrapped_int_ { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + __return.write( + (unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_eq_2(_a, __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); return (unsafe { @@ -290,9 +446,23 @@ impl Cpp17EqualityComparableUnsafe for Wrapped_int_ { impl WeaklyEqualityComparableWithUnsafe for Wrapped_int_ { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + __return.write( + !(unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_eq_2(_a, __rhs) + }), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); return !(unsafe { @@ -304,9 +474,23 @@ impl WeaklyEqualityComparableWithUnsafe for Wrapped_int_ { impl LessThanComparableUnsafe for Wrapped_int_ { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); + let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); + __return.write( + (unsafe { + let _a: *const Wrapped_int_ = __lhs; + operator_lt_3(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); return (unsafe { @@ -332,16 +516,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const Lt; let __b = __tmp_0.iter_at(__y) as *const Lt; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -362,40 +544,26 @@ unsafe fn main_0() -> i32 { let mut eqs: Vec = Vec::from([Eq { v: 1 }, Eq { v: 2 }, Eq { v: 3 }]); let mut two: Eq = Eq { v: 2 }; let mut nine: Eq = Eq { v: 9 }; - assert!( - (((*{ - let mut __tmp_1 = { eqs.begin() }; - let mut __tmp_2 = { eqs.end() }; - let mut __it = (__tmp_1).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( + assert!(( ( ( * { let mut __tmp_1 = { eqs .begin() };let mut __tmp_2 = { eqs .end() }; let mut __it = (__tmp_1 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&two ), ) { __it.iter_inc(); } __it } .iter_deref() ) . v ) == ( 2 ) ) ); + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_3 = { eqs.begin() }; + let mut __tmp_4 = { eqs.end() }; + let mut __it = (__tmp_3).clone(); + while + as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_2), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( + LvalueRefUnsafe::>>::bind(&__tmp_4), + ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&two), - ), - ) { + LvalueRefUnsafe::>::bind(&nine), + ) + { __it.iter_inc(); } __it - } - .iter_deref()) - .v) == (2)) - ); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_3 = { eqs.begin() }; - let mut __tmp_4 = { eqs.end() }; - let mut __it = (__tmp_3).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_4 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&nine ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind(&eqs.end()), - ) + }), + LvalueRefUnsafe::>>::bind(&eqs.end()), )); let mut cmps: Vec = Vec::from([Cmp { v: 3 }, Cmp { v: 1 }, Cmp { v: 2 }]); { @@ -405,16 +573,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_5.iter_at(__x) as *const Cmp; let __b = __tmp_5.iter_at(__y) as *const Cmp; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -431,29 +597,7 @@ unsafe fn main_0() -> i32 { }; assert!(((cmps[(0_usize)].v) == (1)) && ((cmps[(2_usize)].v) == (3))); let mut three: Cmp = Cmp { v: 3 }; - assert!( - (((*{ - let mut __tmp_6 = { cmps.begin() }; - let mut __tmp_7 = { cmps.end() }; - let mut __it = (__tmp_6).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_7), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&three), - ), - ) { - __it.iter_inc(); - } - __it - } - .iter_deref()) - .v) == (3)) - ); + assert!(( ( ( * { let mut __tmp_6 = { cmps .begin() };let mut __tmp_7 = { cmps .end() }; let mut __it = (__tmp_6 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_7 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&three ), ) { __it.iter_inc(); } __it } .iter_deref() ) . v ) == ( 3 ) ) ); let mut frees: Vec = Vec::from([Free { v: 2 }, Free { v: 1 }]); { let mut __tmp_8 = { frees.begin() }; @@ -462,16 +606,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_8.iter_at(__x) as *const Free; let __b = __tmp_8.iter_at(__y) as *const Free; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -488,29 +630,7 @@ unsafe fn main_0() -> i32 { }; assert!(((frees[(0_usize)].v) == (1))); let mut ftwo: Free = Free { v: 2 }; - assert!( - (((*{ - let mut __tmp_9 = { frees.begin() }; - let mut __tmp_10 = { frees.end() }; - let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_10), - ), - ) && !ConvertibleToUnsafe::::convert_value( - >::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&ftwo), - ), - ) { - __it.iter_inc(); - } - __it - } - .iter_deref()) - .v) == (2)) - ); + assert!(( ( ( * { let mut __tmp_9 = { frees .begin() };let mut __tmp_10 = { frees .end() }; let mut __it = (__tmp_9 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&ftwo ), ) { __it.iter_inc(); } __it } .iter_deref() ) . v ) == ( 2 ) ) ); let mut m: UnsafeMap = UnsafeMap::new(); { let mut __tmp_11: Lt; diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index 2afb6bf0c2..45583b4936 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -53,9 +53,21 @@ impl Meters { impl Cpp17EqualityComparableUnsafe for Meters { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + == (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -65,9 +77,21 @@ impl Cpp17EqualityComparableUnsafe for Meters { impl WeaklyEqualityComparableWithUnsafe for Meters { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + != (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -77,9 +101,21 @@ impl WeaklyEqualityComparableWithUnsafe for Meters { impl LessThanComparableUnsafe for Meters { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -89,9 +125,21 @@ impl LessThanComparableUnsafe for Meters { impl PartiallyOrderedWithUnsafe for Meters { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -99,9 +147,21 @@ impl PartiallyOrderedWithUnsafe for Meters { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + > (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -109,9 +169,21 @@ impl PartiallyOrderedWithUnsafe for Meters { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + <= (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) @@ -119,9 +191,21 @@ impl PartiallyOrderedWithUnsafe for Meters { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Meters); + let __rhs = (__rhs.as_ptr() as *const Meters); + __return.write( + ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) + >= (unsafe { Meters::to_i32(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Meters); let __rhs = (__rhs.as_ptr() as *const Meters); return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 07d8381c9e..5e8eecc6fa 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -82,11 +82,9 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { let mut __tmp_2 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_2), - ), + while <*mut u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_2), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -119,11 +117,9 @@ pub unsafe fn emplace_local_from_field_4(mut jpg: *mut JPEGData, mut cond: bool) let mut __tmp_3 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_3), - ), + while <*mut u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -286,11 +282,9 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { let mut __tmp_4 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while ConvertibleToUnsafe::::convert_value( - <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_4), - ), + while <*mut u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_4), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -367,11 +361,9 @@ pub unsafe fn emplace_from_sibling_18(mut s: *mut Bytes) { let mut __tmp_5 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while ConvertibleToUnsafe::::convert_value( - <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_5), - ), + while <*mut u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_5), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( diff --git a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs index 59b8b1c221..462b0b24c4 100644 --- a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs +++ b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs @@ -9,12 +9,12 @@ use std::rc::Rc; pub unsafe fn sink_0(mut it: UnsafeBidirectionalIterator<(i32, i32)>) -> i32 { let mut cit: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it).clone()); - return if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + return if Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&cit), LvalueRefUnsafe::>>::bind( &>::from((it).clone()), ), - )) { + ) { (*it.iter_deref()).1 } else { 0 @@ -39,22 +39,21 @@ unsafe fn main_0() -> i32 { let mut it0: UnsafeBidirectionalIterator<(i32, i32)> = m.find(&0); let mut const_it: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it0).clone()); - let mut r: i32 = - if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&const_it), - LvalueRefUnsafe::>>::bind( - &>::from((end).clone()), - ), - )) { - 0 - } else { - 1 - }; + let mut r: i32 = if Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&const_it), + LvalueRefUnsafe::>>::bind( + &>::from((end).clone()), + ), + ) { + 0 + } else { + 1 + }; r += (unsafe { sink_0((it0).clone()) }); - r += if ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( + r += if Cpp17EqualityComparableUnsafe::is_equal( LvalueRefUnsafe::>>::bind(&end), LvalueRefUnsafe::>>::bind(&end), - )) { + ) { 0 } else { 1 @@ -65,11 +64,9 @@ unsafe fn main_0() -> i32 { let mut const_middle: UnsafeRandomAccessIterator = >::from((middle).clone()); assert!(((*const_middle.iter_deref()) == (8_u32))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&const_middle), - LvalueRefUnsafe::>>::bind(&middle), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&const_middle), + LvalueRefUnsafe::>>::bind(&middle), )); return 0; } diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index 83aef3089c..de1f9e90c1 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -36,11 +36,9 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __first = src.as_mut_ptr(); let mut __out = (dst.as_mut_ptr() as *mut usize).cast::(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&__tmp_0), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_0), ) { object_unsafe!(__value, u64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), @@ -87,13 +85,9 @@ pub unsafe fn size_t_in_rules_3() { |__k| cpp_move_unsafe!(__k), || 0_u64, )) = 4_u64; - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind( - &m.find(&1_u64) - ), - LvalueRefUnsafe::>>::bind(&m.end()), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&m.find(&1_u64)), + LvalueRefUnsafe::>>::bind(&m.end()), )); assert!((((*m.begin().iter_deref()).0) == (1_u64))); let mut m2: UnsafeMap = std::mem::take(&mut m); @@ -213,11 +207,9 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_6 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_6), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_6), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -239,11 +231,9 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_8 = { v.begin() }; let mut __tmp_9 = { v.end() }; let mut __it = (__tmp_8).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_9), - ), + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_9), ) { *__it.iter_deref() = Clone::clone(&(k as u64)); __it.iter_inc(); @@ -259,10 +249,10 @@ pub unsafe fn size_t_in_rules_3() { (*{ let __a: *const _ = &mut v[(1_usize)]; let __b: *const _ = &mut __tmp_10; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -313,17 +303,15 @@ pub unsafe fn size_t_in_rules_3() { v3.push(__a2) } }; - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_13 = { v3.begin() }; - let mut __tmp_14 = { v3.end() }; - let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind(&v3.end()), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_13 = { v3.begin() }; + let mut __tmp_14 = { v3.end() }; + let mut __it = (__tmp_13).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind(&v3.end()), )); assert!((((v3.len()) == (5_usize)) && ((big) >= (k))) && (((pk.1) as usize) == (k))); let mut ci: UnsafeRandomAccessIterator = @@ -384,10 +372,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_15; let __b: *const _ = &mut __tmp_16; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -399,10 +387,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_17; let __b: *const _ = &mut ul; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -417,10 +405,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_18; let __b: *const _ = &mut __tmp_19; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -479,10 +467,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_20; let __b: *const _ = &mut __tmp_21; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -495,10 +483,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_22; let __b: *const _ = &mut __tmp_23; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -528,11 +516,9 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_24; let __b: *const _ = &mut __tmp_25; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { @@ -546,11 +532,9 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_26; let __b: *const _ = &mut __tmp_27; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { __b } else { diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index d7f3e5fd52..3ce8b977bb 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -61,16 +61,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_10.iter_at(__x) as *const i32; let __b = __tmp_10.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index f25877c892..e59e89160d 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -54,9 +54,23 @@ impl MoveAssignableUnsafe for Tracked { impl LessThanComparableUnsafe for Tracked { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Tracked); + let __rhs = (__rhs.as_ptr() as *const Tracked); + __return.write( + (unsafe { + let _a: *const Tracked = __lhs; + operator_lt_1(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Tracked); let __rhs = (__rhs.as_ptr() as *const Tracked); return (unsafe { @@ -106,9 +120,23 @@ impl MoveOnly { impl LessThanComparableUnsafe for MoveOnly { type Result = bool; unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const MoveOnly); + let __rhs = (__rhs.as_ptr() as *const MoveOnly); + __return.write( + (unsafe { + let _a: *const MoveOnly = __lhs; + operator_lt_3(_a, __rhs) + }), + ); + } + unsafe fn is_less( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const MoveOnly); let __rhs = (__rhs.as_ptr() as *const MoveOnly); return (unsafe { @@ -144,9 +172,23 @@ impl Bag { impl Cpp17EqualityComparableUnsafe for Bag { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + __return.write( + (unsafe { + let _a: *const Bag = __lhs; + operator_eq_4(_a, __rhs) + }), + ); + } + unsafe fn is_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Bag); let __rhs = (__rhs.as_ptr() as *const Bag); return (unsafe { @@ -158,9 +200,23 @@ impl Cpp17EqualityComparableUnsafe for Bag { impl LessThanComparableUnsafe for Bag { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Bag); + let __rhs = (__rhs.as_ptr() as *const Bag); + __return.write( + (unsafe { + let _a: *const Bag = __lhs; + operator_lt_5(_a, __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Bag); let __rhs = (__rhs.as_ptr() as *const Bag); return (unsafe { @@ -219,18 +275,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const Tracked; let __b = __tmp_0.iter_at(__y) as *const Tracked; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -284,18 +336,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_1.iter_at(__x) as *const Tracked; let __b = __tmp_1.iter_at(__y) as *const Tracked; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -444,16 +492,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_5.iter_at(__x) as *const Bag; let __b = __tmp_5.iter_at(__y) as *const Bag; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -496,16 +542,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_6.iter_at(__x) as *const Bag; let __b = __tmp_6.iter_at(__y) as *const Bag; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -525,42 +569,45 @@ unsafe fn main_0() -> i32 { && ((bag_vec[(2_usize)].items[(1_usize)].v) == (5)) ); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_7 = { bag_vec.begin() }; - let mut __tmp_8 = { bag_vec.end() }; - let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), )) { __it.iter_inc(); } - __it - }), - LvalueRefUnsafe::>>::bind( - &bag_vec.begin().iter_add(1_isize) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_7 = { bag_vec.begin() }; + let mut __tmp_8 = { bag_vec.end() }; + let mut __it = (__tmp_7).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::>>::bind( + &bag_vec.begin().iter_add(1_isize) + ), )); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind(&{ - let mut __tmp_9 = { bag_vec.begin() }; - let mut __tmp_10 = { bag_vec.end() }; - let mut __best = __tmp_9.clone(); - if ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_9 ), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { let mut __it = (__tmp_9 ).clone(); __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), )) { __best = __it.clone(); } __it.iter_inc(); } } - __best - }), - LvalueRefUnsafe::>>::bind( - &bag_vec.begin().iter_add(2_isize) - ), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind(&{ + let mut __tmp_9 = { bag_vec.begin() }; + let mut __tmp_10 = { bag_vec.end() }; + let mut __best = __tmp_9.clone(); + if as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__tmp_9), + LvalueRefUnsafe::>>::bind(&__tmp_10), + ) { + let mut __it = (__tmp_9).clone(); + __it.iter_inc(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ) { if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } __it.iter_inc(); } + } + __best + }), + LvalueRefUnsafe::>>::bind( + &bag_vec.begin().iter_add(2_isize) + ), )); assert!( (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a @@ -571,10 +618,10 @@ unsafe fn main_0() -> i32 { (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { __b } else { __a @@ -594,13 +641,11 @@ unsafe fn main_0() -> i32 { || 0_i32, )) = 0; assert!((((*bag_map.find(&bags[(2) as usize]).iter_deref()).1) == (2))); - assert!(ConvertibleToUnsafe::::convert_value( - Cpp17EqualityComparableUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &bag_map.find(&bags[(1) as usize]) - ), - LvalueRefUnsafe::>>::bind(&bag_map.end()), - ) + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind( + &bag_map.find(&bags[(1) as usize]) + ), + LvalueRefUnsafe::>>::bind(&bag_map.end()), )); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); let mut moves: Vec = Vec::new(); @@ -626,18 +671,14 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_11.iter_at(__x) as *const MoveOnly; let __b = __tmp_11.iter_at(__y) as *const MoveOnly; - if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - ), + if ::is_less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 6095ed86d6..1d4887e4dc 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -41,11 +41,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = output.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&__tmp_0), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_0), ) { object_unsafe!(__value, i32, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), @@ -65,11 +63,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = widened.begin(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&__tmp_1), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_1), ) { object_unsafe!(__value, i64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), @@ -99,11 +95,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_4 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = constructed.begin(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&__tmp_4), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_4), ) { object_unsafe!(__value, Degrees, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), @@ -125,11 +119,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { wide.as_mut_ptr().offset((2) as isize) }; let mut __first = wide.as_mut_ptr(); let mut __out = floating.begin(); - while ConvertibleToUnsafe::::convert_value( - <*mut i64 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__first), - LvalueRefUnsafe::>::bind(&__tmp_5), - ), + while <*mut i64 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_5), ) { object_unsafe!(__value, f64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), diff --git a/tests/unit/out/unsafe/stdcopy_ostream.rs b/tests/unit/out/unsafe/stdcopy_ostream.rs index a7d80bdf16..1c1e155d91 100644 --- a/tests/unit/out/unsafe/stdcopy_ostream.rs +++ b/tests/unit/out/unsafe/stdcopy_ostream.rs @@ -37,15 +37,7 @@ unsafe fn main_0() -> i32 { let mut __it = (__tmp_0).clone(); let __out = &mut ofs; let mut __bytes: Vec = Vec::new(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_1), - )) { - __bytes.push(*__it.iter_deref() as u8); - __it.iter_inc(); - } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ) { __bytes.push(*__it.iter_deref() as u8); __it.iter_inc(); } __out.write_all(&__bytes); __out.try_clone().unwrap() }; diff --git a/tests/unit/out/unsafe/stdmin_fpoint.rs b/tests/unit/out/unsafe/stdmin_fpoint.rs index f92209e4eb..1be411d216 100644 --- a/tests/unit/out/unsafe/stdmin_fpoint.rs +++ b/tests/unit/out/unsafe/stdmin_fpoint.rs @@ -18,10 +18,10 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut a0; let __b: *const _ = &mut a1; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index 3aa499a652..4713d31ee4 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -55,16 +55,12 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) let mut __tmp_0 = { items.begin() }; let mut __tmp_1 = { items.end() }; let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value(>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), )) { __it.iter_inc(); } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), ) { __it.iter_inc(); } __it }; - assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind( - &items.end() - ), - ) + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&items.end()), )); (*code.offset((i) as isize)) = ((it.iter_distance(&items.begin())) as u32); { @@ -84,11 +80,9 @@ pub unsafe fn sum_4(v: *mut Vec) -> i32 { let mut s: i32 = 0; { let mut it: UnsafeRandomAccessIterator = (*v).begin(); - 'loop_: while ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&it), - LvalueRefUnsafe::>>::bind(&(*v).end()), - ), + 'loop_: while WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&(*v).end()), ) { 'for_body: { s += (*it.iter_deref()); diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 9c68116c95..4ea2334302 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -170,10 +170,10 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut high; let __b: *const _ = &mut __tmp_0; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), - )) { + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index 1c524792fa..8642aa9237 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -191,11 +191,9 @@ unsafe fn main_0() -> i32 { __tmp_7.iter_distance(&UnsafeRandomAccessIterator::Vec(v2.as_mut_ptr())) as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_8).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_9), - ), + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_9), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -524,11 +522,9 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_20), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_20), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -554,19 +550,7 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_22).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_23), - ), - ) { - __tmp.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __tmp.as_mut_ptr().add(__tmp.len() - 1), - (LvalueRefUnsafe::>::bind(__it.iter_deref()),), - ); - __it.iter_inc(); - } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_23 ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } longs.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(longs.as_mut_ptr().add(__off)) }; @@ -580,11 +564,9 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_25), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_25), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -606,11 +588,9 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_27), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_27), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -632,19 +612,7 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_29).clone(); - while ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>>::bind(&__it), - LvalueRefUnsafe::>>::bind(&__tmp_30), - ), - ) { - __tmp.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __tmp.as_mut_ptr().add(__tmp.len() - 1), - (LvalueRefUnsafe::>::bind(__it.iter_deref()),), - ); - __it.iter_inc(); - } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_30 ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } same.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(same.as_mut_ptr().add(__off)) }; diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 5d573b0e70..ffd6666ee2 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -53,9 +53,21 @@ impl Reading { impl Cpp17EqualityComparableUnsafe for Reading { type EqualResult = bool; unsafe fn equal( + __return: *mut Self::EqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + == (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -65,9 +77,21 @@ impl Cpp17EqualityComparableUnsafe for Reading { impl WeaklyEqualityComparableWithUnsafe for Reading { type NotEqualResult = bool; unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + != (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_not_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::NotEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -77,9 +101,21 @@ impl WeaklyEqualityComparableWithUnsafe for Reading { impl LessThanComparableUnsafe for Reading { type Result = bool; unsafe fn less( + __return: *mut Self::Result, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::Result { + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -89,9 +125,21 @@ impl LessThanComparableUnsafe for Reading { impl PartiallyOrderedWithUnsafe for Reading { type LessResult = bool; unsafe fn less( + __return: *mut Self::LessResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -99,9 +147,21 @@ impl PartiallyOrderedWithUnsafe for Reading { } type GreaterResult = bool; unsafe fn greater( + __return: *mut Self::GreaterResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + > (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -109,9 +169,21 @@ impl PartiallyOrderedWithUnsafe for Reading { } type LessEqualResult = bool; unsafe fn less_equal( + __return: *mut Self::LessEqualResult, __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::LessEqualResult { + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + <= (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -119,9 +191,21 @@ impl PartiallyOrderedWithUnsafe for Reading { } type GreaterEqualResult = bool; unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const Reading); + let __rhs = (__rhs.as_ptr() as *const Reading); + __return.write( + ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) + >= (unsafe { Reading::to_i64(&raw const (*__rhs)) })), + ); + } + unsafe fn is_greater_equal( __lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>, - ) -> Self::GreaterEqualResult { + ) -> bool { let __lhs = (__lhs.as_ptr() as *const Reading); let __rhs = (__rhs.as_ptr() as *const Reading); return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) @@ -140,11 +224,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_0), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_0), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -164,11 +246,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_1), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -188,11 +268,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_2), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_2), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -210,11 +288,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*const u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_3), - ), + while <*const u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -243,11 +319,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while ConvertibleToUnsafe::::convert_value( - <*const u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_5), - ), + while <*const u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_5), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -287,7 +361,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_10 = { m.end() }; let mut __v: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } __v }; assert!(((v6.len()) == (3_usize))); @@ -302,7 +376,7 @@ unsafe fn main_0() -> i32 { __tmp_11.iter_distance(&UnsafeRandomAccessIterator::Vec(v6.as_mut_ptr())) as usize; let mut __tmp: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_12).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_13 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_13 ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } v6.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(v6.as_mut_ptr().add(__off)) }; @@ -315,11 +389,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_14 = { ints.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_14), - ), + while <*mut i32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_14), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -336,11 +408,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_15 = { readings.as_mut_ptr().offset((2) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = readings.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut Reading as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_15), - ), + while <*mut Reading as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_15), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index a5c6aa3237..af35e8f0bc 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -321,11 +321,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_16 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_16), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_16), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -345,11 +343,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_17 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_17), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_17), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -369,11 +365,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_18 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_18), - ), + while <*mut u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_18), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -391,11 +385,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_19 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while ConvertibleToUnsafe::::convert_value( - <*const u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_19), - ), + while <*const u32 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_19), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( @@ -418,11 +410,9 @@ unsafe fn main_0() -> i32 { let mut __tmp_20 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while ConvertibleToUnsafe::::convert_value( - <*const u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( - LvalueRefUnsafe::>::bind(&__it), - LvalueRefUnsafe::>::bind(&__tmp_20), - ), + while <*const u8 as WeaklyEqualityComparableWithUnsafe>::is_not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_20), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( diff --git a/tests/unit/out/unsafe/void_return.rs b/tests/unit/out/unsafe/void_return.rs index 4d45939ff1..def230c35e 100644 --- a/tests/unit/out/unsafe/void_return.rs +++ b/tests/unit/out/unsafe/void_return.rs @@ -17,16 +17,14 @@ pub unsafe fn f1_0( __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const i32; let __b = __tmp_0.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { @@ -50,16 +48,14 @@ pub unsafe fn f1_1(mut first: *mut i32, mut last: *mut i32) { __order.sort_by(|&__x, &__y| { let __a = first.iter_at(__x) as *const i32; let __b = first.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), - )) { + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value( - ::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - ), + } else if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { From 6052726a386e1dfc1fbb8dafff834d4110e022cb Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 23:01:20 +0000 Subject: [PATCH 14/17] Update tests --- .../out/refcount/utility.arg.requirements.rs | 1276 ++++++++++++++++- .../out/unsafe/utility.arg.requirements.rs | 1153 ++++++++++++++- .../utility.arg.requirements.cpp | 85 ++ 3 files changed, 2414 insertions(+), 100 deletions(-) diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 1cc7ed0c44..b909e5573b 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -6,8 +6,496 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[byte_size(4)] +pub struct table28_equal_operator_Ticket { + #[offset(0)] + pub number: i32, +} +impl table28_equal_operator_Ticket { + pub fn operator_eq(this: Ptr, other: Ptr) -> bool { + return ({ this.with(|__s| __s.number) } == { other.with(|__s| __s.number) }); + } +} +impl Cpp17EqualityComparable for table28_equal_operator_Ticket { + type EqualResult = bool; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for table28_equal_operator_Ticket { + type NotEqualResult = bool; + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} +pub fn test_0() { + let tickets: Value> = Rc::new(RefCell::new(Vec::from([ + table28_equal_operator_Ticket { number: 4 }, + table28_equal_operator_Ticket { number: 4 }, + table28_equal_operator_Ticket { number: 7 }, + table28_equal_operator_Ticket { number: 9 }, + table28_equal_operator_Ticket { number: 9 }, + ]))); + assert!(( ({ let __tmp_0 : Value = Rc::new(RefCell::new(table28_equal_operator_Ticket { number : 7 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_0.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . number ) == 7 ) ); + assert!(match (Rc::new(RefCell::new(({ let __tmp_2 : Value = Rc::new(RefCell::new(table28_equal_operator_Ticket { number : 5 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_2.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(tickets .decay() .end() )).as_pointer(),) { (__tmp_1, __tmp_3,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_1 ).clone()), LvalueRef:: >>::bind((__tmp_3 ).clone()), ) } } ); + let last: Value> = Rc::new(RefCell::new({ + let __it: Value> = + Rc::new(RefCell::new(tickets.decay().begin())); + let __last: Value> = + Rc::new(RefCell::new(tickets.decay().end())); + if as Cpp17EqualityComparable>::is_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { __last.borrow().clone() } else { let mut __write = __it.borrow().clone(); __it.borrow_mut().iter_inc(); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { if !::is_equal( LvalueRef::>::bind(__write.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), ) { __write.iter_inc(); __write.iter_deref().write(__it.borrow().iter_deref().read()); } __it.borrow_mut().iter_inc(); } __write.iter_inc(); __write } + })); + assert!(((*last.borrow()).iter_distance(&tickets.decay().begin()) == 3_isize)); + assert!( + ({ { (*tickets.borrow())[1_usize] }.number } == 7) + && ({ { (*tickets.borrow())[2_usize] }.number } == 9) + ); +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[conversion_function(to_bool, LvalueRef>, bool )] +#[byte_size(1)] +pub struct table28_result_convertible_to_bool_Truth { + #[offset(0)] + pub value: bool, +} +impl table28_result_convertible_to_bool_Truth { + pub fn to_bool(this: Ptr) -> bool { + return this.with(|__s| __s.value); + } +} +impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Truth { + type EqualResult = bool; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + == { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } == { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl WeaklyEqualityComparableWith for table28_result_convertible_to_bool_Truth { + type NotEqualResult = bool; + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + != { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } != { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl LessThanComparable for table28_result_convertible_to_bool_Truth { + type Result = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + < { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } < { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl PartiallyOrderedWith for table28_result_convertible_to_bool_Truth { + type LessResult = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + < { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } < { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterResult = bool; + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + > { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } > { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type LessEqualResult = bool; + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + <= { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } <= { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + >= { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } >= { + (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl ThreeWayComparable for table28_result_convertible_to_bool_Truth { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), + &(({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), + )); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[byte_size(4)] +pub struct table28_result_convertible_to_bool_Ticket { + #[offset(0)] + pub number: i32, +} +impl table28_result_convertible_to_bool_Ticket { + pub fn operator_eq( + this: Ptr, + other: Ptr, + ) -> table28_result_convertible_to_bool_Truth { + return table28_result_convertible_to_bool_Truth { + value: ({ this.with(|__s| __s.number) } == { other.with(|__s| __s.number) }), + }; + } +} +impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Ticket { + type EqualResult = table28_result_convertible_to_bool_Truth; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + table28_result_convertible_to_bool_Ticket::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table28_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table28_result_convertible_to_bool_Ticket::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), + ) + }); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[byte_size(4)] +pub struct table28_result_convertible_to_bool_Badge { + #[offset(0)] + pub id: i32, +} +impl table28_result_convertible_to_bool_Badge { + pub fn operator_eq( + this: Ptr, + other: Ptr, + ) -> table28_result_convertible_to_bool_Truth { + return table28_result_convertible_to_bool_Truth { + value: ({ this.with(|__s| __s.id) } == { (other.read()) }), + }; + } +} +impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Badge { + type EqualResult = table28_result_convertible_to_bool_Truth; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + table28_result_convertible_to_bool_Badge::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table28_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table28_result_convertible_to_bool_Badge::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), + ) + }); + } +} +pub fn test_1() { + let tickets: Value> = + Rc::new(RefCell::new(Vec::from([ + table28_result_convertible_to_bool_Ticket { number: 4 }, + table28_result_convertible_to_bool_Ticket { number: 7 }, + table28_result_convertible_to_bool_Ticket { number: 9 }, + ]))); + assert!(( ({ let __tmp_4 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 9 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_4.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . number ) == 9 ) ); + assert!(match (Rc::new(RefCell::new(({ let __tmp_6 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 5 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_6.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(tickets .decay() .end() )).as_pointer(),) { (__tmp_5, __tmp_7,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_5 ).clone()), LvalueRef:: >>::bind((__tmp_7 ).clone()), ) } } ); + let badges: Value> = + Rc::new(RefCell::new(Vec::from([ + table28_result_convertible_to_bool_Badge { id: 1 }, + table28_result_convertible_to_bool_Badge { id: 2 }, + table28_result_convertible_to_bool_Badge { id: 3 }, + ]))); + assert!(( ({ let __tmp_8 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_8.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . id ) == 2 ) ); + assert!(match (Rc::new(RefCell::new(({ let __tmp_10 : Value = Rc::new(RefCell::new(8 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_10.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(badges .decay() .end() )).as_pointer(),) { (__tmp_9, __tmp_11,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_9 ).clone()), LvalueRef:: >>::bind((__tmp_11 ).clone()), ) } } ); +} thread_local!( - pub static less_calls_0: Value = Rc::new(RefCell::new(0)); + pub static less_calls_2: Value = Rc::new(RefCell::new(0)); ); #[derive( Copy, @@ -32,7 +520,7 @@ pub struct table29_member_operator_Version { } impl table29_member_operator_Version { pub fn operator_lt(this: Ptr, other: Ptr) -> bool { - (*less_calls_0.with(Value::clone).borrow_mut()).prefix_inc(); + (*less_calls_2.with(Value::clone).borrow_mut()).prefix_inc(); return ({ this.with(|__s| __s.major) } < { other.with(|__s| __s.major) }) || (({ this.with(|__s| __s.major) } == { other.with(|__s| __s.major) }) && ({ this.with(|__s| __s.minor) } < { other.with(|__s| __s.minor) })); @@ -62,7 +550,7 @@ impl LessThanComparable for table29_member_operator_Version { }); } } -pub fn test_1() { +pub fn test_3() { let old_version: Value = Rc::new(RefCell::new(table29_member_operator_Version { major: 1, @@ -105,18 +593,18 @@ pub fn test_1() { .with(|__s| __s.major) == 1) ); - assert!((less_calls_0.with(|rc| *rc.borrow()) == 2)); + assert!((less_calls_2.with(|rc| *rc.borrow()) == 2)); let versions: Value> = Rc::new(RefCell::new(Vec::from([ table29_member_operator_Version { major: 2, minor: 1 }, table29_member_operator_Version { major: 1, minor: 9 }, table29_member_operator_Version { major: 2, minor: 0 }, ]))); { - let mut __tmp_0 = { versions.decay().begin() }; - let __n = versions.decay().end().iter_distance(&__tmp_0); + let mut __tmp_12 = { versions.decay().begin() }; + let __n = versions.decay().end().iter_distance(&__tmp_12); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_0.iter_at(__x), &__tmp_0.iter_at(__y))); - reorder(__order, |__i| __tmp_0.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_12.iter_at(__x), &__tmp_12.iter_at(__y))); + reorder(__order, |__i| __tmp_12.iter_at(__i)); }; assert!( ({ { (*versions.borrow())[0_usize] }.major } == 1) @@ -135,16 +623,16 @@ pub fn test_1() { Map, Value)>, > = Rc::new(RefCell::new(Map::new())); match (new_version.as_pointer(),) { - (__tmp_1,) => ({ (*downloads.borrow_mut()).subscript(__tmp_1, || 0_i32) }), + (__tmp_13,) => ({ (*downloads.borrow_mut()).subscript(__tmp_13, || 0_i32) }), } .write(7); match (old_version.as_pointer(),) { - (__tmp_2,) => ({ (*downloads.borrow_mut()).subscript(__tmp_2, || 0_i32) }), + (__tmp_14,) => ({ (*downloads.borrow_mut()).subscript(__tmp_14, || 0_i32) }), } .write(3); { match (new_version.as_pointer(),) { - (__tmp_3,) => ({ (*downloads.borrow_mut()).subscript(__tmp_3, || 0_i32) }), + (__tmp_15,) => ({ (*downloads.borrow_mut()).subscript(__tmp_15, || 0_i32) }), } .with_mut(|__v| *__v = *__v + 1) }; @@ -167,8 +655,8 @@ pub fn test_1() { ); assert!( ((match (new_version.as_pointer(),) { - (__tmp_4,) => { - ({ (*downloads.borrow_mut()).subscript(__tmp_4, || 0_i32) }) + (__tmp_16,) => { + ({ (*downloads.borrow_mut()).subscript(__tmp_16, || 0_i32) }) } } .read()) @@ -257,7 +745,7 @@ impl LessThanComparable for table29_other_operator_shapes_Height { ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); + __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); } fn is_less( __lhs: LvalueRef>, @@ -265,10 +753,10 @@ impl LessThanComparable for table29_other_operator_shapes_Height { ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); - return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); + return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); } } -pub fn operator_lt_2( +pub fn operator_lt_4( lhs: Ptr, rhs: Ptr, ) -> bool { @@ -304,216 +792,861 @@ impl table29_other_operator_shapes_Depth { )); } } -impl LessThanComparable for table29_other_operator_shapes_Depth { +impl LessThanComparable for table29_other_operator_shapes_Depth { + type Result = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} +impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { + type LessResult = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterResult = bool; + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type LessEqualResult = bool; + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } + type GreaterEqualResult = bool; + fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write(libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + )); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[byte_size(4)] +pub struct table29_other_operator_shapes_Length { + #[offset(0)] + pub meters: i32, +} +impl table29_other_operator_shapes_Length { + pub fn operator_cmp( + this: Ptr, + _a0: Ptr, + ) -> libcc2rs::StrongOrdering { + { + let cmp: Value = Rc::new(RefCell::new( + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(this.with(|__s| __s.meters)), + &(_a0.with(|__s| __s.meters)), + )), + )); + if !(libcc2rs::is_eq(({ (*cmp.borrow()) }))) { + return (*cmp.borrow_mut()); + } + } + return (*libcc2rs::strong_ordering_equal().upgrade().deref()); + } + pub fn operator_eq(this: Ptr, _a0: Ptr) -> bool { + return ({ this.with(|__s| __s.meters) } == { _a0.with(|__s| __s.meters) }); + } +} +impl Cpp17EqualityComparable for table29_other_operator_shapes_Length { + type EqualResult = bool; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl WeaklyEqualityComparableWith for table29_other_operator_shapes_Length { + type NotEqualResult = bool; + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + !({ + table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return !({ + table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) + }); + } +} +impl LessThanComparable for table29_other_operator_shapes_Length { type Result = bool; fn less( __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); __return.write(libcc2rs::is_lt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), )); } fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), ); } } -impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { +impl PartiallyOrderedWith for table29_other_operator_shapes_Length { type LessResult = bool; fn less( __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); __return.write(libcc2rs::is_lt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), )); } fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), ); } type GreaterResult = bool; fn greater( __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); __return.write(libcc2rs::is_gt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), )); } fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gt( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), ); } type LessEqualResult = bool; fn less_equal( __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); __return.write(libcc2rs::is_lteq( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), )); } fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_lteq( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), ); } type GreaterEqualResult = bool; fn greater_equal( __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); __return.write(libcc2rs::is_gteq( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), )); } fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, + __lhs: LvalueRef>, + __rhs: LvalueRef>, ) -> bool { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return libcc2rs::is_gteq( ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) }), ); } } -pub fn test_3() { +impl ThreeWayComparable for table29_other_operator_shapes_Length { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) + }); + } +} +pub fn test_5() { assert!( ({ - let __tmp_5: Value = + let __tmp_17: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 3, })); - let __tmp_6: Value = + let __tmp_18: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 5, })); if ::is_less( LvalueRef::>::bind( - (__tmp_5.as_pointer()).clone(), + (__tmp_17.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_6.as_pointer()).clone(), + (__tmp_18.as_pointer()).clone(), ), ) { - (__tmp_6.as_pointer()) + (__tmp_18.as_pointer()) } else { - (__tmp_5.as_pointer()) + (__tmp_17.as_pointer()) } .with(|__s| __s.grams) } == 5) ); assert!( ({ - let __tmp_7: Value = + let __tmp_19: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 50, })); - let __tmp_8: Value = + let __tmp_20: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 30, })); if ::is_less( LvalueRef::>::bind( - (__tmp_7.as_pointer()).clone(), + (__tmp_19.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_8.as_pointer()).clone(), + (__tmp_20.as_pointer()).clone(), ), ) { - (__tmp_7.as_pointer()) + (__tmp_19.as_pointer()) } else { - (__tmp_8.as_pointer()) + (__tmp_20.as_pointer()) } .with(|__s| __s.millimeters) } == 30) ); assert!( ({ - let __tmp_9: Value = + let __tmp_21: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 7, })); - let __tmp_10: Value = + let __tmp_22: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 4, })); if ::is_less( LvalueRef::>::bind( - (__tmp_9.as_pointer()).clone(), + (__tmp_21.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_10.as_pointer()).clone(), + (__tmp_22.as_pointer()).clone(), ), ) { - (__tmp_10.as_pointer()) + (__tmp_22.as_pointer()) } else { - (__tmp_9.as_pointer()) + (__tmp_21.as_pointer()) } .with(|__s| __s.millimeters) } == 7) ); + assert!( + ({ + let __tmp_23: Value = + Rc::new(RefCell::new(table29_other_operator_shapes_Length { + meters: 9, + })); + let __tmp_24: Value = + Rc::new(RefCell::new(table29_other_operator_shapes_Length { + meters: 2, + })); + if ::is_less( + LvalueRef::>::bind( + (__tmp_23.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_24.as_pointer()).clone(), + ), + ) { + (__tmp_23.as_pointer()) + } else { + (__tmp_24.as_pointer()) + } + .with(|__s| __s.meters) + } == 2) + ); +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[conversion_function(to_bool, LvalueRef>, bool )] +#[byte_size(1)] +pub struct table29_result_convertible_to_bool_Truth { + #[offset(0)] + pub value: bool, +} +impl table29_result_convertible_to_bool_Truth { + pub fn to_bool(this: Ptr) -> bool { + return this.with(|__s| __s.value); + } +} +impl Cpp17EqualityComparable for table29_result_convertible_to_bool_Truth { + type EqualResult = bool; + fn equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + == { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } == { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl WeaklyEqualityComparableWith for table29_result_convertible_to_bool_Truth { + type NotEqualResult = bool; + fn not_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + != { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_not_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } != { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl LessThanComparable for table29_result_convertible_to_bool_Truth { + type Result = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + < { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } < { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl PartiallyOrderedWith for table29_result_convertible_to_bool_Truth { + type LessResult = bool; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + < { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } < { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterResult = bool; + fn greater( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + > { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_greater( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } > { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type LessEqualResult = bool; + fn less_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + <= { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_less_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } <= { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } + type GreaterEqualResult = bool; + fn greater_equal( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } + >= { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) + as i32) + }), + ); + } + fn is_greater_equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) + } >= { + (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) + }); + } +} +impl ThreeWayComparable for table29_result_convertible_to_bool_Truth { + type Category = libcc2rs::StrongOrdering; + fn three_way( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::Category { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), + &(({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), + )); + } +} +#[derive( + Copy, + Clone, + Record, + ByteRepr, + ZeroInitialization, + VaArg, + FnPtrArg, + TriviallyDefaultConstructible, + TriviallyCopyable, + Default, + Conversions, +)] +#[conversions(copy, move)] +#[byte_size(4)] +pub struct table29_result_convertible_to_bool_Priority { + #[offset(0)] + pub level: i32, +} +impl table29_result_convertible_to_bool_Priority { + pub fn operator_lt( + this: Ptr, + other: Ptr, + ) -> table29_result_convertible_to_bool_Truth { + return table29_result_convertible_to_bool_Truth { + value: ({ this.with(|__s| __s.level) } < { other.with(|__s| __s.level) }), + }; + } +} +impl LessThanComparable for table29_result_convertible_to_bool_Priority { + type Result = table29_result_convertible_to_bool_Truth; + fn less( + __return: Ptr, + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + __return.write( + ({ + table29_result_convertible_to_bool_Priority::operator_lt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + } + fn is_less( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> bool { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ + table29_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table29_result_convertible_to_bool_Priority::operator_lt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), + ) + }); + } +} +pub fn test_6() { + assert!( + ({ + let __tmp_25: Value = + Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { + level: 2, + })); + let __tmp_26: Value = + Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { + level: 6, + })); + if ::is_less( + LvalueRef::>::bind( + (__tmp_25.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_26.as_pointer()).clone(), + ), + ) { + (__tmp_26.as_pointer()) + } else { + (__tmp_25.as_pointer()) + } + .with(|__s| __s.level) + } == 6) + ); + assert!( + ({ + let __tmp_27: Value = + Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { + level: 6, + })); + let __tmp_28: Value = + Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { + level: 2, + })); + if ::is_less( + LvalueRef::>::bind( + (__tmp_27.as_pointer()).clone(), + ), + LvalueRef::>::bind( + (__tmp_28.as_pointer()).clone(), + ), + ) { + (__tmp_27.as_pointer()) + } else { + (__tmp_28.as_pointer()) + } + .with(|__s| __s.level) + } == 2) + ); + let priorities: Value> = + Rc::new(RefCell::new(Vec::from([ + table29_result_convertible_to_bool_Priority { level: 5 }, + table29_result_convertible_to_bool_Priority { level: 1 }, + table29_result_convertible_to_bool_Priority { level: 3 }, + ]))); + { + let mut __tmp_29 = { priorities.decay().begin() }; + let __n = priorities.decay().end().iter_distance(&__tmp_29); + let mut __order: Vec = (0..__n).collect(); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_29.iter_at(__x), &__tmp_29.iter_at(__y))); + reorder(__order, |__i| __tmp_29.iter_at(__i)); + }; + assert!(({ { (*priorities.borrow())[0_usize] }.level } == 1)); + assert!(({ { (*priorities.borrow())[1_usize] }.level } == 3)); + assert!(({ { (*priorities.borrow())[2_usize] }.level } == 5)); + assert!(( {let __it: Value > = Rc::new(RefCell::new(priorities .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(priorities .decay() .end() )); let mut __best = __it.borrow().clone(); if as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { __it.borrow_mut().iter_inc(); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { if ::is_less( LvalueRef::>::bind(__best.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), ) { __best = __it.borrow().clone(); } __it.borrow_mut().iter_inc(); } } __best} .iter_deref() .with(|__s| __s . level ) == 5 ) ); } #[derive( Copy, @@ -571,7 +1704,7 @@ impl LessThanComparable for pairs_spec_p3_members_order_pairs_Rank { }); } } -pub fn test_4() { +pub fn test_7() { let low: Value<(Value, Value)> = Rc::new(RefCell::new(( Rc::new(RefCell::new( @@ -610,11 +1743,14 @@ pub fn main() { libcc2rs::cpp2rust_exit(main_0()); } fn main_0() -> i32 { + ({ test_0() }); ({ test_1() }); ({ test_3() }); - ({ test_4() }); + ({ test_5() }); + ({ test_6() }); + ({ test_7() }); return 0; } pub fn __cpp2rust_init_globals() { - let _ = less_calls_0.with(|_| ()); + let _ = less_calls_2.with(|_| ()); } diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index 7d4b429147..56ee74bce1 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -6,7 +6,503 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub static mut less_calls_0: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +pub struct table28_equal_operator_Ticket { + pub number: i32, +} +impl table28_equal_operator_Ticket { + pub unsafe fn operator_eq( + this: *const Self, + other: *const table28_equal_operator_Ticket, + ) -> bool { + return (((*this).number) == ((*other).number)); + } +} +impl Cpp17EqualityComparableUnsafe for table28_equal_operator_Ticket { + type EqualResult = bool; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); + __return.write( + (unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); + return (unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for table28_equal_operator_Ticket { + type NotEqualResult = bool; + unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); + __return.write( + !(unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); + return !(unsafe { + table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +pub unsafe fn test_0() { + let mut tickets: Vec = Vec::from([ + table28_equal_operator_Ticket { number: 4 }, + table28_equal_operator_Ticket { number: 4 }, + table28_equal_operator_Ticket { number: 7 }, + table28_equal_operator_Ticket { number: 9 }, + table28_equal_operator_Ticket { number: 9 }, + ]); + assert!(( ( ( * { let mut __tmp_0 = { tickets .begin() };let mut __tmp_1 = { tickets .end() }; let mut __it = (__tmp_0 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(table28_equal_operator_Ticket { number : 7 , } )), ) { __it.iter_inc(); } __it } .iter_deref() ) . number ) == ( 7 ) ) ); + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind( + &{ + let mut __tmp_2 = { tickets.begin() }; + let mut __tmp_3 = { tickets.end() }; + let mut __it = (__tmp_2).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(table28_equal_operator_Ticket { number : 5 , } )), ) { __it.iter_inc(); } + __it + } + ), + LvalueRefUnsafe::>>::bind( + &tickets.end() + ), + )); + let mut last: UnsafeRandomAccessIterator = { + let mut __tmp_4 = { tickets.begin() }; + let mut __tmp_5 = { tickets.end() }; + if as Cpp17EqualityComparableUnsafe>::is_equal( LvalueRefUnsafe:: >>::bind(&__tmp_4 ), LvalueRefUnsafe:: >>::bind(&__tmp_5 ), ) { (__tmp_5 ).clone() } else { let mut __write = __tmp_4 .clone(); let mut __it = (__tmp_4 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_5 ), ) { if !::is_equal( LvalueRefUnsafe::>::bind(__write.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __write.iter_inc(); *__write.iter_deref() = (*__it.iter_deref()).clone(); } __it.iter_inc(); } __write.iter_inc(); __write } + }; + assert!(((last.iter_distance(&tickets.begin())) == (3_isize))); + assert!(((tickets[(1_usize)].number) == (7)) && ((tickets[(2_usize)].number) == (9))); +} +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +#[conversion_function(to_bool, LvalueRefUnsafe>, bool )] +pub struct table28_result_convertible_to_bool_Truth { + pub value: bool, +} +impl table28_result_convertible_to_bool_Truth { + pub unsafe fn to_bool(this: *const Self) -> bool { + return (*this).value; + } +} +impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Truth { + type EqualResult = bool; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + == ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + == ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl WeaklyEqualityComparableWithUnsafe for table28_result_convertible_to_bool_Truth { + type NotEqualResult = bool; + unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + != ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + != ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl LessThanComparableUnsafe for table28_result_convertible_to_bool_Truth { + type Result = bool; + unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl PartiallyOrderedWithUnsafe for table28_result_convertible_to_bool_Truth { + type LessResult = bool; + unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type GreaterResult = bool; + unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + > ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + > ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + <= ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + <= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + >= ((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + >= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl ThreeWayComparableUnsafe for table28_result_convertible_to_bool_Truth { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32), + &((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32), + )); + } +} +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +pub struct table28_result_convertible_to_bool_Ticket { + pub number: i32, +} +impl table28_result_convertible_to_bool_Ticket { + pub unsafe fn operator_eq( + this: *const Self, + other: *const table28_result_convertible_to_bool_Ticket, + ) -> table28_result_convertible_to_bool_Truth { + return table28_result_convertible_to_bool_Truth { + value: (((*this).number) == ((*other).number)), + }; + } +} +impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Ticket { + type EqualResult = table28_result_convertible_to_bool_Truth; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); + __return.write( + (unsafe { + table28_result_convertible_to_bool_Ticket::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); + let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); + return (unsafe { + table28_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table28_result_convertible_to_bool_Ticket::operator_eq( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }); + } +} +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +pub struct table28_result_convertible_to_bool_Badge { + pub id: i32, +} +impl table28_result_convertible_to_bool_Badge { + pub unsafe fn operator_eq( + this: *const Self, + other: *const i32, + ) -> table28_result_convertible_to_bool_Truth { + return table28_result_convertible_to_bool_Truth { + value: (((*this).id) == (*other)), + }; + } +} +impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Badge { + type EqualResult = table28_result_convertible_to_bool_Truth; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Badge); + let __rhs = (__rhs.as_ptr() as *const i32); + __return.write( + (unsafe { + table28_result_convertible_to_bool_Badge::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Badge); + let __rhs = (__rhs.as_ptr() as *const i32); + return (unsafe { + table28_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table28_result_convertible_to_bool_Badge::operator_eq( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }); + } +} +pub unsafe fn test_1() { + let mut tickets: Vec = Vec::from([ + table28_result_convertible_to_bool_Ticket { number: 4 }, + table28_result_convertible_to_bool_Ticket { number: 7 }, + table28_result_convertible_to_bool_Ticket { number: 9 }, + ]); + assert!(( ( ( * { let mut __tmp_6 = { tickets .begin() };let mut __tmp_7 = { tickets .end() }; let mut __it = (__tmp_6 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_7 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(table28_result_convertible_to_bool_Ticket { number : 9 , } )), ) { __it.iter_inc(); } __it } .iter_deref() ) . number ) == ( 9 ) ) ); + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::< + Const>, + >::bind(&{ + let mut __tmp_8 = { tickets.begin() }; + let mut __tmp_9 = { tickets.end() }; + let mut __it = (__tmp_8).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_9 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(table28_result_convertible_to_bool_Ticket { number : 5 , } )), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::< + Const>, + >::bind(&tickets.end()), + )); + let mut badges: Vec = Vec::from([ + table28_result_convertible_to_bool_Badge { id: 1 }, + table28_result_convertible_to_bool_Badge { id: 2 }, + table28_result_convertible_to_bool_Badge { id: 3 }, + ]); + assert!(( ( ( * { let mut __tmp_10 = { badges .begin() };let mut __tmp_11 = { badges .end() }; let mut __it = (__tmp_10 ).clone(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_11 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2 ), ) { __it.iter_inc(); } __it } .iter_deref() ) . id ) == ( 2 ) ) ); + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::< + Const>, + >::bind(&{ + let mut __tmp_12 = { badges.begin() }; + let mut __tmp_13 = { badges.end() }; + let mut __it = (__tmp_12).clone(); + while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_13 ), ) && !>::is_equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&8 ), ) { __it.iter_inc(); } + __it + }), + LvalueRefUnsafe::< + Const>, + >::bind(&badges.end()), + )); +} +pub static mut less_calls_2: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { 0 }); #[repr(C)] #[derive( Copy, @@ -29,7 +525,7 @@ impl table29_member_operator_Version { this: *const Self, other: *const table29_member_operator_Version, ) -> bool { - (*std::cell::LazyCell::force_mut(&mut *&raw mut less_calls_0)).prefix_inc(); + (*std::cell::LazyCell::force_mut(&mut *&raw mut less_calls_2)).prefix_inc(); return (((*this).major) < ((*other).major)) || ((((*this).major) == ((*other).major)) && (((*this).minor) < ((*other).minor))); } @@ -58,7 +554,7 @@ impl LessThanComparableUnsafe for table29_member_operator_Version { }); } } -pub unsafe fn test_1() { +pub unsafe fn test_3() { let mut old_version: table29_member_operator_Version = table29_member_operator_Version { major: 1, minor: 4 }; let mut new_version: table29_member_operator_Version = @@ -95,19 +591,19 @@ pub unsafe fn test_1() { .major) == (1)) ); - assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut less_calls_0)) == (2))); + assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut less_calls_2)) == (2))); let mut versions: Vec = Vec::from([ table29_member_operator_Version { major: 2, minor: 1 }, table29_member_operator_Version { major: 1, minor: 9 }, table29_member_operator_Version { major: 2, minor: 0 }, ]); { - let mut __tmp_0 = { versions.begin() }; - let __n = versions.end().iter_distance(&__tmp_0); + let mut __tmp_14 = { versions.begin() }; + let __n = versions.end().iter_distance(&__tmp_14); let mut __order: Vec = (0..__n).collect(); __order.sort_by(|&__x, &__y| { - let __a = __tmp_0.iter_at(__x) as *const table29_member_operator_Version; - let __b = __tmp_0.iter_at(__y) as *const table29_member_operator_Version; + let __a = __tmp_14.iter_at(__x) as *const table29_member_operator_Version; + let __b = __tmp_14.iter_at(__y) as *const table29_member_operator_Version; if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), @@ -124,16 +620,16 @@ pub unsafe fn test_1() { }); let __values: Vec<_> = __order .iter() - .map(|&__i| std::ptr::read(__tmp_0.iter_at(__i))) + .map(|&__i| std::ptr::read(__tmp_14.iter_at(__i))) .collect(); for (__i, __v) in (0..__n).zip(__values) { - std::ptr::write(__tmp_0.iter_at(__i), __v); + std::ptr::write(__tmp_14.iter_at(__i), __v); } }; assert!(((versions[(0_usize)].major) == (1)) && ((versions[(0_usize)].minor) == (9))); assert!(((versions[(1_usize)].major) == (2)) && ((versions[(1_usize)].minor) == (0))); assert!(((versions[(2_usize)].major) == (2)) && ((versions[(2_usize)].minor) == (1))); - assert!(( ( ( * { let mut __tmp_1 = { versions .begin() };let mut __tmp_2 = { versions .end() }; let mut __best = __tmp_1 .clone(); if as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_1 ), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ) { let mut __it = (__tmp_1 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_2 ), ) { if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . minor ) == ( 1 ) ) ); + assert!(( ( ( * { let mut __tmp_15 = { versions .begin() };let mut __tmp_16 = { versions .end() }; let mut __best = __tmp_15 .clone(); if as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_15 ), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ) { let mut __it = (__tmp_15 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_16 ), ) { if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . minor ) == ( 1 ) ) ); let mut downloads: UnsafeMap< table29_member_operator_Version, (table29_member_operator_Version, i32), @@ -223,7 +719,7 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { __return.write( (unsafe { let _lhs: *const table29_other_operator_shapes_Height = __lhs; - operator_lt_2(_lhs, __rhs) + operator_lt_4(_lhs, __rhs) }), ); } @@ -235,11 +731,11 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); return (unsafe { let _lhs: *const table29_other_operator_shapes_Height = __lhs; - operator_lt_2(_lhs, __rhs) + operator_lt_4(_lhs, __rhs) }); } } -pub unsafe fn operator_lt_2( +pub unsafe fn operator_lt_4( lhs: *const table29_other_operator_shapes_Height, rhs: *const table29_other_operator_shapes_Height, ) -> bool { @@ -406,16 +902,253 @@ impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { ); } } -pub unsafe fn test_3() { +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +pub struct table29_other_operator_shapes_Length { + pub meters: i32, +} +impl table29_other_operator_shapes_Length { + pub unsafe fn operator_cmp( + this: *const Self, + _a0: *const table29_other_operator_shapes_Length, + ) -> libcc2rs::StrongOrdering { + { + let mut cmp: libcc2rs::StrongOrdering = libcc2rs::StrongOrdering::from( + std::cmp::Ord::cmp(&((*this).meters), &((*_a0).meters)), + ); + if !(libcc2rs::is_eq(cmp)) { + return cmp; + } + } + return libcc2rs::STRONG_ORDERING_EQUAL; + } + pub unsafe fn operator_eq( + this: *const Self, + _a0: *const table29_other_operator_shapes_Length, + ) -> bool { + return (((*this).meters) == ((*_a0).meters)); + } +} +impl Cpp17EqualityComparableUnsafe for table29_other_operator_shapes_Length { + type EqualResult = bool; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write( + (unsafe { + table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return (unsafe { + table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl WeaklyEqualityComparableWithUnsafe for table29_other_operator_shapes_Length { + type NotEqualResult = bool; + unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write( + !(unsafe { + table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return !(unsafe { + table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) + }); + } +} +impl LessThanComparableUnsafe for table29_other_operator_shapes_Length { + type Result = bool; + unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write(libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Length { + type LessResult = bool; + unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write(libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterResult = bool; + unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write(libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write(libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + __return.write(libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + )); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ); + } +} +impl ThreeWayComparableUnsafe for table29_other_operator_shapes_Length { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); + let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); + return (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }); + } +} +pub unsafe fn test_5() { assert!( (({ - let mut __tmp_3: table29_other_operator_shapes_Weight = + let mut __tmp_17: table29_other_operator_shapes_Weight = table29_other_operator_shapes_Weight { grams: 3 }; - let mut __tmp_4: table29_other_operator_shapes_Weight = + let mut __tmp_18: table29_other_operator_shapes_Weight = table29_other_operator_shapes_Weight { grams: 5 }; (*{ - let __a: *const _ = (&mut __tmp_3); - let __b: *const _ = (&mut __tmp_4); + let __a: *const _ = (&mut __tmp_17); + let __b: *const _ = (&mut __tmp_18); if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), @@ -430,13 +1163,13 @@ pub unsafe fn test_3() { ); assert!( (({ - let mut __tmp_5: table29_other_operator_shapes_Height = + let mut __tmp_19: table29_other_operator_shapes_Height = table29_other_operator_shapes_Height { millimeters: 30 }; - let mut __tmp_6: table29_other_operator_shapes_Height = + let mut __tmp_20: table29_other_operator_shapes_Height = table29_other_operator_shapes_Height { millimeters: 50 }; (*{ - let __a: *const _ = (&mut __tmp_5); - let __b: *const _ = (&mut __tmp_6); + let __a: *const _ = (&mut __tmp_19); + let __b: *const _ = (&mut __tmp_20); if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), @@ -451,13 +1184,13 @@ pub unsafe fn test_3() { ); assert!( (({ - let mut __tmp_7: table29_other_operator_shapes_Depth = + let mut __tmp_21: table29_other_operator_shapes_Depth = table29_other_operator_shapes_Depth { millimeters: 7 }; - let mut __tmp_8: table29_other_operator_shapes_Depth = + let mut __tmp_22: table29_other_operator_shapes_Depth = table29_other_operator_shapes_Depth { millimeters: 4 }; (*{ - let __a: *const _ = (&mut __tmp_7); - let __b: *const _ = (&mut __tmp_8); + let __a: *const _ = (&mut __tmp_21); + let __b: *const _ = (&mut __tmp_22); if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), @@ -470,6 +1203,363 @@ pub unsafe fn test_3() { .millimeters }) == (7)) ); + assert!( + (({ + let mut __tmp_23: table29_other_operator_shapes_Length = + table29_other_operator_shapes_Length { meters: 2 }; + let mut __tmp_24: table29_other_operator_shapes_Length = + table29_other_operator_shapes_Length { meters: 9 }; + (*{ + let __a: *const _ = (&mut __tmp_23); + let __b: *const _ = (&mut __tmp_24); + if ::is_less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ) { + __b + } else { + __a + } + }) + .meters + }) == (2)) + ); +} +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +#[conversion_function(to_bool, LvalueRefUnsafe>, bool )] +pub struct table29_result_convertible_to_bool_Truth { + pub value: bool, +} +impl table29_result_convertible_to_bool_Truth { + pub unsafe fn to_bool(this: *const Self) -> bool { + return (*this).value; + } +} +impl Cpp17EqualityComparableUnsafe for table29_result_convertible_to_bool_Truth { + type EqualResult = bool; + unsafe fn equal( + __return: *mut Self::EqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + == ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + == ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl WeaklyEqualityComparableWithUnsafe for table29_result_convertible_to_bool_Truth { + type NotEqualResult = bool; + unsafe fn not_equal( + __return: *mut Self::NotEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + != ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_not_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + != ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl LessThanComparableUnsafe for table29_result_convertible_to_bool_Truth { + type Result = bool; + unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl PartiallyOrderedWithUnsafe for table29_result_convertible_to_bool_Truth { + type LessResult = bool; + unsafe fn less( + __return: *mut Self::LessResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type GreaterResult = bool; + unsafe fn greater( + __return: *mut Self::GreaterResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + > ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_greater( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + > ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type LessEqualResult = bool; + unsafe fn less_equal( + __return: *mut Self::LessEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + <= ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_less_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + <= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } + type GreaterEqualResult = bool; + unsafe fn greater_equal( + __return: *mut Self::GreaterEqualResult, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + __return.write( + (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + >= ((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32)), + ); + } + unsafe fn is_greater_equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32) + >= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32)); + } +} +impl ThreeWayComparableUnsafe for table29_result_convertible_to_bool_Truth { + type Category = libcc2rs::StrongOrdering; + unsafe fn three_way( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::Category { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); + return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) + as i32), + &((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) + as i32), + )); + } +} +#[repr(C)] +#[derive( + Copy, + Clone, + VaArg, + FnPtrArg, + ZeroInitializationUnsafe, + TriviallyDefaultConstructibleUnsafe, + TriviallyCopyableUnsafe, + Default, + ConversionsUnsafe, +)] +#[conversions(copy, move)] +pub struct table29_result_convertible_to_bool_Priority { + pub level: i32, +} +impl table29_result_convertible_to_bool_Priority { + pub unsafe fn operator_lt( + this: *const Self, + other: *const table29_result_convertible_to_bool_Priority, + ) -> table29_result_convertible_to_bool_Truth { + return table29_result_convertible_to_bool_Truth { + value: (((*this).level) < ((*other).level)), + }; + } +} +impl LessThanComparableUnsafe for table29_result_convertible_to_bool_Priority { + type Result = table29_result_convertible_to_bool_Truth; + unsafe fn less( + __return: *mut Self::Result, + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); + __return.write( + (unsafe { + table29_result_convertible_to_bool_Priority::operator_lt(&raw const (*__lhs), __rhs) + }), + ); + } + unsafe fn is_less( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> bool { + let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); + let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); + return (unsafe { + table29_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table29_result_convertible_to_bool_Priority::operator_lt( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }); + } +} +pub unsafe fn test_6() { + assert!( + (({ + let mut __tmp_25: table29_result_convertible_to_bool_Priority = + table29_result_convertible_to_bool_Priority { level: 2 }; + let mut __tmp_26: table29_result_convertible_to_bool_Priority = + table29_result_convertible_to_bool_Priority { level: 6 }; + ( * {let __a: *const _ = (& mut __tmp_25); let __b: *const _ = (& mut __tmp_26); if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), ) { __b } else { __a }} ) . level + }) == (6)) + ); + assert!( + (({ + let mut __tmp_27: table29_result_convertible_to_bool_Priority = + table29_result_convertible_to_bool_Priority { level: 2 }; + let mut __tmp_28: table29_result_convertible_to_bool_Priority = + table29_result_convertible_to_bool_Priority { level: 6 }; + ( * {let __a: *const _ = (& mut __tmp_27); let __b: *const _ = (& mut __tmp_28); if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), ) { __b } else { __a }} ) . level + }) == (2)) + ); + let mut priorities: Vec = Vec::from([ + table29_result_convertible_to_bool_Priority { level: 5 }, + table29_result_convertible_to_bool_Priority { level: 1 }, + table29_result_convertible_to_bool_Priority { level: 3 }, + ]); + { + let mut __tmp_29 = { priorities.begin() }; + let __n = priorities.end().iter_distance(&__tmp_29); + let mut __order: Vec = (0..__n).collect(); + __order.sort_by(|&__x, &__y| { let __a = __tmp_29 .iter_at(__x) as *const table29_result_convertible_to_bool_Priority ; let __b = __tmp_29 .iter_at(__y) as *const table29_result_convertible_to_bool_Priority ; if ::is_less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), ) { std::cmp::Ordering::Less } else if ::is_less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal } }); + let __values: Vec<_> = __order + .iter() + .map(|&__i| std::ptr::read(__tmp_29.iter_at(__i))) + .collect(); + for (__i, __v) in (0..__n).zip(__values) { + std::ptr::write(__tmp_29.iter_at(__i), __v); + } + }; + assert!(((priorities[(0_usize)].level) == (1))); + assert!(((priorities[(1_usize)].level) == (3))); + assert!(((priorities[(2_usize)].level) == (5))); + assert!(( ( ( * { let mut __tmp_30 = { priorities .begin() };let mut __tmp_31 = { priorities .end() }; let mut __best = __tmp_30 .clone(); if as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_30 ), LvalueRefUnsafe:: >>::bind(&__tmp_31 ), ) { let mut __it = (__tmp_30 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_31 ), ) { if ::is_less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __best = __it.clone(); } __it.iter_inc(); } } __best } .iter_deref() ) . level ) == ( 5 ) ) ); } #[repr(C)] #[derive( @@ -521,7 +1611,7 @@ impl LessThanComparableUnsafe for pairs_spec_p3_members_order_pairs_Rank { }); } } -pub unsafe fn test_4() { +pub unsafe fn test_7() { let mut low: (pairs_spec_p3_members_order_pairs_Rank, i32) = ((pairs_spec_p3_members_order_pairs_Rank { value: 1 }), 9); let mut high: (pairs_spec_p3_members_order_pairs_Rank, i32) = @@ -593,11 +1683,14 @@ pub fn main() { } } unsafe fn main_0() -> i32 { + (unsafe { test_0() }); (unsafe { test_1() }); (unsafe { test_3() }); - (unsafe { test_4() }); + (unsafe { test_5() }); + (unsafe { test_6() }); + (unsafe { test_7() }); return 0; } pub unsafe fn __cpp2rust_init_globals() { - std::cell::LazyCell::force(&*&raw const less_calls_0); + std::cell::LazyCell::force(&*&raw const less_calls_2); } diff --git a/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp b/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp index 9d14b6cfad..11a89c1996 100644 --- a/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp +++ b/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp @@ -6,6 +6,55 @@ #include #include +// N4950 [utility.arg.requirements] Table 28 (Cpp17EqualityComparable): a == b +// is the only operation the library uses to compare values for equality. +namespace table28_equal_operator { +struct Ticket { + int number; + bool operator==(const Ticket &other) const { return number == other.number; } +}; + +void test() { + std::vector tickets{{4}, {4}, {7}, {9}, {9}}; + assert(std::find(tickets.begin(), tickets.end(), Ticket{7})->number == 7); + assert(std::find(tickets.begin(), tickets.end(), Ticket{5}) == tickets.end()); + auto last = std::unique(tickets.begin(), tickets.end()); + assert(last - tickets.begin() == 3); + assert(tickets[1].number == 7 && tickets[2].number == 9); +} +} // namespace table28_equal_operator + +// N4950 [utility.arg.requirements] Table 28: the result of a == b need only be +// convertible to bool, and then a != b does not exist ([over.match.oper]/9). +namespace table28_result_convertible_to_bool { +struct Truth { + bool value; + operator bool() const { return value; } +}; + +struct Ticket { + int number; + Truth operator==(const Ticket &other) const { + return Truth{number == other.number}; + } +}; + +struct Badge { + int id; + Truth operator==(const int &other) const { return Truth{id == other}; } +}; + +void test() { + std::vector tickets{{4}, {7}, {9}}; + assert(std::find(tickets.begin(), tickets.end(), Ticket{9})->number == 9); + assert(std::find(tickets.begin(), tickets.end(), Ticket{5}) == tickets.end()); + + std::vector badges{{1}, {2}, {3}}; + assert(std::find(badges.begin(), badges.end(), 2)->id == 2); + assert(std::find(badges.begin(), badges.end(), 8) == badges.end()); +} +} // namespace table28_result_convertible_to_bool + // N4950 [utility.arg.requirements] Table 29 (Cpp17LessThanComparable): a < b // is a strict weak ordering, and is the only operation the library uses to // order values. @@ -68,13 +117,46 @@ struct Depth { } }; +struct Length { + int meters; + auto operator<=>(const Length &) const = default; +}; + void test() { assert(std::max(Weight{3}, Weight{5}).grams == 5); assert(std::min(Height{30}, Height{50}).millimeters == 30); assert(std::max(Depth{7}, Depth{4}).millimeters == 7); + assert(std::min(Length{2}, Length{9}).meters == 2); } } // namespace table29_other_operator_shapes +// N4950 [utility.arg.requirements] Table 29: the result of a < b need only be +// convertible to bool. +namespace table29_result_convertible_to_bool { +struct Truth { + bool value; + operator bool() const { return value; } +}; + +struct Priority { + int level; + Truth operator<(const Priority &other) const { + return Truth{level < other.level}; + } +}; + +void test() { + assert(std::max(Priority{2}, Priority{6}).level == 6); + assert(std::min(Priority{2}, Priority{6}).level == 2); + std::vector priorities{{5}, {1}, {3}}; + std::sort(priorities.begin(), priorities.end()); + assert(priorities[0].level == 1); + assert(priorities[1].level == 3); + assert(priorities[2].level == 5); + assert(std::max_element(priorities.begin(), priorities.end())->level == 5); +} +} // namespace table29_result_convertible_to_bool + // N4950 [pairs.spec]/3: pairs are ordered by their first members, and by // their second members if the first ones are equivalent, using operator< of // the members. @@ -99,8 +181,11 @@ void test() { } // namespace pairs_spec_p3_members_order_pairs int main() { + table28_equal_operator::test(); + table28_result_convertible_to_bool::test(); table29_member_operator::test(); table29_other_operator_shapes::test(); + table29_result_convertible_to_bool::test(); pairs_spec_p3_members_order_pairs::test(); return 0; } From 803a4577f073b7ff5a07c4d811687de83d648be9 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 23:15:17 +0000 Subject: [PATCH 15/17] Reduce size of code --- cpp2rust/converter/converter.cpp | 87 +- cpp2rust/converter/converter.h | 13 +- .../converter/models/converter_refcount.cpp | 9 +- .../converter/models/converter_refcount.h | 4 +- libcc2rs/src/cmp.rs | 112 ++ .../out/refcount/friend_operator.rs | 65 +- .../out/unsafe/friend_operator.rs | 93 +- .../out/refcount/class.spaceship.rs | 1144 +++++-------- .../out/unsafe/class.spaceship.rs | 1045 +++++------- .../class.conv/out/refcount/class.conv.fct.rs | 224 +-- .../class.conv/out/unsafe/class.conv.fct.rs | 217 +-- .../refcount/concept.equalitycomparable.rs | 292 ++-- .../out/refcount/concept.totallyordered.rs | 731 +++----- .../out/unsafe/concept.equalitycomparable.rs | 298 ++-- .../out/unsafe/concept.totallyordered.rs | 713 +++----- .../out/refcount/concept.convertible.rs | 247 +-- .../out/unsafe/concept.convertible.rs | 240 +-- .../out/refcount/sequence.reqmts.rs | 217 +-- .../out/unsafe/sequence.reqmts.rs | 238 +-- .../allocator.requirements.general.rs | 52 +- .../unsafe/allocator.requirements.general.rs | 66 +- .../out/refcount/utility.arg.requirements.rs | 1414 ++++++---------- .../out/unsafe/utility.arg.requirements.rs | 1346 ++++++--------- .../stmt.select/out/refcount/stmt.switch.rs | 280 +--- .../stmt.select/out/unsafe/stmt.switch.rs | 350 +--- .../support/cmp/out/refcount/cmp.concept.rs | 1000 +++++------ .../std/support/cmp/out/unsafe/cmp.concept.rs | 989 ++++------- tests/unit/out/refcount/class.rs | 23 +- tests/unit/out/refcount/find.rs | 23 +- tests/unit/out/refcount/friend.rs | 23 +- tests/unit/out/refcount/map_key_copy_ctor.rs | 23 +- tests/unit/out/refcount/map_key_identity.rs | 46 +- tests/unit/out/refcount/max.rs | 23 +- .../refcount/operator_comparison_defaulted.rs | 1354 ++++++--------- .../out/refcount/operator_comparison_free.rs | 240 +-- .../refcount/operator_comparison_member.rs | 157 +- .../out/refcount/operator_comparison_mixed.rs | 276 ++- .../refcount/operator_comparison_nonbool.rs | 936 +++++------ .../operator_comparison_noncopyable.rs | 42 +- tests/unit/out/refcount/operator_friend.rs | 574 ++----- .../out/refcount/operator_other_member.rs | 178 +- tests/unit/out/refcount/operator_overloads.rs | 132 +- tests/unit/out/refcount/operator_three_way.rs | 189 +-- tests/unit/out/refcount/operator_traits.rs | 405 ++--- .../refcount/pair_converting_construction.rs | 211 +-- tests/unit/out/refcount/sort_no_copy.rs | 92 +- .../out/refcount/vector_iter_range_ctor.rs | 206 +-- tests/unit/out/unsafe/class.rs | 26 +- tests/unit/out/unsafe/find.rs | 23 +- tests/unit/out/unsafe/friend.rs | 30 +- tests/unit/out/unsafe/map_key_copy_ctor.rs | 26 +- tests/unit/out/unsafe/map_key_identity.rs | 66 +- tests/unit/out/unsafe/max.rs | 33 +- .../unsafe/operator_comparison_defaulted.rs | 1492 ++++++----------- .../out/unsafe/operator_comparison_free.rs | 315 ++-- .../out/unsafe/operator_comparison_member.rs | 173 +- .../out/unsafe/operator_comparison_mixed.rs | 354 ++-- .../out/unsafe/operator_comparison_nonbool.rs | 954 ++++------- .../unsafe/operator_comparison_noncopyable.rs | 60 +- tests/unit/out/unsafe/operator_friend.rs | 797 +++------ .../unit/out/unsafe/operator_other_member.rs | 208 +-- tests/unit/out/unsafe/operator_overloads.rs | 173 +- tests/unit/out/unsafe/operator_three_way.rs | 208 +-- tests/unit/out/unsafe/operator_traits.rs | 493 ++---- .../unsafe/pair_converting_construction.rs | 217 +-- tests/unit/out/unsafe/sort_no_copy.rs | 132 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 217 +-- 67 files changed, 7931 insertions(+), 14705 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 6026aba320..f01a94a7c9 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5922,72 +5922,59 @@ void Converter::EmitComparisonTrait(const ComparisonTrait &trait, GetUnboxedTypeAsString(comparisons.lhs_type))); PushBrace impl_brace(*this); for (const auto &relation : trait.relations) { - EmitComparisonMethod(relation, comparisons); + EmitComparisonMethod(name, relation, comparisons); } } -void Converter::EmitComparisonMethod(const ComparisonRelation &relation, +void Converter::EmitComparisonMethod(std::string_view trait, + const ComparisonRelation &relation, const Comparisons &comparisons) { auto *expr = comparisons.exprs.at(relation.op); auto type = ctx_.getReferenceQualifiedType(expr); - StrCat(std::format("type {} = {};", relation.result, - type->isReferenceType() - ? GetReferenceMarkerAsString(type) - : GetUnboxedTypeAsString(type.getUnqualifiedType()))); + auto operands = std::format("|{}, {}|", GetNamedDeclAsString(comparisons.lhs), + GetNamedDeclAsString(comparisons.rhs)); + StrCat(GetComparisonMacro(), token::kOpenParen, trait, token::kComma, + relation.method, token::kComma); + if (relation.test_method) { + StrCat(relation.test_method, token::kComma); + } + StrCat(relation.result, "=", + type->isReferenceType() + ? GetReferenceMarkerAsString(type) + : GetUnboxedTypeAsString(type.getUnqualifiedType()), + token::kComma); if (!relation.test_method) { assert(!type->isReferenceType() && !UsesReturnSlot(type)); - EmitComparisonFunction(relation.method, "", - std::format("Self::{}", relation.result), - comparisons, [&] { - HoistMaterializedTempBindings hoist_temps(*this); - StrCat(keyword::kReturn); - ConvertVarInit(type, expr); - StrCat(token::kSemiColon); - }); - return; + StrCat(operands); + EmitComparisonBody([&] { + HoistMaterializedTempBindings hoist_temps(*this); + ConvertVarInit(type, expr); + }); + } else { + StrCat(GetUnboxedTypeAsString(comparisons.rhs_type), token::kComma); + if (!type->isBooleanType()) { + StrCat("|__return,", operands.substr(1)); + EmitComparisonBody([&] { InitializeReturnSlot(type, expr); }); + StrCat(token::kComma, operands); + } else { + StrCat(operands); + } + EmitComparisonBody([&] { + HoistMaterializedTempBindings hoist_temps(*this); + ConvertVarInit(ctx_.BoolTy, comparisons.tests.at(relation.op)); + }); } - EmitComparisonFunction( - relation.method, - std::format("__return: {},", - GetReturnSlotType(std::format("Self::{}", relation.result))), - "", comparisons, [&] { InitializeReturnSlot(type, expr); }); - EmitComparisonFunction(relation.test_method, "", "bool", comparisons, [&] { - HoistMaterializedTempBindings hoist_temps(*this); - StrCat(keyword::kReturn); - ConvertVarInit(ctx_.BoolTy, comparisons.tests.at(relation.op)); - StrCat(token::kSemiColon); - }); + StrCat(token::kCloseParen, token::kSemiColon); } -void Converter::EmitComparisonFunction(std::string_view method, - std::string_view slot_param, - std::string_view return_type, - const Comparisons &comparisons, - llvm::function_ref body) { - StrCat(keyword_unsafe_, keyword::kFn, method); - { - PushParen params(*this); - StrCat(slot_param); - for (auto *operand : {comparisons.lhs, comparisons.rhs}) { - StrCat(GetNamedDeclAsString(operand), token::kColon, - GetReferenceMarkerAsString(operand->getType()), token::kComma); - } - } - if (!return_type.empty()) { - StrCat(token::kArrow, return_type); - } +void Converter::EmitComparisonBody(llvm::function_ref body) { PushBrace brace(*this); - for (auto *operand : {comparisons.lhs, comparisons.rhs}) { - auto name = GetNamedDeclAsString(operand); - StrCat(std::format("let {} = {};", name, - GetReferredObjectPointer(name, operand->getType()))); - } PushExprKind push(*this, ExprKind::Void); ConvertFullExpression(body); } -std::string Converter::GetReturnSlotType(std::string_view object_type) const { - return std::format("*mut {}", object_type); +const char *Converter::GetComparisonMacro() const { + return "comparison_unsafe!"; } void Converter::AddSpecialMemberDerives(const clang::RecordDecl *decl, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index e24e4c9a08..ab8429a521 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -314,8 +314,6 @@ class Converter : public clang::RecursiveASTVisitor { virtual std::string GetReturnSlotArg(std::string_view receiver) const; - virtual std::string GetReturnSlotType(std::string_view object_type) const; - void InitializeReturnSlot(clang::QualType type, clang::Expr *value); std::string GetReturnSlotParam(clang::QualType type); @@ -514,14 +512,13 @@ class Converter : public clang::RecursiveASTVisitor { void EmitComparisonTrait(const ComparisonTrait &trait, const Comparisons &comparisons); - void EmitComparisonMethod(const ComparisonRelation &relation, + void EmitComparisonMethod(std::string_view trait, + const ComparisonRelation &relation, const Comparisons &comparisons); - void EmitComparisonFunction(std::string_view method, - std::string_view slot_param, - std::string_view return_type, - const Comparisons &comparisons, - llvm::function_ref body); + void EmitComparisonBody(llvm::function_ref body); + + virtual const char *GetComparisonMacro() const; void ConvertParamTy(clang::QualType param_type, clang::Expr *expr); diff --git a/cpp2rust/converter/models/converter_refcount.cpp b/cpp2rust/converter/models/converter_refcount.cpp index 468d9c4604..5bae07984e 100644 --- a/cpp2rust/converter/models/converter_refcount.cpp +++ b/cpp2rust/converter/models/converter_refcount.cpp @@ -3584,6 +3584,10 @@ ConverterRefCount::DestroyMembers(const clang::CXXRecordDecl *decl) { const char *ConverterRefCount::GetObjectMacro() const { return "object!"; } +const char *ConverterRefCount::GetComparisonMacro() const { + return "comparison!"; +} + std::string ConverterRefCount::GetStorageReceiver(std::string_view name) const { return std::format("{}.clone()", name); } @@ -3664,11 +3668,6 @@ ConverterRefCount::GetReturnSlotArg(std::string_view receiver) const { return std::format("Ptr::clone(&{})", receiver); } -std::string -ConverterRefCount::GetReturnSlotType(std::string_view object_type) const { - return std::format("Ptr<{}>", object_type); -} - std::string ConverterRefCount::GetParamTypeAsString(const clang::ParmVarDecl *param) { PushConversionKind push(*this, VarConversionKind(param)); diff --git a/cpp2rust/converter/models/converter_refcount.h b/cpp2rust/converter/models/converter_refcount.h index a69641e371..568475720e 100644 --- a/cpp2rust/converter/models/converter_refcount.h +++ b/cpp2rust/converter/models/converter_refcount.h @@ -75,6 +75,8 @@ class ConverterRefCount final : public Converter { const char *GetObjectMacro() const override; + const char *GetComparisonMacro() const override; + std::string GetStorageReceiver(std::string_view name) const override; const char *GetAssignMacro() const override; @@ -112,8 +114,6 @@ class ConverterRefCount final : public Converter { std::string GetReturnSlotArg(std::string_view receiver) const override; - std::string GetReturnSlotType(std::string_view object_type) const override; - bool VisitCXXThisExpr(clang::CXXThisExpr *expr) override; bool ThisIsRustPtr() const override; diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index 8d0d1a5762..4d0427235d 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -1210,3 +1210,115 @@ pub fn cpp_cmp(lhs: &Ptr, rhs: &Ptr) -> Ordering { Ordering::Equal } } + +#[macro_export] +macro_rules! comparison { + ($trait:path, $method:ident, $test:ident, $result:ident = bool, $rhs:ty, + |$a:ident, $b:ident| $body:block) => { + type $result = bool; + fn $method( + __return: $crate::Ptr, + $a: $crate::LvalueRef<$crate::Const>, + $b: $crate::LvalueRef<$crate::Const<$rhs>>, + ) { + __return.write(::$test($a, $b)); + } + fn $test( + $a: $crate::LvalueRef<$crate::Const>, + $b: $crate::LvalueRef<$crate::Const<$rhs>>, + ) -> bool { + let $a = $a.as_pointer(); + let $b = $b.as_pointer(); + $body + } + }; + ($trait:path, $method:ident, $test:ident, $result:ident = $ty:ty, $rhs:ty, + |$slot:ident, $a:ident, $b:ident| $slot_body:block, + |$c:ident, $d:ident| $test_body:block) => { + type $result = $ty; + fn $method( + $slot: $crate::Ptr<$ty>, + $a: $crate::LvalueRef<$crate::Const>, + $b: $crate::LvalueRef<$crate::Const<$rhs>>, + ) { + let $a = $a.as_pointer(); + let $b = $b.as_pointer(); + $slot_body + } + fn $test( + $c: $crate::LvalueRef<$crate::Const>, + $d: $crate::LvalueRef<$crate::Const<$rhs>>, + ) -> bool { + let $c = $c.as_pointer(); + let $d = $d.as_pointer(); + $test_body + } + }; + ($trait:path, $method:ident, $result:ident = $ty:ty, |$a:ident, $b:ident| $body:block) => { + type $result = $ty; + fn $method( + $a: $crate::LvalueRef<$crate::Const>, + $b: $crate::LvalueRef<$crate::Const>, + ) -> $ty { + let $a = $a.as_pointer(); + let $b = $b.as_pointer(); + $body + } + }; +} + +#[macro_export] +macro_rules! comparison_unsafe { + ($trait:path, $method:ident, $test:ident, $result:ident = bool, $rhs:ty, + |$a:ident, $b:ident| $body:block) => { + type $result = bool; + unsafe fn $method( + __return: *mut bool, + $a: $crate::LvalueRefUnsafe<$crate::Const>, + $b: $crate::LvalueRefUnsafe<$crate::Const<$rhs>>, + ) { + unsafe { __return.write(::$test($a, $b)) } + } + unsafe fn $test( + $a: $crate::LvalueRefUnsafe<$crate::Const>, + $b: $crate::LvalueRefUnsafe<$crate::Const<$rhs>>, + ) -> bool { + let $a = $a.as_ptr() as *const Self; + let $b = $b.as_ptr() as *const $rhs; + $body + } + }; + ($trait:path, $method:ident, $test:ident, $result:ident = $ty:ty, $rhs:ty, + |$slot:ident, $a:ident, $b:ident| $slot_body:block, + |$c:ident, $d:ident| $test_body:block) => { + type $result = $ty; + unsafe fn $method( + $slot: *mut $ty, + $a: $crate::LvalueRefUnsafe<$crate::Const>, + $b: $crate::LvalueRefUnsafe<$crate::Const<$rhs>>, + ) { + let $a = $a.as_ptr() as *const Self; + let $b = $b.as_ptr() as *const $rhs; + $slot_body + } + unsafe fn $test( + $c: $crate::LvalueRefUnsafe<$crate::Const>, + $d: $crate::LvalueRefUnsafe<$crate::Const<$rhs>>, + ) -> bool { + let $c = $c.as_ptr() as *const Self; + let $d = $d.as_ptr() as *const $rhs; + $test_body + } + }; + ($trait:path, $method:ident, $result:ident = $ty:ty, |$a:ident, $b:ident| $body:block) => { + type $result = $ty; + unsafe fn $method( + $a: $crate::LvalueRefUnsafe<$crate::Const>, + $b: $crate::LvalueRefUnsafe<$crate::Const>, + ) -> $ty { + let $a = $a.as_ptr() as *const Self; + let $b = $b.as_ptr() as *const Self; + $body + } + }; +} diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index 0d7bafd3be..7763eecc3d 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -28,51 +28,34 @@ pub struct S { pub b: i32, } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ne_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index 533a7d6984..ec9f8e67fe 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -24,82 +24,49 @@ pub struct S { pub b: i32, } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _x: *const S = __lhs; operator_eq_0(_x, __rhs) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _x: *const S = __lhs; - operator_eq_0(_x, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _x: *const S = __lhs; operator_ne_1(_x, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _x: *const S = __lhs; - operator_ne_1(_x, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { (unsafe { let _x: *const S = __lhs; operator_lt_2(_x, __rhs) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _x: *const S = __lhs; - operator_lt_2(_x, __rhs) - }); - } + }) + } + ); } pub fn main() { unsafe { diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 8dabf916d7..d5e1c50166 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -70,239 +70,142 @@ impl p1_memberwise_in_declaration_order_Date { } } impl Cpp17EqualityComparable for p1_memberwise_in_declaration_order_Date { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { ({ p1_memberwise_in_declaration_order_Date::operator_eq( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_memberwise_in_declaration_order_Date::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { !({ p1_memberwise_in_declaration_order_Date::operator_eq( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_memberwise_in_declaration_order_Date::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl LessThanComparable for p1_memberwise_in_declaration_order_Date { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_memberwise_in_declaration_order_Date::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); +} +impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ p1_memberwise_in_declaration_order_Date::operator_cmp( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } -} -impl ThreeWayComparable for p1_memberwise_in_declaration_order_Date { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_memberwise_in_declaration_order_Date::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } pub fn test_0() { let earlier: Value = @@ -455,233 +358,136 @@ impl p2_common_comparison_category_Reading { } } impl Cpp17EqualityComparable for p2_common_comparison_category_Reading { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { ({ p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { !({ p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl LessThanComparable for p2_common_comparison_category_Reading { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for p2_common_comparison_category_Reading { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p2_common_comparison_category_Reading::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); +} +impl ThreeWayComparable for p2_common_comparison_category_Reading { + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::PartialOrdering, + |__lhs, __rhs| { ({ p2_common_comparison_category_Reading::operator_cmp( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } -} -impl ThreeWayComparable for p2_common_comparison_category_Reading { - type Category = libcc2rs::PartialOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p2_common_comparison_category_Reading::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } pub fn test_1() { let low: Value = @@ -754,168 +560,93 @@ impl weak_ordering_from_user_operator_Fraction { } } impl LessThanComparable for weak_ordering_from_user_operator_Fraction { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + weak_ordering_from_user_operator_Fraction::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } pub fn test_2() { let half: Value = @@ -1055,168 +786,93 @@ impl partial_ordering_from_user_operator_Interval { } } impl LessThanComparable for partial_ordering_from_user_operator_Interval { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + partial_ordering_from_user_operator_Interval::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } pub fn test_3() { let early: Value = diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 08ae3c834e..fd8c62d3d6 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -62,203 +62,133 @@ impl p1_memberwise_in_declaration_order_Date { } } impl Cpp17EqualityComparableUnsafe for p1_memberwise_in_declaration_order_Date { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { (unsafe { p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return (unsafe { - p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { !(unsafe { p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return !(unsafe { - p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return libcc2rs::is_lt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return libcc2rs::is_lt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write(libcc2rs::is_gt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return libcc2rs::is_gt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write(libcc2rs::is_lteq( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return libcc2rs::is_lteq( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - __return.write(libcc2rs::is_gteq( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return libcc2rs::is_gteq( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_memberwise_in_declaration_order_Date, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p1_memberwise_in_declaration_order_Date { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - let __rhs = (__rhs.as_ptr() as *const p1_memberwise_in_declaration_order_Date); - return (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + (unsafe { + p1_memberwise_in_declaration_order_Date::operator_cmp(&raw const (*__lhs), __rhs) + }) + } + ); } pub unsafe fn test_0() { let mut earlier: p1_memberwise_in_declaration_order_Date = @@ -377,203 +307,118 @@ impl p2_common_comparison_category_Reading { } } impl Cpp17EqualityComparableUnsafe for p2_common_comparison_category_Reading { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { (unsafe { p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return (unsafe { - p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { !(unsafe { p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return !(unsafe { - p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write(libcc2rs::is_lt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return libcc2rs::is_lt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write(libcc2rs::is_lt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return libcc2rs::is_lt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write(libcc2rs::is_gt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return libcc2rs::is_gt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write(libcc2rs::is_lteq( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return libcc2rs::is_lteq( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - __return.write(libcc2rs::is_gteq( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return libcc2rs::is_gteq( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_common_comparison_category_Reading, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p2_common_comparison_category_Reading { - type Category = libcc2rs::PartialOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p2_common_comparison_category_Reading); - let __rhs = (__rhs.as_ptr() as *const p2_common_comparison_category_Reading); - return (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::PartialOrdering, + |__lhs, __rhs| { + (unsafe { + p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) + }) + } + ); } pub unsafe fn test_1() { let mut low: p2_common_comparison_category_Reading = p2_common_comparison_category_Reading { @@ -632,138 +477,93 @@ impl weak_ordering_from_user_operator_Fraction { } } impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - __return.write(libcc2rs::is_lt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - return libcc2rs::is_lt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - __return.write(libcc2rs::is_lt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - return libcc2rs::is_lt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - __return.write(libcc2rs::is_gt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - return libcc2rs::is_gt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - __return.write(libcc2rs::is_lteq( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - return libcc2rs::is_lteq( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - __return.write(libcc2rs::is_gteq( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - let __rhs = (__rhs.as_ptr() as *const weak_ordering_from_user_operator_Fraction); - return libcc2rs::is_gteq( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + weak_ordering_from_user_operator_Fraction, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + weak_ordering_from_user_operator_Fraction::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } pub unsafe fn test_2() { let mut half: weak_ordering_from_user_operator_Fraction = @@ -879,168 +679,93 @@ impl partial_ordering_from_user_operator_Interval { } } impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - __return.write(libcc2rs::is_lt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - return libcc2rs::is_lt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - __return.write(libcc2rs::is_lt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - return libcc2rs::is_lt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - __return.write(libcc2rs::is_gt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - return libcc2rs::is_gt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - __return.write(libcc2rs::is_lteq( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - return libcc2rs::is_lteq( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - __return.write(libcc2rs::is_gteq( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - let __rhs = (__rhs.as_ptr() as *const partial_ordering_from_user_operator_Interval); - return libcc2rs::is_gteq( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + partial_ordering_from_user_operator_Interval, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + partial_ordering_from_user_operator_Interval::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } pub unsafe fn test_3() { let mut early: partial_ordering_from_user_operator_Interval = diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 27c84a9be1..5ca6475445 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -69,180 +69,96 @@ impl p2_implicit_conversion_function_Ratio { } } impl Cpp17EqualityComparable for p2_implicit_conversion_function_Ratio { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl LessThanComparable for p2_implicit_conversion_function_Ratio { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } pub fn test_1() { let ratio: Value = diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 419e8cb603..37ca68f226 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -60,166 +60,89 @@ impl p2_implicit_conversion_function_Ratio { } } impl Cpp17EqualityComparableUnsafe for p2_implicit_conversion_function_Ratio { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } + == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Ratio { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - != (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - != (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } + != (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl LessThanComparableUnsafe for p2_implicit_conversion_function_Ratio { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - > (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - > (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + > (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - <= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - <= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - __return.write( + <= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_implicit_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - >= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p2_implicit_conversion_function_Ratio); - return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - >= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); - } + >= (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } pub unsafe fn test_1() { let mut ratio: p2_implicit_conversion_function_Ratio = p2_implicit_conversion_function_Ratio { diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index 76e653bc0c..a56508da10 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -38,44 +38,28 @@ impl p1_3_not_equal_Meters { } } impl Cpp17EqualityComparable for p1_3_not_equal_Meters { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_3_not_equal_Meters, + |__lhs, __rhs| { + ({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_3_not_equal_Meters, + |__lhs, __rhs| { + ({ p1_3_not_equal_Meters::operator_ne((__lhs).clone(), (__rhs).clone()) }) + } + ); } pub fn test_1() { let three: Value = @@ -116,92 +100,52 @@ impl p1_2_reversed_operands_Meters { } } impl Cpp17EqualityComparable for p1_2_reversed_operands_Meters { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { + ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl Cpp17EqualityComparable for i32 { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_2_reversed_operands_Meters, + |__lhs, __rhs| { + ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { + !({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for i32 { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_2_reversed_operands_Meters, + |__lhs, __rhs| { + !({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }) + } + ); } pub fn test_2() { let three: Value = @@ -256,88 +200,52 @@ impl p1_different_types_Meters { } } impl Cpp17EqualityComparable for p1_different_types_Meters { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { + ({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl Cpp17EqualityComparable for i32 { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_different_types_Meters, + |__lhs, __rhs| { + ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_different_types_Meters { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(!({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { + !({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for i32 { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(!({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_different_types_Meters, + |__lhs, __rhs| { + !({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }) + } + ); } pub fn test_3() { let lengths: Value> = Rc::new(RefCell::new(Vec::from([ diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index 146b78e1ee..d709176dff 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -55,180 +55,96 @@ impl p1_each_relation_is_an_operator_Score { } } impl Cpp17EqualityComparable for p1_each_relation_is_an_operator_Score { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { !({ p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl LessThanComparable for p1_each_relation_is_an_operator_Score { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_gt((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_gt((__lhs).clone(), (__rhs).clone()) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_le((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_le((__lhs).clone(), (__rhs).clone()) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { ({ p1_each_relation_is_an_operator_Score::operator_ge((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_each_relation_is_an_operator_Score::operator_ge((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } pub fn test_3() { let low: Value = @@ -307,179 +223,127 @@ impl p1_relations_from_three_way_Level { } } impl Cpp17EqualityComparable for p1_relations_from_three_way_Level { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + ({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + !({ p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl LessThanComparable for p1_relations_from_three_way_Level { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_relations_from_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_relations_from_three_way_Level { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_relations_from_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_relations_from_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_relations_from_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_relations_from_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl ThreeWayComparable for p1_relations_from_three_way_Level { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + ({ p1_relations_from_three_way_Level::operator_cmp((__lhs).clone(), (__rhs).clone()) }) + } + ); } pub fn test_4() { let shallow: Value = @@ -566,166 +430,91 @@ impl p1_operator_preferred_over_three_way_Level { } } impl LessThanComparable for p1_operator_preferred_over_three_way_Level { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { ({ p1_operator_preferred_over_three_way_Level::operator_gt( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_operator_preferred_over_three_way_Level::operator_gt( - (__lhs).clone(), - (__rhs).clone(), + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), ) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ); - } + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_operator_preferred_over_three_way_Level::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } pub fn test_6() { let shallow: Value = diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 5f9dc48433..7b4c7561ef 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -34,44 +34,28 @@ impl p1_3_not_equal_Meters { } } impl Cpp17EqualityComparableUnsafe for p1_3_not_equal_Meters { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); - let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); - __return.write((unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); - let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); - return (unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_3_not_equal_Meters, + |__lhs, __rhs| { + (unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); - let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); - __return.write((unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_3_not_equal_Meters); - let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); - return (unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_3_not_equal_Meters, + |__lhs, __rhs| { + (unsafe { p1_3_not_equal_Meters::operator_ne(&raw const (*__lhs), __rhs) }) + } + ); } pub unsafe fn test_1() { let mut three: p1_3_not_equal_Meters = p1_3_not_equal_Meters { value: 3 }; @@ -104,96 +88,52 @@ impl p1_2_reversed_operands_Meters { } } impl Cpp17EqualityComparableUnsafe for p1_2_reversed_operands_Meters { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write( - (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { + (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl Cpp17EqualityComparableUnsafe for i32 { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); - __return.write( - (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); - return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_2_reversed_operands_Meters, + |__lhs, __rhs| { + (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write( - !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_2_reversed_operands_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - return !(unsafe { - p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { + !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for i32 { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); - __return.write( - !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); - return !(unsafe { - p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_2_reversed_operands_Meters, + |__lhs, __rhs| { + !(unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }) + } + ); } pub unsafe fn test_2() { let mut three: p1_2_reversed_operands_Meters = p1_2_reversed_operands_Meters { value: 3 }; @@ -244,90 +184,52 @@ impl p1_different_types_Meters { } } impl Cpp17EqualityComparableUnsafe for p1_different_types_Meters { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - __return - .write((unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { + (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl Cpp17EqualityComparableUnsafe for i32 { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); - __return - .write((unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); - return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_different_types_Meters, + |__lhs, __rhs| { + (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write( - !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_different_types_Meters); - let __rhs = (__rhs.as_ptr() as *const i32); - return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { + !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for i32 { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); - __return.write( - !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); - return !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_different_types_Meters, + |__lhs, __rhs| { + !(unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }) + } + ); } pub unsafe fn test_3() { let mut lengths: Vec = Vec::from([ diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index bab544a29a..f6599020a7 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -64,180 +64,96 @@ impl p1_each_relation_is_an_operator_Score { } } impl Cpp17EqualityComparableUnsafe for p1_each_relation_is_an_operator_Score { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { !(unsafe { p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return !(unsafe { - p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) - }); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_gt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_gt(&raw const (*__lhs), __rhs) - }); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_le(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_le(&raw const (*__lhs), __rhs) - }); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_each_relation_is_an_operator_Score, + |__lhs, __rhs| { (unsafe { p1_each_relation_is_an_operator_Score::operator_ge(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - let __rhs = (__rhs.as_ptr() as *const p1_each_relation_is_an_operator_Score); - return (unsafe { - p1_each_relation_is_an_operator_Score::operator_ge(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } pub unsafe fn test_3() { let mut low: p1_each_relation_is_an_operator_Score = @@ -303,201 +219,112 @@ impl p1_relations_from_three_way_Level { } } impl Cpp17EqualityComparableUnsafe for p1_relations_from_three_way_Level { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write( - (unsafe { p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return (unsafe { - p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + (unsafe { p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write( - !(unsafe { - p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return !(unsafe { - p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + !(unsafe { p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return libcc2rs::is_lt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return libcc2rs::is_lt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write(libcc2rs::is_gt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return libcc2rs::is_gt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write(libcc2rs::is_lteq( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return libcc2rs::is_lteq( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - __return.write(libcc2rs::is_gteq( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return libcc2rs::is_gteq( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_relations_from_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p1_relations_from_three_way_Level { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_relations_from_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_relations_from_three_way_Level); - return (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + (unsafe { p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) }) + } + ); } pub unsafe fn test_4() { let mut shallow: p1_relations_from_three_way_Level = @@ -567,136 +394,88 @@ impl p1_operator_preferred_over_three_way_Level { } } impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - return libcc2rs::is_lt( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - return libcc2rs::is_lt( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { (unsafe { p1_operator_preferred_over_three_way_Level::operator_gt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - return (unsafe { - p1_operator_preferred_over_three_way_Level::operator_gt(&raw const (*__lhs), __rhs) - }); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - __return.write(libcc2rs::is_lteq( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - return libcc2rs::is_lteq( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - __return.write(libcc2rs::is_gteq( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - let __rhs = (__rhs.as_ptr() as *const p1_operator_preferred_over_three_way_Level); - return libcc2rs::is_gteq( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_operator_preferred_over_three_way_Level, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_operator_preferred_over_three_way_Level::operator_cmp( + &raw const (*__lhs), + __rhs, + ) + }), + ) + } + ); } pub unsafe fn test_6() { let mut shallow: p1_operator_preferred_over_three_way_Level = diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index e9e0334b26..779ab0685d 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -84,194 +84,109 @@ impl p1_convertible_to_Ratio { } } impl Cpp17EqualityComparable for p1_convertible_to_Ratio { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } == { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } == { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } != { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } != { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl LessThanComparable for p1_convertible_to_Ratio { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl PartiallyOrderedWith for p1_convertible_to_Ratio { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } > { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } > { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } <= { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } <= { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } >= { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } >= { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }); - } + }) + } + ); } impl ThreeWayComparable for p1_convertible_to_Ratio { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }), - &({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }), - )); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }), + &({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }), + )) + } + ); } const _: () = assert!(true, "std::convertible_to"); const _: () = assert!(!(false), "!std::convertible_to"); diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 3ba8d5319c..207e604914 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -74,180 +74,102 @@ impl p1_convertible_to_Ratio { } } impl Cpp17EqualityComparableUnsafe for p1_convertible_to_Ratio { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } + == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - != (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - != (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } + != (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl LessThanComparableUnsafe for p1_convertible_to_Ratio { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - > (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - > (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + > (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - <= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - <= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - __return.write( + <= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_convertible_to_Ratio, + |__lhs, __rhs| { ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - >= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - >= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); - } + >= (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) + } + ); } impl ThreeWayComparableUnsafe for p1_convertible_to_Ratio { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_convertible_to_Ratio); - let __rhs = (__rhs.as_ptr() as *const p1_convertible_to_Ratio); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }), - &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) }), - )); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }), + &(unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) }), + )) + } + ); } const _: () = assert!(true, "std::convertible_to"); const _: () = assert!(!(false), "!std::convertible_to"); diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 80cc1cf576..5d21e9775a 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -32,173 +32,96 @@ impl p38_insert_range_by_conversion_function_Ratio { } } impl Cpp17EqualityComparable for p38_insert_range_by_conversion_function_Ratio { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - == { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ratio { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } != { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - != { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } + }) + } + ); } impl LessThanComparable for p38_insert_range_by_conversion_function_Ratio { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } + }) + } + ); } impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - < { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } > { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - > { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } <= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - <= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } >= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } - >= { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); - } + }) + } + ); } pub fn test_0() { let ratios: Value> = diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index bd52c1d729..ccbcdba668 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -29,208 +29,110 @@ impl p38_insert_range_by_conversion_function_Ratio { } } impl Cpp17EqualityComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) == (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) == (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } + })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_function_Ratio { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) != (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) != (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } + })) + } + ); } impl LessThanComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) < (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) < (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } + })) + } + ); } impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Ratio { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) < (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) < (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) > (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) > (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) <= (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) <= (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p38_insert_range_by_conversion_function_Ratio, + |__lhs, __rhs| { ((unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) >= (unsafe { p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - let __rhs = (__rhs.as_ptr() as *const p38_insert_range_by_conversion_function_Ratio); - return ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) >= (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })); - } + })) + } + ); } pub unsafe fn test_0() { let mut ratios: [p38_insert_range_by_conversion_function_Ratio; 2] = [ diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 9ed544d65e..594b6a49ac 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -46,44 +46,24 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { } } impl Cpp17EqualityComparable for p16_rebind_member_Alloc_std_pair_const_int__int__ { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p16_rebind_member_Alloc_std_pair_const_int__int__, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int__int__ { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p16_rebind_member_Alloc_std_pair_const_int__int__, + |__lhs, __rhs| { !({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index 630af1033a..4ad7ab13c8 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -41,60 +41,34 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { } } impl Cpp17EqualityComparableUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p16_rebind_member_Alloc_std_pair_const_int__int__, + |__lhs, __rhs| { (unsafe { let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - return (unsafe { - let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p16_rebind_member_Alloc_std_pair_const_int__int__, + |__lhs, __rhs| { !(unsafe { let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - let __rhs = (__rhs.as_ptr() as *const p16_rebind_member_Alloc_std_pair_const_int__int__); - return !(unsafe { - let _a: *const p16_rebind_member_Alloc_std_pair_const_int__int__ = __lhs; - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl Default for p16_rebind_member_Alloc_std_pair_const_int__int__ { fn default() -> Self { diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index b909e5573b..837e9be022 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -31,48 +31,28 @@ impl table28_equal_operator_Ticket { } } impl Cpp17EqualityComparable for table28_equal_operator_Ticket { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + table28_equal_operator_Ticket, + |__lhs, __rhs| { + ({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for table28_equal_operator_Ticket { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + table28_equal_operator_Ticket, + |__lhs, __rhs| { + !({ table28_equal_operator_Ticket::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } pub fn test_0() { let tickets: Value> = Rc::new(RefCell::new(Vec::from([ @@ -123,222 +103,123 @@ impl table28_result_convertible_to_bool_Truth { } } impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Truth { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } == { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } == { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for table28_result_convertible_to_bool_Truth { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } != { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } != { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl LessThanComparable for table28_result_convertible_to_bool_Truth { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } < { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } < { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl PartiallyOrderedWith for table28_result_convertible_to_bool_Truth { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } < { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } < { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } > { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } > { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } <= { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } <= { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } >= { (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } >= { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl ThreeWayComparable for table28_result_convertible_to_bool_Truth { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &(({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), - &(({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), - )); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), + &(({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), + )) + } + ); } #[derive( Copy, @@ -370,43 +251,38 @@ impl table28_result_convertible_to_bool_Ticket { } } impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Ticket { - type EqualResult = table28_result_convertible_to_bool_Truth; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = table28_result_convertible_to_bool_Truth, + table28_result_convertible_to_bool_Ticket, + |__return, __lhs, __rhs| { + __return.write( + ({ + table28_result_convertible_to_bool_Ticket::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + }, + |__lhs, __rhs| { ({ - table28_result_convertible_to_bool_Ticket::operator_eq( - (__lhs).clone(), - (__rhs).clone(), + table28_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table28_result_convertible_to_bool_Ticket::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), ) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table28_result_convertible_to_bool_Truth::to_bool( - Rc::new(RefCell::new( - ({ - table28_result_convertible_to_bool_Ticket::operator_eq( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )) - .as_pointer(), - ) - }); - } + }) + } + ); } #[derive( Copy, @@ -438,43 +314,38 @@ impl table28_result_convertible_to_bool_Badge { } } impl Cpp17EqualityComparable for table28_result_convertible_to_bool_Badge { - type EqualResult = table28_result_convertible_to_bool_Truth; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = table28_result_convertible_to_bool_Truth, + i32, + |__return, __lhs, __rhs| { + __return.write( + ({ + table28_result_convertible_to_bool_Badge::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + }, + |__lhs, __rhs| { ({ - table28_result_convertible_to_bool_Badge::operator_eq( - (__lhs).clone(), - (__rhs).clone(), + table28_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table28_result_convertible_to_bool_Badge::operator_eq( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), ) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table28_result_convertible_to_bool_Truth::to_bool( - Rc::new(RefCell::new( - ({ - table28_result_convertible_to_bool_Badge::operator_eq( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )) - .as_pointer(), - ) - }); - } + }) + } + ); } pub fn test_1() { let tickets: Value> = @@ -527,28 +398,16 @@ impl table29_member_operator_Version { } } impl LessThanComparable for table29_member_operator_Version { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ table29_member_operator_Version::operator_lt((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table29_member_operator_Version::operator_lt((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_member_operator_Version, + |__lhs, __rhs| { + ({ table29_member_operator_Version::operator_lt((__lhs).clone(), (__rhs).clone()) }) + } + ); } pub fn test_3() { let old_version: Value = @@ -688,34 +547,20 @@ impl table29_other_operator_shapes_Weight { } } impl LessThanComparable for table29_other_operator_shapes_Weight { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Weight, + |__lhs, __rhs| { ({ table29_other_operator_shapes_Weight::operator_lt((__lhs).clone(), { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table29_other_operator_shapes_Weight::operator_lt((__lhs).clone(), { - (*__rhs.upgrade().deref()) }) - }); - } + } + ); } #[derive( Copy, @@ -737,24 +582,14 @@ pub struct table29_other_operator_shapes_Height { pub millimeters: i32, } impl LessThanComparable for table29_other_operator_shapes_Height { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Height, + |__lhs, __rhs| { ({ operator_lt_4((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_4( lhs: Ptr, @@ -793,138 +628,93 @@ impl table29_other_operator_shapes_Depth { } } impl LessThanComparable for table29_other_operator_shapes_Depth { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - table29_other_operator_shapes_Depth::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Depth::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Depth::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Depth::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } #[derive( Copy, @@ -968,203 +758,133 @@ impl table29_other_operator_shapes_Length { } } impl Cpp17EqualityComparable for table29_other_operator_shapes_Length { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { ({ table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for table29_other_operator_shapes_Length { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { !({ table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - table29_other_operator_shapes_Length::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } impl LessThanComparable for table29_other_operator_shapes_Length { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Length::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for table29_other_operator_shapes_Length { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + table29_other_operator_shapes_Length::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + table29_other_operator_shapes_Length::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + table29_other_operator_shapes_Length::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + table29_other_operator_shapes_Length::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl ThreeWayComparable for table29_other_operator_shapes_Length { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + ({ + table29_other_operator_shapes_Length::operator_cmp((__lhs).clone(), (__rhs).clone()) + }) + } + ); } pub fn test_5() { assert!( @@ -1294,222 +1014,123 @@ impl table29_result_convertible_to_bool_Truth { } } impl Cpp17EqualityComparable for table29_result_convertible_to_bool_Truth { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } == { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } == { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for table29_result_convertible_to_bool_Truth { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } != { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } != { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl LessThanComparable for table29_result_convertible_to_bool_Truth { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } < { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } < { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl PartiallyOrderedWith for table29_result_convertible_to_bool_Truth { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } < { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } < { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } > { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } > { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } <= { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } <= { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } >= { (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) - } >= { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl ThreeWayComparable for table29_result_convertible_to_bool_Truth { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &(({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), - &(({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), - )); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32), + &(({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) as i32), + )) + } + ); } #[derive( Copy, @@ -1541,43 +1162,38 @@ impl table29_result_convertible_to_bool_Priority { } } impl LessThanComparable for table29_result_convertible_to_bool_Priority { - type Result = table29_result_convertible_to_bool_Truth; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = table29_result_convertible_to_bool_Truth, + table29_result_convertible_to_bool_Priority, + |__return, __lhs, __rhs| { + __return.write( + ({ + table29_result_convertible_to_bool_Priority::operator_lt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ); + }, + |__lhs, __rhs| { ({ - table29_result_convertible_to_bool_Priority::operator_lt( - (__lhs).clone(), - (__rhs).clone(), + table29_result_convertible_to_bool_Truth::to_bool( + Rc::new(RefCell::new( + ({ + table29_result_convertible_to_bool_Priority::operator_lt( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + )) + .as_pointer(), ) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - table29_result_convertible_to_bool_Truth::to_bool( - Rc::new(RefCell::new( - ({ - table29_result_convertible_to_bool_Priority::operator_lt( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - )) - .as_pointer(), - ) - }); - } + }) + } + ); } pub fn test_6() { assert!( @@ -1676,33 +1292,21 @@ impl pairs_spec_p3_members_order_pairs_Rank { } } impl LessThanComparable for pairs_spec_p3_members_order_pairs_Rank { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + pairs_spec_p3_members_order_pairs_Rank, + |__lhs, __rhs| { ({ pairs_spec_p3_members_order_pairs_Rank::operator_lt( (__lhs).clone(), (__rhs).clone(), ) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - pairs_spec_p3_members_order_pairs_Rank::operator_lt((__lhs).clone(), (__rhs).clone()) - }); - } + }) + } + ); } pub fn test_7() { let low: Value<(Value, Value)> = diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index 56ee74bce1..dd07e86e1e 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -31,50 +31,28 @@ impl table28_equal_operator_Ticket { } } impl Cpp17EqualityComparableUnsafe for table28_equal_operator_Ticket { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); - __return.write( - (unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); - return (unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + table28_equal_operator_Ticket, + |__lhs, __rhs| { + (unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for table28_equal_operator_Ticket { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); - __return.write( - !(unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_equal_operator_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_equal_operator_Ticket); - return !(unsafe { - table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + table28_equal_operator_Ticket, + |__lhs, __rhs| { + !(unsafe { table28_equal_operator_Ticket::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } pub unsafe fn test_0() { let mut tickets: Vec = Vec::from([ @@ -130,217 +108,127 @@ impl table28_result_convertible_to_bool_Truth { } } impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Truth { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) == ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - == ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl WeaklyEqualityComparableWithUnsafe for table28_result_convertible_to_bool_Truth { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) != ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - != ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl LessThanComparableUnsafe for table28_result_convertible_to_bool_Truth { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl PartiallyOrderedWithUnsafe for table28_result_convertible_to_bool_Truth { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) > ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - > ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) <= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - <= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table28_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) >= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - >= ((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl ThreeWayComparableUnsafe for table28_result_convertible_to_bool_Truth { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Truth); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32), - &((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32), - )); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) + }) as i32), + &((unsafe { + table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32), + )) + } + ); } #[repr(C)] #[derive( @@ -369,37 +257,35 @@ impl table28_result_convertible_to_bool_Ticket { } } impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Ticket { - type EqualResult = table28_result_convertible_to_bool_Truth; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); - __return.write( - (unsafe { - table28_result_convertible_to_bool_Ticket::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); - let __rhs = (__rhs.as_ptr() as *const table28_result_convertible_to_bool_Ticket); - return (unsafe { - table28_result_convertible_to_bool_Truth::to_bool( - &(unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = table28_result_convertible_to_bool_Truth, + table28_result_convertible_to_bool_Ticket, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { table28_result_convertible_to_bool_Ticket::operator_eq( &raw const (*__lhs), __rhs, ) }), - ) - }); - } + ); + }, + |__lhs, __rhs| { + (unsafe { + table28_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table28_result_convertible_to_bool_Ticket::operator_eq( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }) + } + ); } #[repr(C)] #[derive( @@ -428,37 +314,35 @@ impl table28_result_convertible_to_bool_Badge { } } impl Cpp17EqualityComparableUnsafe for table28_result_convertible_to_bool_Badge { - type EqualResult = table28_result_convertible_to_bool_Truth; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Badge); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write( - (unsafe { - table28_result_convertible_to_bool_Badge::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table28_result_convertible_to_bool_Badge); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { - table28_result_convertible_to_bool_Truth::to_bool( - &(unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = table28_result_convertible_to_bool_Truth, + i32, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { table28_result_convertible_to_bool_Badge::operator_eq( &raw const (*__lhs), __rhs, ) }), - ) - }); - } + ); + }, + |__lhs, __rhs| { + (unsafe { + table28_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table28_result_convertible_to_bool_Badge::operator_eq( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }) + } + ); } pub unsafe fn test_1() { let mut tickets: Vec = Vec::from([ @@ -531,28 +415,16 @@ impl table29_member_operator_Version { } } impl LessThanComparableUnsafe for table29_member_operator_Version { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_member_operator_Version); - let __rhs = (__rhs.as_ptr() as *const table29_member_operator_Version); - __return.write( - (unsafe { table29_member_operator_Version::operator_lt(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_member_operator_Version); - let __rhs = (__rhs.as_ptr() as *const table29_member_operator_Version); - return (unsafe { - table29_member_operator_Version::operator_lt(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_member_operator_Version, + |__lhs, __rhs| { + (unsafe { table29_member_operator_Version::operator_lt(&raw const (*__lhs), __rhs) }) + } + ); } pub unsafe fn test_3() { let mut old_version: table29_member_operator_Version = @@ -666,30 +538,18 @@ impl table29_other_operator_shapes_Weight { } } impl LessThanComparableUnsafe for table29_other_operator_shapes_Weight { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Weight); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Weight); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Weight, + |__lhs, __rhs| { (unsafe { table29_other_operator_shapes_Weight::operator_lt(&raw const (*__lhs), (*__rhs)) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Weight); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Weight); - return (unsafe { - table29_other_operator_shapes_Weight::operator_lt(&raw const (*__lhs), (*__rhs)) - }); - } + }) + } + ); } #[repr(C)] #[derive( @@ -708,32 +568,19 @@ pub struct table29_other_operator_shapes_Height { pub millimeters: i32, } impl LessThanComparableUnsafe for table29_other_operator_shapes_Height { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Height); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Height, + |__lhs, __rhs| { (unsafe { let _lhs: *const table29_other_operator_shapes_Height = __lhs; operator_lt_4(_lhs, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Height); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Height); - return (unsafe { - let _lhs: *const table29_other_operator_shapes_Height = __lhs; - operator_lt_4(_lhs, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_4( lhs: *const table29_other_operator_shapes_Height, @@ -769,138 +616,78 @@ impl table29_other_operator_shapes_Depth { } } impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - __return.write(libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - return libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - __return.write(libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - return libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - __return.write(libcc2rs::is_gt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - return libcc2rs::is_gt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - __return.write(libcc2rs::is_lteq( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - return libcc2rs::is_lteq( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - __return.write(libcc2rs::is_gteq( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Depth); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Depth); - return libcc2rs::is_gteq( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_other_operator_shapes_Depth, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } #[repr(C)] #[derive( @@ -941,203 +728,118 @@ impl table29_other_operator_shapes_Length { } } impl Cpp17EqualityComparableUnsafe for table29_other_operator_shapes_Length { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { (unsafe { table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return (unsafe { - table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for table29_other_operator_shapes_Length { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { !(unsafe { table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return !(unsafe { - table29_other_operator_shapes_Length::operator_eq(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for table29_other_operator_shapes_Length { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write(libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Length { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write(libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write(libcc2rs::is_gt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return libcc2rs::is_gt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write(libcc2rs::is_lteq( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return libcc2rs::is_lteq( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - __return.write(libcc2rs::is_gteq( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return libcc2rs::is_gteq( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_other_operator_shapes_Length, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for table29_other_operator_shapes_Length { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const table29_other_operator_shapes_Length); - let __rhs = (__rhs.as_ptr() as *const table29_other_operator_shapes_Length); - return (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + (unsafe { + table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) + }) + } + ); } pub unsafe fn test_5() { assert!( @@ -1248,217 +950,127 @@ impl table29_result_convertible_to_bool_Truth { } } impl Cpp17EqualityComparableUnsafe for table29_result_convertible_to_bool_Truth { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) == ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - == ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl WeaklyEqualityComparableWithUnsafe for table29_result_convertible_to_bool_Truth { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) != ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - != ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl LessThanComparableUnsafe for table29_result_convertible_to_bool_Truth { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl PartiallyOrderedWithUnsafe for table29_result_convertible_to_bool_Truth { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) > ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - > ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) <= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - <= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - __return.write( + }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + table29_result_convertible_to_bool_Truth, + |__lhs, __rhs| { (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) as i32) >= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - >= ((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32)); - } + }) as i32)) + } + ); } impl ThreeWayComparableUnsafe for table29_result_convertible_to_bool_Truth { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Truth); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32), - &((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) }) - as i32), - )); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) + }) as i32), + &((unsafe { + table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) + }) as i32), + )) + } + ); } #[repr(C)] #[derive( @@ -1487,37 +1099,35 @@ impl table29_result_convertible_to_bool_Priority { } } impl LessThanComparableUnsafe for table29_result_convertible_to_bool_Priority { - type Result = table29_result_convertible_to_bool_Truth; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); - __return.write( - (unsafe { - table29_result_convertible_to_bool_Priority::operator_lt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); - let __rhs = (__rhs.as_ptr() as *const table29_result_convertible_to_bool_Priority); - return (unsafe { - table29_result_convertible_to_bool_Truth::to_bool( - &(unsafe { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = table29_result_convertible_to_bool_Truth, + table29_result_convertible_to_bool_Priority, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { table29_result_convertible_to_bool_Priority::operator_lt( &raw const (*__lhs), __rhs, ) }), - ) - }); - } + ); + }, + |__lhs, __rhs| { + (unsafe { + table29_result_convertible_to_bool_Truth::to_bool( + &(unsafe { + table29_result_convertible_to_bool_Priority::operator_lt( + &raw const (*__lhs), + __rhs, + ) + }), + ) + }) + } + ); } pub unsafe fn test_6() { assert!( @@ -1586,30 +1196,18 @@ impl pairs_spec_p3_members_order_pairs_Rank { } } impl LessThanComparableUnsafe for pairs_spec_p3_members_order_pairs_Rank { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); - let __rhs = (__rhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + pairs_spec_p3_members_order_pairs_Rank, + |__lhs, __rhs| { (unsafe { pairs_spec_p3_members_order_pairs_Rank::operator_lt(&raw const (*__lhs), __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); - let __rhs = (__rhs.as_ptr() as *const pairs_spec_p3_members_order_pairs_Rank); - return (unsafe { - pairs_spec_p3_members_order_pairs_Rank::operator_lt(&raw const (*__lhs), __rhs) - }); - } + }) + } + ); } pub unsafe fn test_7() { let mut low: (pairs_spec_p3_members_order_pairs_Rank, i32) = diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 62a2a12b99..32a820a7d1 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -119,15 +119,13 @@ impl Destructible for p2_condition_variable_lives_for_whole_statement_ConvertsTo } } impl Cpp17EqualityComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -140,42 +138,20 @@ impl Cpp17EqualityComparable for p2_condition_variable_lives_for_whole_statement (__rhs).clone(), ) }) - }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } == { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) }) - }); - } + } + ); } impl WeaklyEqualityComparableWith for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -188,40 +164,18 @@ impl WeaklyEqualityComparableWith (__rhs).clone(), ) }) - }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } != { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) }) - }); - } + } + ); } impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -234,40 +188,18 @@ impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_Conv (__rhs).clone(), ) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) }) - } < { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) - }) - }); - } + } + ); } impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -280,38 +212,16 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co (__rhs).clone(), ) }) - }), - ); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } < { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) }) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -324,38 +234,16 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co (__rhs).clone(), ) }) - }), - ); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } > { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) }) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -368,38 +256,16 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co (__rhs).clone(), ) }) - }), - ); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) }) - } <= { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) - }) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ({ ({ p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( @@ -412,29 +278,9 @@ impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_Co (__rhs).clone(), ) }) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } >= { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) }) - }); - } + } + ); } pub fn test_7() { { diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index bc8f802a46..8ab47ef771 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -95,21 +95,13 @@ impl DestructibleUnsafe for p2_condition_variable_lives_for_whole_statement_Conv impl Cpp17EqualityComparableUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -118,50 +110,20 @@ impl Cpp17EqualityComparableUnsafe p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) == (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } + })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -170,48 +132,18 @@ impl WeaklyEqualityComparableWithUnsafe p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) != (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } + })) + } + ); } impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -220,48 +152,18 @@ impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statemen p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) < (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } + })) + } + ); } impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -270,46 +172,16 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) < (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -318,46 +190,16 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) > (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -366,46 +208,16 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) <= (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - __return.write( + })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p2_condition_variable_lives_for_whole_statement_ConvertsToInt, + |__lhs, __rhs| { ((unsafe { p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__lhs), @@ -414,31 +226,9 @@ impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statem p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( &raw const (*__rhs), ) - })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe< - Const, - >, - __rhs: LvalueRefUnsafe< - Const, - >, - ) -> bool { - let __lhs = (__lhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - let __rhs = (__rhs.as_ptr() - as *const p2_condition_variable_lives_for_whole_statement_ConvertsToInt); - return ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) >= (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })); - } + })) + } + ); } pub unsafe fn test_7() { { diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index 6716633aeb..d7826dd76b 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -58,177 +58,112 @@ impl p1_defaulted_three_way_Version { } } impl Cpp17EqualityComparable for p1_defaulted_three_way_Version { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + !({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl LessThanComparable for p1_defaulted_three_way_Version { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_defaulted_three_way_Version { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl ThreeWayComparable for p1_defaulted_three_way_Version { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + ({ p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -334,179 +269,112 @@ impl p1_user_written_three_way_Money { } } impl Cpp17EqualityComparable for p1_user_written_three_way_Money { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + ({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + !({ p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl LessThanComparable for p1_user_written_three_way_Money { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_user_written_three_way_Money { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl ThreeWayComparable for p1_user_written_three_way_Money { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + ({ p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); pub fn test_2() { @@ -579,177 +447,112 @@ impl p1_weaker_category_Temperature { } } impl Cpp17EqualityComparable for p1_weaker_category_Temperature { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - !({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }), - ); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ - p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + !({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }) + } + ); } impl LessThanComparable for p1_weaker_category_Temperature { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_weaker_category_Temperature { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) + }), + ) + } + ); } impl ThreeWayComparable for p1_weaker_category_Temperature { - type Category = libcc2rs::PartialOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) - }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::PartialOrdering, + |__lhs, __rhs| { + ({ p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -807,138 +610,93 @@ impl p1_three_way_without_equality_Rank { } } impl LessThanComparable for p1_three_way_without_equality_Rank { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq( - ({ - p1_three_way_without_equality_Rank::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lt( + ({ + p1_three_way_without_equality_Rank::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_gt( + ({ + p1_three_way_without_equality_Rank::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_gteq( + ({ + p1_three_way_without_equality_Rank::operator_cmp( + (__lhs).clone(), + (__rhs).clone(), + ) + }), + ) + } + ); } const _: () = assert!(!(false), "!std::three_way_comparable"); pub fn test_4() { diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index c975d5b36e..3d3d0ad75e 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -54,179 +54,112 @@ impl p1_defaulted_three_way_Version { } } impl Cpp17EqualityComparableUnsafe for p1_defaulted_three_way_Version { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write( - (unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return (unsafe { - p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + (unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write( - !(unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return !(unsafe { - p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + !(unsafe { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write(libcc2rs::is_lt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return libcc2rs::is_lt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write(libcc2rs::is_lt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return libcc2rs::is_lt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write(libcc2rs::is_gt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return libcc2rs::is_gt( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write(libcc2rs::is_lteq( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return libcc2rs::is_lteq( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - __return.write(libcc2rs::is_gteq( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return libcc2rs::is_gteq( - (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_defaulted_three_way_Version, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p1_defaulted_three_way_Version { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_defaulted_three_way_Version); - let __rhs = (__rhs.as_ptr() as *const p1_defaulted_three_way_Version); - return (unsafe { - p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + (unsafe { p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -307,179 +240,112 @@ impl p1_user_written_three_way_Money { } } impl Cpp17EqualityComparableUnsafe for p1_user_written_three_way_Money { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write( - (unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return (unsafe { - p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + (unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write( - !(unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return !(unsafe { - p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + !(unsafe { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl LessThanComparableUnsafe for p1_user_written_three_way_Money { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write(libcc2rs::is_lt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return libcc2rs::is_lt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write(libcc2rs::is_lt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return libcc2rs::is_lt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write(libcc2rs::is_gt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return libcc2rs::is_gt( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write(libcc2rs::is_lteq( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return libcc2rs::is_lteq( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - __return.write(libcc2rs::is_gteq( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return libcc2rs::is_gteq( - (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_user_written_three_way_Money, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p1_user_written_three_way_Money { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_user_written_three_way_Money); - let __rhs = (__rhs.as_ptr() as *const p1_user_written_three_way_Money); - return (unsafe { - p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + (unsafe { p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); pub unsafe fn test_2() { @@ -546,179 +412,112 @@ impl p1_weaker_category_Temperature { } } impl Cpp17EqualityComparableUnsafe for p1_weaker_category_Temperature { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write( - (unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return (unsafe { - p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + (unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write( - !(unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return !(unsafe { - p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + !(unsafe { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }) + } + ); } impl LessThanComparableUnsafe for p1_weaker_category_Temperature { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write(libcc2rs::is_lt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return libcc2rs::is_lt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write(libcc2rs::is_lt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return libcc2rs::is_lt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write(libcc2rs::is_gt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return libcc2rs::is_gt( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write(libcc2rs::is_lteq( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return libcc2rs::is_lteq( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - __return.write(libcc2rs::is_gteq( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return libcc2rs::is_gteq( - (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_weaker_category_Temperature, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl ThreeWayComparableUnsafe for p1_weaker_category_Temperature { - type Category = libcc2rs::PartialOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const p1_weaker_category_Temperature); - let __rhs = (__rhs.as_ptr() as *const p1_weaker_category_Temperature); - return (unsafe { - p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) - }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::PartialOrdering, + |__lhs, __rhs| { + (unsafe { p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) }) + } + ); } const _: () = assert!(true, "std::three_way_comparable"); const _: () = assert!( @@ -768,138 +567,78 @@ impl p1_three_way_without_equality_Rank { } } impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - return libcc2rs::is_lt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - __return.write(libcc2rs::is_lt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - return libcc2rs::is_lt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - __return.write(libcc2rs::is_gt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - return libcc2rs::is_gt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - __return.write(libcc2rs::is_lteq( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - return libcc2rs::is_lteq( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - __return.write(libcc2rs::is_gteq( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const p1_three_way_without_equality_Rank); - let __rhs = (__rhs.as_ptr() as *const p1_three_way_without_equality_Rank); - return libcc2rs::is_gteq( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + p1_three_way_without_equality_Rank, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) + }), + ) + } + ); } const _: () = assert!(!(false), "!std::three_way_comparable"); pub unsafe fn test_4() { diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 7ea2b49730..ee6db7df92 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -115,21 +115,14 @@ impl Counter { } } impl Cpp17EqualityComparable for Counter { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Counter::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Counter::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Counter, + |__lhs, __rhs| { ({ Counter::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index 1fc640821a..ce938caf51 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -31,21 +31,14 @@ impl P { } } impl Cpp17EqualityComparable for P { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ P::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ P::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + P, + |__lhs, __rhs| { ({ P::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/friend.rs b/tests/unit/out/refcount/friend.rs index cea1c7a61e..e0728e7d98 100644 --- a/tests/unit/out/refcount/friend.rs +++ b/tests/unit/out/refcount/friend.rs @@ -38,21 +38,14 @@ pub struct V { pub x: i32, } impl Cpp17EqualityComparable for V { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + V, + |__lhs, __rhs| { ({ operator_eq_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn get_4(w: Ptr) -> i32 { return w.with(|__s| __s.x); diff --git a/tests/unit/out/refcount/map_key_copy_ctor.rs b/tests/unit/out/refcount/map_key_copy_ctor.rs index 1e178b2f40..b343ed6a3f 100644 --- a/tests/unit/out/refcount/map_key_copy_ctor.rs +++ b/tests/unit/out/refcount/map_key_copy_ctor.rs @@ -46,21 +46,14 @@ impl Key { } } impl LessThanComparable for Key { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Key::operator_lt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Key::operator_lt((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Key, + |__lhs, __rhs| { ({ Key::operator_lt((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn make_key_3(__return: Ptr, mut k: i32) { (*made_2.with(Value::clone).borrow_mut()).prefix_inc(); diff --git a/tests/unit/out/refcount/map_key_identity.rs b/tests/unit/out/refcount/map_key_identity.rs index ec33f866fc..653d98989c 100644 --- a/tests/unit/out/refcount/map_key_identity.rs +++ b/tests/unit/out/refcount/map_key_identity.rs @@ -31,38 +31,24 @@ pub struct Key { pub identity: i32, } impl Cpp17EqualityComparable for Key { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Key, + |__lhs, __rhs| { ({ operator_eq_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Key { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Key, + |__lhs, __rhs| { ({ operator_lt_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_2(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.order) } < { b.with(|__s| __s.order) }); diff --git a/tests/unit/out/refcount/max.rs b/tests/unit/out/refcount/max.rs index 0fe690bb5d..953c1d18d2 100644 --- a/tests/unit/out/refcount/max.rs +++ b/tests/unit/out/refcount/max.rs @@ -53,21 +53,14 @@ impl Bag { } } impl LessThanComparable for Bag { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Bag, + |__lhs, __rhs| { ({ operator_lt_4((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_4(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.n) } < { b.with(|__s| __s.n) }); diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index ec928dbe2b..55f7b6bfcb 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -34,38 +34,24 @@ impl Eq { } } impl Cpp17EqualityComparable for Eq { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Eq, + |__lhs, __rhs| { ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Eq { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Eq, + |__lhs, __rhs| { !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -116,135 +102,86 @@ impl Cmp { } } impl Cpp17EqualityComparable for Cmp { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Cmp, + |__lhs, __rhs| { ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Cmp { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Cmp, + |__lhs, __rhs| { !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Cmp { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for Cmp { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for Cmp { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -283,135 +220,86 @@ impl Both { } } impl Cpp17EqualityComparable for Both { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Both, + |__lhs, __rhs| { ({ Both::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Both { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Both::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Both, + |__lhs, __rhs| { !({ Both::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Both { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for Both { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for Both { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Both::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -447,96 +335,58 @@ impl OrdOnly { } } impl LessThanComparable for OrdOnly { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for OrdOnly { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_gt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } #[derive( Copy, @@ -575,135 +425,86 @@ impl Inner { } } impl Cpp17EqualityComparable for Inner { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Inner, + |__lhs, __rhs| { ({ Inner::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Inner { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Inner::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Inner, + |__lhs, __rhs| { !({ Inner::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Inner { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for Inner { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for Inner { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -754,135 +555,86 @@ impl Outer { } } impl Cpp17EqualityComparable for Outer { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Outer, + |__lhs, __rhs| { ({ Outer::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Outer { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Outer::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Outer, + |__lhs, __rhs| { !({ Outer::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Outer { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for Outer { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for Outer { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -930,141 +682,80 @@ impl Secondary { } } impl Cpp17EqualityComparable for Secondary { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Secondary, + |__lhs, __rhs| { ({ Secondary::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Secondary { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Secondary, + |__lhs, __rhs| { ({ Secondary::operator_ne((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Secondary { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Secondary, + |__lhs, __rhs| { ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl PartiallyOrderedWith for Secondary { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone()) }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone()) })); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Secondary, + |__lhs, __rhs| { ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Secondary, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Secondary, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Secondary, + |__lhs, __rhs| { ({ Secondary::operator_ge((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl ThreeWayComparable for Secondary { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Secondary::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Clone, @@ -1105,147 +796,86 @@ impl PtrMember { } } impl Cpp17EqualityComparable for PtrMember { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + PtrMember, + |__lhs, __rhs| { ({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for PtrMember { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + PtrMember, + |__lhs, __rhs| { !({ PtrMember::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for PtrMember { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for PtrMember { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_gt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for PtrMember { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 9fe5a9ec94..00de564f9e 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -26,113 +26,68 @@ pub struct S { pub v: i32, } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ne_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl PartiallyOrderedWith for S { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_2((__lhs).clone(), (__rhs).clone()) }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_gt_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_gt_3((__lhs).clone(), (__rhs).clone()) }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_le_4((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_le_4((__lhs).clone(), (__rhs).clone()) }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ge_5((__lhs).clone(), (__rhs).clone()) })); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ge_5((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { ({ operator_gt_3((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_le_4((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ge_5((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_eq_0(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); @@ -178,81 +133,52 @@ pub struct V { pub v: i32, } impl Cpp17EqualityComparable for V { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + V, + |__lhs, __rhs| { ({ operator_eq_8({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - operator_eq_8({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) }) - }); - } + } + ); } impl WeaklyEqualityComparableWith for V { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + V, + |__lhs, __rhs| { ({ operator_ne_9({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - operator_ne_9({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) }) - }); - } + } + ); } impl LessThanComparable for V { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + V, + |__lhs, __rhs| { ({ operator_lt_10({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - operator_lt_10({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) }) - }); - } + } + ); } pub fn operator_eq_8(mut a: V, mut b: V) -> bool { return (a.v == b.v); diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index 31b4fe984f..933b683cb8 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -49,113 +49,68 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_ne((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_ne((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_ne((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl PartiallyOrderedWith for S { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone()) }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_gt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_gt((__lhs).clone(), (__rhs).clone()) }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_le((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_le((__lhs).clone(), (__rhs).clone()) }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_ge((__lhs).clone(), (__rhs).clone()) })); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_ge((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_gt((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_le((__lhs).clone(), (__rhs).clone(),) }) } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_ge((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 40c667f66d..943927012d 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -46,208 +46,124 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq((__lhs).clone(), (__rhs.read())) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq((__lhs).clone(), (__rhs.read())) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { ({ S::operator_eq((__lhs).clone(), (__rhs.read()),) }) } + ); } impl Cpp17EqualityComparable for i32 { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs.read()), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs.read()), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0((__lhs.read()), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_ne((__lhs).clone(), (__rhs.read())) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_ne((__lhs).clone(), (__rhs.read())) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { ({ S::operator_ne((__lhs).clone(), (__rhs.read()),) }) } + ); } impl WeaklyEqualityComparableWith for i32 { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_1((__lhs.read()), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_1((__lhs.read()), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ne_1((__lhs.read()), (__rhs).clone(),) }) } + ); } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + f64, + |__lhs, __rhs| { ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); } impl Cpp17EqualityComparable for f64 { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + f64, + |__lhs, __rhs| { ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); } impl WeaklyEqualityComparableWith for f64 { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32)) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + i64, + |__lhs, __rhs| { ({ S::operator_eq((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); } impl Cpp17EqualityComparable for i64 { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32)) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + i64, + |__lhs, __rhs| { ({ S::operator_ne((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); } impl WeaklyEqualityComparableWith for i64 { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); } pub fn operator_eq_0(mut a: i32, b: Ptr) -> bool { return ({ a } == { b.with(|__s| __s.v) }); diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index 3b1c55c9a0..cb53da6855 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -26,183 +26,173 @@ pub struct X { pub v: i32, } impl Cpp17EqualityComparable for X { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_eq_0({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_eq_0({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_eq_0({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } + }) != 0) + } + ); } impl WeaklyEqualityComparableWith for X { - type NotEqualResult = i32; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_ne_1({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_ne_1({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_ne_1({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } + }) != 0) + } + ); } impl LessThanComparable for X { - type Result = i32; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + comparison!( + LessThanComparable, + less, + is_less, + Result = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_lt_2({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_lt_2({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } + }) != 0) + } + ); } impl PartiallyOrderedWith for X { - type LessResult = i32; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_lt_2({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_lt_2({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_lt_2({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } - type GreaterResult = i32; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + }) != 0) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_gt_3({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_gt_3({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_gt_3({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } - type LessEqualResult = i32; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + }) != 0) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_le_4({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_le_4({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_le_4({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } - type GreaterEqualResult = i32; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ + }) != 0) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_ge_5({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { + (({ operator_ge_5({ (*__lhs.upgrade().deref()) }, { (*__rhs.upgrade().deref()) }) - }), - ); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ - operator_ge_5({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0); - } + }) != 0) + } + ); } pub fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if (a.v == b.v) { 2 } else { 0 }; @@ -308,38 +298,30 @@ impl Mixed { } } impl Cpp17EqualityComparable for Mixed { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + Mixed, + |__return, __lhs, __rhs| { + __return.write(({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone()) })); + }, + |__lhs, __rhs| { (({ Mixed::operator_eq((__lhs).clone(), (__rhs).clone(),) }) != 0) } + ); } impl LessThanComparable for Mixed { - type Result = i32; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) }) != 0); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = i32, + Mixed, + |__return, __lhs, __rhs| { + __return.write(({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone()) })); + }, + |__lhs, __rhs| { (({ Mixed::operator_lt((__lhs).clone(), (__rhs).clone(),) }) != 0) } + ); } #[derive( Copy, @@ -371,173 +353,109 @@ impl MyBool { } } impl Cpp17EqualityComparable for MyBool { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } == { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } == { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for MyBool { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } != { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } != { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl LessThanComparable for MyBool { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl PartiallyOrderedWith for MyBool { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } > { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } > { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } <= { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } <= { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + MyBool, + |__lhs, __rhs| { ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } >= { (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } >= { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl ThreeWayComparable for MyBool { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &(({ MyBool::to_bool((__lhs).clone()) }) as i32), - &(({ MyBool::to_bool((__rhs).clone()) }) as i32), - )); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ MyBool::to_bool((__lhs).clone()) }) as i32), + &(({ MyBool::to_bool((__rhs).clone()) }) as i32), + )) + } + ); } #[derive( Copy, @@ -559,72 +477,68 @@ pub struct Boolish { pub v: i32, } impl Cpp17EqualityComparable for Boolish { - type EqualResult = MyBool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = MyBool, + Boolish, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_eq_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { ({ - operator_eq_6({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - MyBool::to_bool( - Rc::new(RefCell::new( - ({ - operator_eq_6({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }), - )) - .as_pointer(), - ) - }); - } + MyBool::to_bool( + Rc::new(RefCell::new( + ({ + operator_eq_6({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + )) + .as_pointer(), + ) + }) + } + ); } impl LessThanComparable for Boolish { - type Result = MyBool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = MyBool, + Boolish, + |__return, __lhs, __rhs| { + __return.write( + ({ + operator_lt_7({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + ); + }, + |__lhs, __rhs| { ({ - operator_lt_7({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ - MyBool::to_bool( - Rc::new(RefCell::new( - ({ - operator_lt_7({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }), - )) - .as_pointer(), - ) - }); - } + MyBool::to_bool( + Rc::new(RefCell::new( + ({ + operator_lt_7({ (*__lhs.upgrade().deref()) }, { + (*__rhs.upgrade().deref()) + }) + }), + )) + .as_pointer(), + ) + }) + } + ); } pub fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { @@ -668,176 +582,109 @@ impl RefBool { } } impl Cpp17EqualityComparable for RefBool { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } == { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } == { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for RefBool { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } != { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } != { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl LessThanComparable for RefBool { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl PartiallyOrderedWith for RefBool { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } > { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } > { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } <= { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } <= { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + RefBool, + |__lhs, __rhs| { ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } >= { (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } >= { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }); - } + }) + } + ); } impl ThreeWayComparable for RefBool { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &(({ RefBool::to_bool((__lhs).clone()) }) as i32), - &(({ RefBool::to_bool((__rhs).clone()) }) as i32), - )); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &(({ RefBool::to_bool((__lhs).clone()) }) as i32), + &(({ RefBool::to_bool((__rhs).clone()) }) as i32), + )) + } + ); } thread_local!( pub static ref_true_8: Value = Rc::new(RefCell::new({ @@ -871,23 +718,8 @@ impl RefInt { } } impl Cpp17EqualityComparable for RefInt { - type EqualResult = LvalueRef; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(LvalueRef::bind( - ({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ RefBool::to_bool(({ RefInt::operator_eq((__lhs).clone(), (__rhs).clone()) })) }); - } + comparison! ( Cpp17EqualityComparable , equal , is_equal , EqualResult = LvalueRef , RefInt , |__return, __lhs, __rhs| { __return .write ( LvalueRef ::bind ( ( { RefInt :: operator_eq ( (__lhs ).clone() , (__rhs ).clone() , ) } ) ) ) ; +} , |__lhs, __rhs| { ( { RefBool :: to_bool ( ( { RefInt :: operator_eq ( (__lhs ).clone() , (__rhs ).clone() , ) } ) , ) } ) } ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_comparison_noncopyable.rs b/tests/unit/out/refcount/operator_comparison_noncopyable.rs index 2d66f6d27a..76527d7433 100644 --- a/tests/unit/out/refcount/operator_comparison_noncopyable.rs +++ b/tests/unit/out/refcount/operator_comparison_noncopyable.rs @@ -30,34 +30,24 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 7e96a52819..5b150edcd8 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -32,41 +32,24 @@ pub struct Defaulted { pub b: i32, } impl Cpp17EqualityComparable for Defaulted { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Defaulted, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Defaulted { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Defaulted, + |__lhs, __rhs| { !({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_cmp_1(_a0: Ptr, _a1: Ptr) -> libcc2rs::StrongOrdering { { @@ -103,159 +86,80 @@ pub struct DefaultedOrd { pub a: i32, } impl Cpp17EqualityComparable for DefaultedOrd { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { ({ operator_eq_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for DefaultedOrd { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { !({ operator_eq_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for DefaultedOrd { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + DefaultedOrd, + |__lhs, __rhs| { libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone(),) })) } + ); } impl PartiallyOrderedWith for DefaultedOrd { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + DefaultedOrd, + |__lhs, __rhs| { libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone(),) })) } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + DefaultedOrd, + |__lhs, __rhs| { libcc2rs::is_gt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone(),) })) } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for DefaultedOrd { - type Category = libcc2rs::StrongOrdering; - fn three_way( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_cmp_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ operator_cmp_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_eq_3(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); @@ -288,55 +192,34 @@ pub struct Inline { pub a: i32, } impl Cpp17EqualityComparable for Inline { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Inline, + |__lhs, __rhs| { ({ operator_eq_3((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Inline { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_3((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Inline, + |__lhs, __rhs| { !({ operator_eq_3((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Inline { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_4((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_4((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Inline, + |__lhs, __rhs| { ({ operator_lt_4((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -358,41 +241,24 @@ pub struct OutOfLine { pub a: i32, } impl Cpp17EqualityComparable for OutOfLine { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_6((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_6((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + OutOfLine, + |__lhs, __rhs| { ({ operator_eq_6((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for OutOfLine { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_ne_7((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_ne_7((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + OutOfLine, + |__lhs, __rhs| { ({ operator_ne_7((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_eq_6(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.a) } == { y.with(|__s| __s.a) }); @@ -429,58 +295,34 @@ pub struct Tmpl_int_ { pub v: i32, } impl Cpp17EqualityComparable for Tmpl_int_ { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_8((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Tmpl_int_, + |__lhs, __rhs| { ({ operator_eq_8((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Tmpl_int_ { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_8((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_8((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Tmpl_int_, + |__lhs, __rhs| { !({ operator_eq_8((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Tmpl_int_ { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_9((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_9((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Tmpl_int_, + |__lhs, __rhs| { ({ operator_lt_9((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_eq_11(x: Ptr, y: Ptr) -> bool { return ({ x.with(|__s| __s.v) } == { y.with(|__s| __s.v) }); @@ -508,58 +350,34 @@ pub struct Tmpl_long_ { pub v: i64, } impl Cpp17EqualityComparable for Tmpl_long_ { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_11((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Tmpl_long_, + |__lhs, __rhs| { ({ operator_eq_11((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Tmpl_long_ { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_11((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_11((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Tmpl_long_, + |__lhs, __rhs| { !({ operator_eq_11((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Tmpl_long_ { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_12((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_12((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Tmpl_long_, + |__lhs, __rhs| { ({ operator_lt_12((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_eq_13(_a0: Ptr, _a1: Ptr) -> bool { return ({ _a0.with(|__s| __s.v) } == { _a1.with(|__s| __s.v) }); @@ -584,44 +402,24 @@ pub struct TmplDefaulted_int_ { pub v: i32, } impl Cpp17EqualityComparable for TmplDefaulted_int_ { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_13((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + TmplDefaulted_int_, + |__lhs, __rhs| { ({ operator_eq_13((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for TmplDefaulted_int_ { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_13((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_13((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + TmplDefaulted_int_, + |__lhs, __rhs| { !({ operator_eq_13((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index d5334fcf02..4f619f116f 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -71,120 +71,82 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } == { ({ S::to_i32((__rhs).clone()) }) }) + } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } != { ({ S::to_i32((__rhs).clone()) }) }) + } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }) + } + ); } impl PartiallyOrderedWith for S { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return - .write(({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) })); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) }); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } > { ({ S::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } <= { ({ S::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { + ({ ({ S::to_i32((__lhs).clone()) }) } >= { ({ S::to_i32((__rhs).clone()) }) }) + } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_overloads.rs b/tests/unit/out/refcount/operator_overloads.rs index 8aeb5da3b0..ad33f3a694 100644 --- a/tests/unit/out/refcount/operator_overloads.rs +++ b/tests/unit/out/refcount/operator_overloads.rs @@ -57,89 +57,71 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + i32, + |__return, __lhs, __rhs| { + __return.write(({ S::operator_eq_1((__lhs).clone(), (__rhs.read())) })); + }, + |__lhs, __rhs| { (({ S::operator_eq_1((__lhs).clone(), (__rhs.read()),) }) != 0) } + ); } impl Cpp17EqualityComparable for i32 { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + S, + |__return, __lhs, __rhs| { + __return.write(({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) })); + }, + |__lhs, __rhs| { + (({ operator_eq_0((__lhs.read()), { (*__rhs.upgrade().deref()) }) }) != 0) + } + ); } impl Cpp17EqualityComparable for S { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + i64, + |__return, __lhs, __rhs| { + __return.write(({ S::operator_eq_2((__lhs).clone(), (__rhs.read())) })); + }, + |__lhs, __rhs| { (({ S::operator_eq_2((__lhs).clone(), (__rhs.read()),) }) != 0) } + ); } impl Cpp17EqualityComparable for i64 { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_1((__lhs.read()), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ operator_eq_1((__lhs.read()), (__rhs).clone()) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + S, + |__return, __lhs, __rhs| { + __return.write(({ operator_eq_1((__lhs.read()), (__rhs).clone()) })); + }, + |__lhs, __rhs| { (({ operator_eq_1((__lhs.read()), (__rhs).clone(),) }) != 0) } + ); } impl Cpp17EqualityComparable for S { - type EqualResult = i32; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return (({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) }) != 0); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = i32, + f64, + |__return, __lhs, __rhs| { + __return.write(({ S::operator_eq_3((__lhs).clone(), (__rhs.read())) })); + }, + |__lhs, __rhs| { (({ S::operator_eq_3((__lhs).clone(), (__rhs.read()),) }) != 0) } + ); } pub fn operator_div_2(a: Ptr, b: Ptr) -> i32 { return ({ a.with(|__s| __s.v) } / { b.with(|__s| __s.v) }); diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 31fa4148ee..72d01074f1 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -40,131 +40,86 @@ impl S { } } impl Cpp17EqualityComparable for S { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ({ S::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for S { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ S::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ S::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { !({ S::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for S { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for S { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_gt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for S { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ S::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index 284302d678..f224c1efb6 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -31,17 +31,14 @@ impl Lt { } } impl LessThanComparable for Lt { - type Result = bool; - fn less(__return: Ptr, __lhs: LvalueRef>, __rhs: LvalueRef>) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Lt::operator_lt((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Lt::operator_lt((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Lt, + |__lhs, __rhs| { ({ Lt::operator_lt((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -68,38 +65,24 @@ impl Eq { } } impl Cpp17EqualityComparable for Eq { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Eq, + |__lhs, __rhs| { ({ Eq::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Eq { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Eq, + |__lhs, __rhs| { !({ Eq::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -132,135 +115,86 @@ impl Cmp { } } impl Cpp17EqualityComparable for Cmp { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Cmp, + |__lhs, __rhs| { ({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Cmp { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Cmp, + |__lhs, __rhs| { !({ Cmp::operator_eq((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Cmp { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl PartiallyOrderedWith for Cmp { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gt( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_lteq( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(libcc2rs::is_gteq( - ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }), - )); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gteq(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) + } + ); } impl ThreeWayComparable for Cmp { - type Category = libcc2rs::StrongOrdering; - fn three_way(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::Category { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + ThreeWayComparable, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { ({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone(),) }) } + ); } #[derive( Copy, @@ -282,55 +216,34 @@ pub struct Free { pub v: i32, } impl Cpp17EqualityComparable for Free { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Free, + |__lhs, __rhs| { ({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Free { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_0((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Free, + |__lhs, __rhs| { !({ operator_eq_0((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Free { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Free, + |__lhs, __rhs| { ({ operator_lt_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_1(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); @@ -364,64 +277,34 @@ pub struct Wrapped_int_ { pub v: i32, } impl Cpp17EqualityComparable for Wrapped_int_ { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Wrapped_int_, + |__lhs, __rhs| { ({ operator_eq_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl WeaklyEqualityComparableWith for Wrapped_int_ { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(!({ operator_eq_2((__lhs).clone(), (__rhs).clone()) })); - } - fn is_not_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return !({ operator_eq_2((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Wrapped_int_, + |__lhs, __rhs| { !({ operator_eq_2((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Wrapped_int_ { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Wrapped_int_, + |__lhs, __rhs| { ({ operator_lt_3((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index 8b9e71a135..46069179fa 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -57,153 +57,82 @@ impl Meters { } } impl Cpp17EqualityComparable for Meters { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } == { - ({ Meters::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } == { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } == { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); } impl WeaklyEqualityComparableWith for Meters { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } != { - ({ Meters::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } != { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } != { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); } impl LessThanComparable for Meters { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); } impl PartiallyOrderedWith for Meters { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } < { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } > { ({ Meters::to_i32((__rhs).clone()) }) }), - ); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } > { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { - ({ Meters::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( - ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { - ({ Meters::to_i32((__rhs).clone()) }) - }), - ); - } - fn is_greater_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { - ({ Meters::to_i32((__rhs).clone()) }) - }); - } + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } > { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } <= { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Meters, + |__lhs, __rhs| { + ({ ({ Meters::to_i32((__lhs).clone()) }) } >= { ({ Meters::to_i32((__rhs).clone()) }) }) + } + ); } #[derive( Copy, diff --git a/tests/unit/out/refcount/sort_no_copy.rs b/tests/unit/out/refcount/sort_no_copy.rs index ff39be106d..203e861dfd 100644 --- a/tests/unit/out/refcount/sort_no_copy.rs +++ b/tests/unit/out/refcount/sort_no_copy.rs @@ -53,21 +53,14 @@ impl MoveAssignable for Tracked { } } impl LessThanComparable for Tracked { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_1((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_1((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Tracked, + |__lhs, __rhs| { ({ operator_lt_1((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl Default for Tracked { fn default() -> Self { @@ -111,21 +104,14 @@ impl MoveOnly { } } impl LessThanComparable for MoveOnly { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_3((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_3((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + MoveOnly, + |__lhs, __rhs| { ({ operator_lt_3((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_3(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } < { b.with(|__s| __s.v) }); @@ -149,38 +135,24 @@ impl Bag { } } impl Cpp17EqualityComparable for Bag { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_eq_4((__lhs).clone(), (__rhs).clone()) })); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_eq_4((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Bag, + |__lhs, __rhs| { ({ operator_eq_4((__lhs).clone(), (__rhs).clone(),) }) } + ); } impl LessThanComparable for Bag { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write(({ operator_lt_5((__lhs).clone(), (__rhs).clone()) })); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ operator_lt_5((__lhs).clone(), (__rhs).clone()) }); - } + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Bag, + |__lhs, __rhs| { ({ operator_lt_5((__lhs).clone(), (__rhs).clone(),) }) } + ); } pub fn operator_lt_5(a: Ptr, b: Ptr) -> bool { return ({ (*a.upgrade().deref()).items.len() } < { (*b.upgrade().deref()).items.len() }); diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 72b0306d5a..845697ca66 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -57,162 +57,96 @@ impl Reading { } } impl Cpp17EqualityComparable for Reading { - type EqualResult = bool; - fn equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + Cpp17EqualityComparable, + equal, + is_equal, + EqualResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } == { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } == { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWith for Reading { - type NotEqualResult = bool; - fn not_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + WeaklyEqualityComparableWith, + not_equal, + is_not_equal, + NotEqualResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } != { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } != { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } + }) + } + ); } impl LessThanComparable for Reading { - type Result = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } < { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } + }) + } + ); } impl PartiallyOrderedWith for Reading { - type LessResult = bool; - fn less( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + comparison!( + PartiallyOrderedWith, + less, + is_less, + LessResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } < { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_less(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } < { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } - type GreaterResult = bool; - fn greater( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater, + is_greater, + GreaterResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } > { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_greater(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } > { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } - type LessEqualResult = bool; - fn less_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + less_equal, + is_less_equal, + LessEqualResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } <= { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_less_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } <= { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } - type GreaterEqualResult = bool; - fn greater_equal( - __return: Ptr, - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - __return.write( + }) + } + ); + comparison!( + PartiallyOrderedWith, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Reading, + |__lhs, __rhs| { ({ ({ Reading::to_i64((__lhs).clone()) }) } >= { ({ Reading::to_i64((__rhs).clone()) }) - }), - ); - } - fn is_greater_equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> bool { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ ({ Reading::to_i64((__lhs).clone()) }) } >= { - ({ Reading::to_i64((__rhs).clone()) }) - }); - } + }) + } + ); } pub fn main() { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/class.rs b/tests/unit/out/unsafe/class.rs index 36d165a26e..3e349c30cd 100644 --- a/tests/unit/out/unsafe/class.rs +++ b/tests/unit/out/unsafe/class.rs @@ -104,24 +104,14 @@ impl Counter { } } impl Cpp17EqualityComparableUnsafe for Counter { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Counter); - let __rhs = (__rhs.as_ptr() as *const Counter); - __return.write((unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Counter); - let __rhs = (__rhs.as_ptr() as *const Counter); - return (unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Counter, + |__lhs, __rhs| { (unsafe { Counter::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( diff --git a/tests/unit/out/unsafe/find.rs b/tests/unit/out/unsafe/find.rs index 2754b6c1ed..9e536af4fe 100644 --- a/tests/unit/out/unsafe/find.rs +++ b/tests/unit/out/unsafe/find.rs @@ -28,21 +28,14 @@ impl P { } } impl Cpp17EqualityComparableUnsafe for P { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const P); - let __rhs = (__rhs.as_ptr() as *const P); - __return.write((unsafe { P::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const P); - let __rhs = (__rhs.as_ptr() as *const P); - return (unsafe { P::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + P, + |__lhs, __rhs| { (unsafe { P::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/friend.rs b/tests/unit/out/unsafe/friend.rs index 89deb42c78..d919d2095c 100644 --- a/tests/unit/out/unsafe/friend.rs +++ b/tests/unit/out/unsafe/friend.rs @@ -35,29 +35,19 @@ pub struct V { pub x: i32, } impl Cpp17EqualityComparableUnsafe for V { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + V, + |__lhs, __rhs| { (unsafe { let _a: *const V = __lhs; operator_eq_1(_a, __rhs) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - return (unsafe { - let _a: *const V = __lhs; - operator_eq_1(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn get_4(w: *const W_int_) -> i32 { return (*w).x; diff --git a/tests/unit/out/unsafe/map_key_copy_ctor.rs b/tests/unit/out/unsafe/map_key_copy_ctor.rs index 33a054dfcc..4de8741ccc 100644 --- a/tests/unit/out/unsafe/map_key_copy_ctor.rs +++ b/tests/unit/out/unsafe/map_key_copy_ctor.rs @@ -39,24 +39,14 @@ impl Key { } } impl LessThanComparableUnsafe for Key { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - __return.write((unsafe { Key::operator_lt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - return (unsafe { Key::operator_lt(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Key, + |__lhs, __rhs| { (unsafe { Key::operator_lt(&raw const (*__lhs), __rhs,) }) } + ); } pub unsafe fn make_key_3(__return: *mut Key, mut k: i32) { (*std::cell::LazyCell::force_mut(&mut *&raw mut made_2)).prefix_inc(); diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index ae939ec3ff..581d49c8fa 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -26,60 +26,34 @@ pub struct Key { pub identity: i32, } impl Cpp17EqualityComparableUnsafe for Key { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Key, + |__lhs, __rhs| { (unsafe { let _a: *const Key = __lhs; operator_eq_1(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - return (unsafe { - let _a: *const Key = __lhs; - operator_eq_1(_a, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Key { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Key, + |__lhs, __rhs| { (unsafe { let _a: *const Key = __lhs; operator_lt_2(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Key); - let __rhs = (__rhs.as_ptr() as *const Key); - return (unsafe { - let _a: *const Key = __lhs; - operator_lt_2(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_2(a: *const Key, b: *const Key) -> bool { return (((*a).order) < ((*b).order)); diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 89a413dddb..efbaf63a08 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -46,32 +46,19 @@ impl Bag { } } impl LessThanComparableUnsafe for Bag { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Bag, + |__lhs, __rhs| { (unsafe { let _a: *const Bag = __lhs; operator_lt_4(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - return (unsafe { - let _a: *const Bag = __lhs; - operator_lt_4(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_4(a: *const Bag, b: *const Bag) -> bool { return (((*a).n) < ((*b).n)); diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index e8630573ba..c3f403e865 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -29,44 +29,24 @@ impl Eq { } } impl Cpp17EqualityComparableUnsafe for Eq { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - __return.write((unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Eq, + |__lhs, __rhs| { (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Eq { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - __return.write(!(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Eq, + |__lhs, __rhs| { !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -108,159 +88,86 @@ impl Cmp { } } impl Cpp17EqualityComparableUnsafe for Cmp { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write((unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Cmp, + |__lhs, __rhs| { (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Cmp { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(!(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Cmp, + |__lhs, __rhs| { !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Cmp { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for Cmp { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_gt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lteq( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_gteq( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for Cmp { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -294,159 +201,86 @@ impl Both { } } impl Cpp17EqualityComparableUnsafe for Both { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write((unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return (unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Both, + |__lhs, __rhs| { (unsafe { Both::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Both { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(!(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return !(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Both, + |__lhs, __rhs| { !(unsafe { Both::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Both { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(libcc2rs::is_lt( - (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for Both { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(libcc2rs::is_lt( - (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(libcc2rs::is_gt( - (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return libcc2rs::is_gt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(libcc2rs::is_lteq( - (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return libcc2rs::is_lteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - __return.write(libcc2rs::is_gteq( - (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return libcc2rs::is_gteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Both, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for Both { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Both); - let __rhs = (__rhs.as_ptr() as *const Both); - return (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -477,108 +311,58 @@ impl OrdOnly { } } impl LessThanComparableUnsafe for OrdOnly { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - __return.write(libcc2rs::is_lt( - (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for OrdOnly { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - __return.write(libcc2rs::is_lt( - (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - return libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - __return.write(libcc2rs::is_gt( - (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - return libcc2rs::is_gt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - __return.write(libcc2rs::is_lteq( - (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - return libcc2rs::is_lteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - __return.write(libcc2rs::is_gteq( - (unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OrdOnly); - let __rhs = (__rhs.as_ptr() as *const OrdOnly); - return libcc2rs::is_gteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + OrdOnly, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } #[repr(C)] #[derive( @@ -612,159 +396,86 @@ impl Inner { } } impl Cpp17EqualityComparableUnsafe for Inner { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write((unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return (unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Inner, + |__lhs, __rhs| { (unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Inner { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(!(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return !(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Inner, + |__lhs, __rhs| { !(unsafe { Inner::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Inner { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(libcc2rs::is_lt( - (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for Inner { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(libcc2rs::is_lt( - (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(libcc2rs::is_gt( - (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return libcc2rs::is_gt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(libcc2rs::is_lteq( - (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return libcc2rs::is_lteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - __return.write(libcc2rs::is_gteq( - (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return libcc2rs::is_gteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Inner, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for Inner { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Inner); - let __rhs = (__rhs.as_ptr() as *const Inner); - return (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -811,159 +522,86 @@ impl Outer { } } impl Cpp17EqualityComparableUnsafe for Outer { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write((unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return (unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Outer, + |__lhs, __rhs| { (unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Outer { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(!(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return !(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Outer, + |__lhs, __rhs| { !(unsafe { Outer::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Outer { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(libcc2rs::is_lt( - (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for Outer { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(libcc2rs::is_lt( - (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(libcc2rs::is_gt( - (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return libcc2rs::is_gt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(libcc2rs::is_lteq( - (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return libcc2rs::is_lteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - __return.write(libcc2rs::is_gteq( - (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return libcc2rs::is_gteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Outer, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for Outer { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Outer); - let __rhs = (__rhs.as_ptr() as *const Outer); - return (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -1009,153 +647,80 @@ impl Secondary { } } impl Cpp17EqualityComparableUnsafe for Secondary { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write((unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Secondary, + |__lhs, __rhs| { (unsafe { Secondary::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Secondary { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write((unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Secondary, + |__lhs, __rhs| { (unsafe { Secondary::operator_ne(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Secondary { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write((unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Secondary, + |__lhs, __rhs| { (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs,) }) } + ); } impl PartiallyOrderedWithUnsafe for Secondary { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write((unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs) }); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write(libcc2rs::is_gt( - (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return libcc2rs::is_gt((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write(libcc2rs::is_lteq( - (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return libcc2rs::is_lteq((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - __return.write((unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Secondary, + |__lhs, __rhs| { (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs,) }) } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Secondary, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Secondary, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Secondary, + |__lhs, __rhs| { (unsafe { Secondary::operator_ge(&raw const (*__lhs), __rhs,) }) } + ); } impl ThreeWayComparableUnsafe for Secondary { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Secondary); - let __rhs = (__rhs.as_ptr() as *const Secondary); - return (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Secondary::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -1192,159 +757,86 @@ impl PtrMember { } } impl Cpp17EqualityComparableUnsafe for PtrMember { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write((unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return (unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + PtrMember, + |__lhs, __rhs| { (unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for PtrMember { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(!(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return !(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + PtrMember, + |__lhs, __rhs| { !(unsafe { PtrMember::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for PtrMember { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(libcc2rs::is_lt( - (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for PtrMember { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(libcc2rs::is_lt( - (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(libcc2rs::is_gt( - (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return libcc2rs::is_gt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(libcc2rs::is_lteq( - (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return libcc2rs::is_lteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - __return.write(libcc2rs::is_gteq( - (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return libcc2rs::is_gteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + PtrMember, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for PtrMember { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const PtrMember); - let __rhs = (__rhs.as_ptr() as *const PtrMember); - return (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index 6f433a73fd..e8f9b45eed 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -23,185 +23,103 @@ pub struct S { pub v: i32, } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_ne_1(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_ne_1(_a, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_lt_2(_a, __rhs) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_lt_2(_a, __rhs) - }); - } + }) + } + ); } impl PartiallyOrderedWithUnsafe for S { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_lt_2(_a, __rhs) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_lt_2(_a, __rhs) - }); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_gt_3(_a, __rhs) - }), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_gt_3(_a, __rhs) - }); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_le_4(_a, __rhs) - }), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_le_4(_a, __rhs) - }); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + }) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: *const S = __lhs; operator_ge_5(_a, __rhs) - }), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: *const S = __lhs; - operator_ge_5(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_0(a: *const S, b: *const S) -> bool { return (((*a).v) == ((*b).v)); @@ -244,82 +162,49 @@ pub struct V { pub v: i32, } impl Cpp17EqualityComparableUnsafe for V { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + V, + |__lhs, __rhs| { (unsafe { let _a: V = (*__lhs); operator_eq_8(_a, (*__rhs)) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - return (unsafe { - let _a: V = (*__lhs); - operator_eq_8(_a, (*__rhs)) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for V { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + V, + |__lhs, __rhs| { (unsafe { let _a: V = (*__lhs); operator_ne_9(_a, (*__rhs)) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - return (unsafe { - let _a: V = (*__lhs); - operator_ne_9(_a, (*__rhs)) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for V { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + V, + |__lhs, __rhs| { (unsafe { let _a: V = (*__lhs); operator_lt_10(_a, (*__rhs)) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const V); - let __rhs = (__rhs.as_ptr() as *const V); - return (unsafe { - let _a: V = (*__lhs); - operator_lt_10(_a, (*__rhs)) - }); - } + }) + } + ); } pub unsafe fn operator_eq_8(mut a: V, mut b: V) -> bool { return ((a.v) == (b.v)); diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index c136fe694d..9f9afb2dbc 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -46,129 +46,68 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_ne(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_ne(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_ne(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs,) }) } + ); } impl PartiallyOrderedWithUnsafe for S { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs) }); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_gt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_gt(&raw const (*__lhs), __rhs) }); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_le(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_le(&raw const (*__lhs), __rhs) }); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_ge(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_ge(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs,) }) } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_gt(&raw const (*__lhs), __rhs,) }) } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_le(&raw const (*__lhs), __rhs,) }) } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_ge(&raw const (*__lhs), __rhs,) }) } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index 51dd25d18c..c396b38642 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -43,292 +43,154 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write((unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs)) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + i32, + |__lhs, __rhs| { (unsafe { S::operator_eq(&raw const (*__lhs), (*__rhs),) }) } + ); } impl Cpp17EqualityComparableUnsafe for i32 { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = (*__lhs); operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = (*__lhs); - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write((unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - return (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs)) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + i32, + |__lhs, __rhs| { (unsafe { S::operator_ne(&raw const (*__lhs), (*__rhs),) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for i32 { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = (*__lhs); operator_ne_1(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = (*__lhs); - operator_ne_1(_a, __rhs) - }); - } + }) + } + ); } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - __return.write((unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + f64, + |__lhs, __rhs| { (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); } impl Cpp17EqualityComparableUnsafe for f64 { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const f64); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = ((*__lhs) as i32); operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const f64); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = ((*__lhs) as i32); - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - __return.write((unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + f64, + |__lhs, __rhs| { (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for f64 { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const f64); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = ((*__lhs) as i32); operator_ne_1(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const f64); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = ((*__lhs) as i32); - operator_ne_1(_a, __rhs) - }); - } + }) + } + ); } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - __return.write((unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - return (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32)) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + i64, + |__lhs, __rhs| { (unsafe { S::operator_eq(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); } impl Cpp17EqualityComparableUnsafe for i64 { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = ((*__lhs) as i32); operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = ((*__lhs) as i32); - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - __return.write((unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - return (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32)) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + i64, + |__lhs, __rhs| { (unsafe { S::operator_ne(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for i64 { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _a: i32 = ((*__lhs) as i32); operator_ne_1(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _a: i32 = ((*__lhs) as i32); - operator_ne_1(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_0(mut a: i32, b: *const S) -> bool { return ((a) == ((*b).v)); diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index 2b53d9691b..3f93f0fe50 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -23,185 +23,159 @@ pub struct X { pub v: i32, } impl Cpp17EqualityComparableUnsafe for X { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_eq_0(_a, (*__rhs)) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_eq_0(_a, (*__rhs)) - }) != 0); - } + }) != 0) + } + ); } impl WeaklyEqualityComparableWithUnsafe for X { - type NotEqualResult = i32; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_ne_1(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_ne_1(_a, (*__rhs)) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_ne_1(_a, (*__rhs)) - }) != 0); - } + }) != 0) + } + ); } impl LessThanComparableUnsafe for X { - type Result = i32; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_lt_2(_a, (*__rhs)) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_lt_2(_a, (*__rhs)) - }) != 0); - } + }) != 0) + } + ); } impl PartiallyOrderedWithUnsafe for X { - type LessResult = i32; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_lt_2(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_lt_2(_a, (*__rhs)) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_lt_2(_a, (*__rhs)) - }) != 0); - } - type GreaterResult = i32; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + }) != 0) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_gt_3(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_gt_3(_a, (*__rhs)) - }), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_gt_3(_a, (*__rhs)) - }) != 0); - } - type LessEqualResult = i32; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + }) != 0) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_le_4(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_le_4(_a, (*__rhs)) - }), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_le_4(_a, (*__rhs)) - }) != 0); - } - type GreaterEqualResult = i32; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - __return.write( - (unsafe { + }) != 0) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = i32, + X, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: X = (*__lhs); + operator_ge_5(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: X = (*__lhs); operator_ge_5(_a, (*__rhs)) - }), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const X); - let __rhs = (__rhs.as_ptr() as *const X); - return ((unsafe { - let _a: X = (*__lhs); - operator_ge_5(_a, (*__rhs)) - }) != 0); - } + }) != 0) + } + ); } pub unsafe fn operator_eq_0(mut a: X, mut b: X) -> i32 { return if ((a.v) == (b.v)) { 2 } else { 0 }; @@ -290,44 +264,30 @@ impl Mixed { } } impl Cpp17EqualityComparableUnsafe for Mixed { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Mixed); - let __rhs = (__rhs.as_ptr() as *const Mixed); - __return.write((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Mixed); - let __rhs = (__rhs.as_ptr() as *const Mixed); - return ((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) }) != 0); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + Mixed, + |__return, __lhs, __rhs| { + __return.write((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs) })); + }, + |__lhs, __rhs| { ((unsafe { Mixed::operator_eq(&raw const (*__lhs), __rhs,) }) != 0) } + ); } impl LessThanComparableUnsafe for Mixed { - type Result = i32; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Mixed); - let __rhs = (__rhs.as_ptr() as *const Mixed); - __return.write((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Mixed); - let __rhs = (__rhs.as_ptr() as *const Mixed); - return ((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) }) != 0); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = i32, + Mixed, + |__return, __lhs, __rhs| { + __return.write((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs) })); + }, + |__lhs, __rhs| { ((unsafe { Mixed::operator_lt(&raw const (*__lhs), __rhs,) }) != 0) } + ); } #[repr(C)] #[derive( @@ -356,180 +316,102 @@ impl MyBool { } } impl Cpp17EqualityComparableUnsafe for MyBool { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + == ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl WeaklyEqualityComparableWithUnsafe for MyBool { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - != ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - != ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + != ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl LessThanComparableUnsafe for MyBool { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl PartiallyOrderedWithUnsafe for MyBool { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - > ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - > ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + > ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - <= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - <= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - __return.write( + <= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + MyBool, + |__lhs, __rhs| { (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - >= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - >= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + >= ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl ThreeWayComparableUnsafe for MyBool { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const MyBool); - let __rhs = (__rhs.as_ptr() as *const MyBool); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32), - &((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32), - )); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32), + &((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32), + )) + } + ); } #[repr(C)] #[derive( @@ -548,68 +430,58 @@ pub struct Boolish { pub v: i32, } impl Cpp17EqualityComparableUnsafe for Boolish { - type EqualResult = MyBool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Boolish); - let __rhs = (__rhs.as_ptr() as *const Boolish); - __return.write( - (unsafe { - let _a: Boolish = (*__lhs); - operator_eq_6(_a, (*__rhs)) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Boolish); - let __rhs = (__rhs.as_ptr() as *const Boolish); - return (unsafe { - MyBool::to_bool( - &(unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = MyBool, + Boolish, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { let _a: Boolish = (*__lhs); operator_eq_6(_a, (*__rhs)) }), - ) - }); - } + ); + }, + |__lhs, __rhs| { + (unsafe { + MyBool::to_bool( + &(unsafe { + let _a: Boolish = (*__lhs); + operator_eq_6(_a, (*__rhs)) + }), + ) + }) + } + ); } impl LessThanComparableUnsafe for Boolish { - type Result = MyBool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Boolish); - let __rhs = (__rhs.as_ptr() as *const Boolish); - __return.write( - (unsafe { - let _a: Boolish = (*__lhs); - operator_lt_7(_a, (*__rhs)) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Boolish); - let __rhs = (__rhs.as_ptr() as *const Boolish); - return (unsafe { - MyBool::to_bool( - &(unsafe { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = MyBool, + Boolish, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { let _a: Boolish = (*__lhs); operator_lt_7(_a, (*__rhs)) }), - ) - }); - } + ); + }, + |__lhs, __rhs| { + (unsafe { + MyBool::to_bool( + &(unsafe { + let _a: Boolish = (*__lhs); + operator_lt_7(_a, (*__rhs)) + }), + ) + }) + } + ); } pub unsafe fn operator_eq_6(mut a: Boolish, mut b: Boolish) -> MyBool { return { @@ -650,180 +522,102 @@ impl RefBool { } } impl Cpp17EqualityComparableUnsafe for RefBool { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + == ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl WeaklyEqualityComparableWithUnsafe for RefBool { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - != ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - != ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + != ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl LessThanComparableUnsafe for RefBool { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl PartiallyOrderedWithUnsafe for RefBool { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - > ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - > ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + > ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - <= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - <= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - __return.write( + <= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + RefBool, + |__lhs, __rhs| { (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - >= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - >= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)); - } + >= ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) + } + ); } impl ThreeWayComparableUnsafe for RefBool { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const RefBool); - let __rhs = (__rhs.as_ptr() as *const RefBool); - return libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( - &((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32), - &((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32), - )); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { + libcc2rs::StrongOrdering::from(std::cmp::Ord::cmp( + &((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32), + &((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32), + )) + } + ); } pub static mut ref_true_8: std::cell::LazyCell = std::cell::LazyCell::new(|| unsafe { { @@ -854,30 +648,8 @@ impl RefInt { } } impl Cpp17EqualityComparableUnsafe for RefInt { - type EqualResult = LvalueRefUnsafe; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const RefInt); - let __rhs = (__rhs.as_ptr() as *const RefInt); - __return.write(LvalueRefUnsafe::bind( - &mut (*(unsafe { RefInt::operator_eq(&raw const (*__lhs), __rhs) })), - )); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const RefInt); - let __rhs = (__rhs.as_ptr() as *const RefInt); - return (unsafe { - RefBool::to_bool( - &raw const (*(unsafe { RefInt::operator_eq(&raw const (*__lhs), __rhs) })), - ) - }); - } + comparison_unsafe! ( Cpp17EqualityComparableUnsafe , equal , is_equal , EqualResult = LvalueRefUnsafe , RefInt , |__return, __lhs, __rhs| { __return .write ( LvalueRefUnsafe ::bind ( & mut ( * ( unsafe { RefInt :: operator_eq ( &raw const ( * __lhs ) , __rhs , ) } ) ) ) ) ; +} , |__lhs, __rhs| { ( unsafe { RefBool :: to_bool ( &raw const ( * ( unsafe { RefInt :: operator_eq ( &raw const ( * __lhs ) , __rhs , ) } ) ) , ) } ) } ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs index 9a58bc8319..19ab6e2a87 100644 --- a/tests/unit/out/unsafe/operator_comparison_noncopyable.rs +++ b/tests/unit/out/unsafe/operator_comparison_noncopyable.rs @@ -29,54 +29,34 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { let _x: *const S = __lhs; operator_eq_0(_x, __rhs) - }), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _x: *const S = __lhs; - operator_eq_0(_x, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { (unsafe { let _x: *const S = __lhs; operator_lt_1(_x, __rhs) - }), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { - let _x: *const S = __lhs; - operator_lt_1(_x, __rhs) - }); - } + }) + } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 3a2e59172e..6ffdf08d22 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -27,60 +27,34 @@ pub struct Defaulted { pub b: i32, } impl Cpp17EqualityComparableUnsafe for Defaulted { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Defaulted); - let __rhs = (__rhs.as_ptr() as *const Defaulted); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Defaulted, + |__lhs, __rhs| { (unsafe { let _arg0: *const Defaulted = __lhs; operator_eq_0(_arg0, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Defaulted); - let __rhs = (__rhs.as_ptr() as *const Defaulted); - return (unsafe { - let _arg0: *const Defaulted = __lhs; - operator_eq_0(_arg0, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Defaulted { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Defaulted); - let __rhs = (__rhs.as_ptr() as *const Defaulted); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Defaulted, + |__lhs, __rhs| { !(unsafe { let _arg0: *const Defaulted = __lhs; operator_eq_0(_arg0, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Defaulted); - let __rhs = (__rhs.as_ptr() as *const Defaulted); - return !(unsafe { - let _arg0: *const Defaulted = __lhs; - operator_eq_0(_arg0, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_cmp_1( _a0: *const DefaultedOrd, @@ -115,218 +89,126 @@ pub struct DefaultedOrd { pub a: i32, } impl Cpp17EqualityComparableUnsafe for DefaultedOrd { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { (unsafe { let _arg0: *const DefaultedOrd = __lhs; operator_eq_2(_arg0, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_eq_2(_arg0, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for DefaultedOrd { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { !(unsafe { let _arg0: *const DefaultedOrd = __lhs; operator_eq_2(_arg0, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return !(unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_eq_2(_arg0, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for DefaultedOrd { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write(libcc2rs::is_lt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return libcc2rs::is_lt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - ); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ) + } + ); } impl PartiallyOrderedWithUnsafe for DefaultedOrd { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write(libcc2rs::is_lt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return libcc2rs::is_lt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - ); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write(libcc2rs::is_gt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return libcc2rs::is_gt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - ); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write(libcc2rs::is_lteq( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return libcc2rs::is_lteq( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - ); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - __return.write(libcc2rs::is_gteq( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return libcc2rs::is_gteq( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_lt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_gt( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_lteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + DefaultedOrd, + |__lhs, __rhs| { + libcc2rs::is_gteq( + (unsafe { + let _arg0: *const DefaultedOrd = __lhs; + operator_cmp_1(_arg0, __rhs) + }), + ) + } + ); +} +impl ThreeWayComparableUnsafe for DefaultedOrd { + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { let _arg0: *const DefaultedOrd = __lhs; operator_cmp_1(_arg0, __rhs) - }), - ); - } -} -impl ThreeWayComparableUnsafe for DefaultedOrd { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const DefaultedOrd); - let __rhs = (__rhs.as_ptr() as *const DefaultedOrd); - return (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_3(x: *const Inline, y: *const Inline) -> bool { return (((*x).a) == ((*y).a)); @@ -356,88 +238,49 @@ pub struct Inline { pub a: i32, } impl Cpp17EqualityComparableUnsafe for Inline { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Inline, + |__lhs, __rhs| { (unsafe { let _x: *const Inline = __lhs; operator_eq_3(_x, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - return (unsafe { - let _x: *const Inline = __lhs; - operator_eq_3(_x, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Inline { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Inline, + |__lhs, __rhs| { !(unsafe { let _x: *const Inline = __lhs; operator_eq_3(_x, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - return !(unsafe { - let _x: *const Inline = __lhs; - operator_eq_3(_x, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Inline { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Inline, + |__lhs, __rhs| { (unsafe { let _x: *const Inline = __lhs; operator_lt_4(_x, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Inline); - let __rhs = (__rhs.as_ptr() as *const Inline); - return (unsafe { - let _x: *const Inline = __lhs; - operator_lt_4(_x, __rhs) - }); - } + }) + } + ); } #[repr(C)] #[derive( @@ -456,60 +299,34 @@ pub struct OutOfLine { pub a: i32, } impl Cpp17EqualityComparableUnsafe for OutOfLine { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OutOfLine); - let __rhs = (__rhs.as_ptr() as *const OutOfLine); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + OutOfLine, + |__lhs, __rhs| { (unsafe { let _x: *const OutOfLine = __lhs; operator_eq_6(_x, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OutOfLine); - let __rhs = (__rhs.as_ptr() as *const OutOfLine); - return (unsafe { - let _x: *const OutOfLine = __lhs; - operator_eq_6(_x, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for OutOfLine { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const OutOfLine); - let __rhs = (__rhs.as_ptr() as *const OutOfLine); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + OutOfLine, + |__lhs, __rhs| { (unsafe { let _x: *const OutOfLine = __lhs; operator_ne_7(_x, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const OutOfLine); - let __rhs = (__rhs.as_ptr() as *const OutOfLine); - return (unsafe { - let _x: *const OutOfLine = __lhs; - operator_ne_7(_x, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_6(x: *const OutOfLine, y: *const OutOfLine) -> bool { return (((*x).a) == ((*y).a)); @@ -546,88 +363,49 @@ pub struct Tmpl_int_ { pub v: i32, } impl Cpp17EqualityComparableUnsafe for Tmpl_int_ { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Tmpl_int_, + |__lhs, __rhs| { (unsafe { let _x: *const Tmpl_int_ = __lhs; operator_eq_8(_x, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - return (unsafe { - let _x: *const Tmpl_int_ = __lhs; - operator_eq_8(_x, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Tmpl_int_ { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Tmpl_int_, + |__lhs, __rhs| { !(unsafe { let _x: *const Tmpl_int_ = __lhs; operator_eq_8(_x, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - return !(unsafe { - let _x: *const Tmpl_int_ = __lhs; - operator_eq_8(_x, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Tmpl_int_ { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Tmpl_int_, + |__lhs, __rhs| { (unsafe { let _x: *const Tmpl_int_ = __lhs; operator_lt_9(_x, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_int_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_int_); - return (unsafe { - let _x: *const Tmpl_int_ = __lhs; - operator_lt_9(_x, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_11(x: *const Tmpl_long_, y: *const Tmpl_long_) -> bool { return (((*x).v) == ((*y).v)); @@ -652,88 +430,49 @@ pub struct Tmpl_long_ { pub v: i64, } impl Cpp17EqualityComparableUnsafe for Tmpl_long_ { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Tmpl_long_, + |__lhs, __rhs| { (unsafe { let _x: *const Tmpl_long_ = __lhs; operator_eq_11(_x, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - return (unsafe { - let _x: *const Tmpl_long_ = __lhs; - operator_eq_11(_x, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Tmpl_long_ { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Tmpl_long_, + |__lhs, __rhs| { !(unsafe { let _x: *const Tmpl_long_ = __lhs; operator_eq_11(_x, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - return !(unsafe { - let _x: *const Tmpl_long_ = __lhs; - operator_eq_11(_x, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Tmpl_long_ { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Tmpl_long_, + |__lhs, __rhs| { (unsafe { let _x: *const Tmpl_long_ = __lhs; operator_lt_12(_x, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tmpl_long_); - let __rhs = (__rhs.as_ptr() as *const Tmpl_long_); - return (unsafe { - let _x: *const Tmpl_long_ = __lhs; - operator_lt_12(_x, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_eq_13( _a0: *const TmplDefaulted_int_, @@ -758,60 +497,34 @@ pub struct TmplDefaulted_int_ { pub v: i32, } impl Cpp17EqualityComparableUnsafe for TmplDefaulted_int_ { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); - let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + TmplDefaulted_int_, + |__lhs, __rhs| { (unsafe { let _arg0: *const TmplDefaulted_int_ = __lhs; operator_eq_13(_arg0, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); - let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); - return (unsafe { - let _arg0: *const TmplDefaulted_int_ = __lhs; - operator_eq_13(_arg0, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for TmplDefaulted_int_ { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); - let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + TmplDefaulted_int_, + |__lhs, __rhs| { !(unsafe { let _arg0: *const TmplDefaulted_int_ = __lhs; operator_eq_13(_arg0, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const TmplDefaulted_int_); - let __rhs = (__rhs.as_ptr() as *const TmplDefaulted_int_); - return !(unsafe { - let _arg0: *const TmplDefaulted_int_ = __lhs; - operator_eq_13(_arg0, __rhs) - }); - } + }) + } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index 8cce81ca50..f5887a379b 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -66,157 +66,89 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - == (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - == (unsafe { S::to_i32(&raw const (*__rhs)) })); - } + == (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - != (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - != (unsafe { S::to_i32(&raw const (*__rhs)) })); - } + != (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - < (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - < (unsafe { S::to_i32(&raw const (*__rhs)) })); - } + < (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); } impl PartiallyOrderedWithUnsafe for S { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - < (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - < (unsafe { S::to_i32(&raw const (*__rhs)) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + < (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - > (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - > (unsafe { S::to_i32(&raw const (*__rhs)) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + > (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - <= (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - <= (unsafe { S::to_i32(&raw const (*__rhs)) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( + <= (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { ((unsafe { S::to_i32(&raw const (*__lhs)) }) - >= (unsafe { S::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { S::to_i32(&raw const (*__lhs)) }) - >= (unsafe { S::to_i32(&raw const (*__rhs)) })); - } + >= (unsafe { S::to_i32(&raw const (*__rhs)) })) + } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_overloads.rs b/tests/unit/out/unsafe/operator_overloads.rs index 1feeabcb33..2866133b35 100644 --- a/tests/unit/out/unsafe/operator_overloads.rs +++ b/tests/unit/out/unsafe/operator_overloads.rs @@ -46,120 +46,89 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - __return.write((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i32); - return ((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) }) != 0); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + i32, + |__return, __lhs, __rhs| { + __return.write((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs)) })); + }, + |__lhs, __rhs| { ((unsafe { S::operator_eq_1(&raw const (*__lhs), (*__rhs),) }) != 0) } + ); } impl Cpp17EqualityComparableUnsafe for i32 { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( - (unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + S, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: i32 = (*__lhs); + operator_eq_0(_a, (*__rhs)) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: i32 = (*__lhs); operator_eq_0(_a, (*__rhs)) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { - let _a: i32 = (*__lhs); - operator_eq_0(_a, (*__rhs)) - }) != 0); - } + }) != 0) + } + ); } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - __return.write((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const i64); - return ((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) }) != 0); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + i64, + |__return, __lhs, __rhs| { + __return.write((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs)) })); + }, + |__lhs, __rhs| { ((unsafe { S::operator_eq_2(&raw const (*__lhs), (*__rhs),) }) != 0) } + ); } impl Cpp17EqualityComparableUnsafe for i64 { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write( - (unsafe { + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + S, + |__return, __lhs, __rhs| { + __return.write( + (unsafe { + let _a: i64 = (*__lhs); + operator_eq_1(_a, __rhs) + }), + ); + }, + |__lhs, __rhs| { + ((unsafe { let _a: i64 = (*__lhs); operator_eq_1(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const i64); - let __rhs = (__rhs.as_ptr() as *const S); - return ((unsafe { - let _a: i64 = (*__lhs); - operator_eq_1(_a, __rhs) - }) != 0); - } + }) != 0) + } + ); } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = i32; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - __return.write((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const f64); - return ((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) }) != 0); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = i32, + f64, + |__return, __lhs, __rhs| { + __return.write((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs)) })); + }, + |__lhs, __rhs| { ((unsafe { S::operator_eq_3(&raw const (*__lhs), (*__rhs),) }) != 0) } + ); } pub unsafe fn operator_div_2(a: *const S, b: *const S) -> i32 { return (((*a).v) / ((*b).v)); diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 4323f5b3c4..678a620986 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -37,150 +37,86 @@ impl S { } } impl Cpp17EqualityComparableUnsafe for S { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write((unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + S, + |__lhs, __rhs| { (unsafe { S::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for S { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(!(unsafe { S::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return !(unsafe { S::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + S, + |__lhs, __rhs| { !(unsafe { S::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for S { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(libcc2rs::is_lt( - (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for S { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(libcc2rs::is_lt( - (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less(__lhs: LvalueRefUnsafe>, __rhs: LvalueRefUnsafe>) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(libcc2rs::is_gt( - (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return libcc2rs::is_gt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(libcc2rs::is_lteq( - (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return libcc2rs::is_lteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - __return.write(libcc2rs::is_gteq( - (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return libcc2rs::is_gteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + S, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for S { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const S); - let __rhs = (__rhs.as_ptr() as *const S); - return (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { S::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index e046a16498..bfe7787829 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -28,24 +28,14 @@ impl Lt { } } impl LessThanComparableUnsafe for Lt { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Lt); - let __rhs = (__rhs.as_ptr() as *const Lt); - __return.write((unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Lt); - let __rhs = (__rhs.as_ptr() as *const Lt); - return (unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Lt, + |__lhs, __rhs| { (unsafe { Lt::operator_lt(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -69,44 +59,24 @@ impl Eq { } } impl Cpp17EqualityComparableUnsafe for Eq { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - __return.write((unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - return (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Eq, + |__lhs, __rhs| { (unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Eq { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - __return.write(!(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Eq); - let __rhs = (__rhs.as_ptr() as *const Eq); - return !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Eq, + |__lhs, __rhs| { !(unsafe { Eq::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -133,159 +103,86 @@ impl Cmp { } } impl Cpp17EqualityComparableUnsafe for Cmp { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write((unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Cmp, + |__lhs, __rhs| { (unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl WeaklyEqualityComparableWithUnsafe for Cmp { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(!(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) })); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Cmp, + |__lhs, __rhs| { !(unsafe { Cmp::operator_eq(&raw const (*__lhs), __rhs,) }) } + ); } impl LessThanComparableUnsafe for Cmp { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl PartiallyOrderedWithUnsafe for Cmp { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_gt( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_lteq( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - __return.write(libcc2rs::is_gteq( - (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }), - )); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })); - } + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_lteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Cmp, + |__lhs, __rhs| { + libcc2rs::is_gteq((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) + } + ); } impl ThreeWayComparableUnsafe for Cmp { - type Category = libcc2rs::StrongOrdering; - unsafe fn three_way( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::Category { - let __lhs = (__lhs.as_ptr() as *const Cmp); - let __rhs = (__rhs.as_ptr() as *const Cmp); - return (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) }); - } + comparison_unsafe!( + ThreeWayComparableUnsafe, + three_way, + Category = libcc2rs::StrongOrdering, + |__lhs, __rhs| { (unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs,) }) } + ); } #[repr(C)] #[derive( @@ -304,88 +201,49 @@ pub struct Free { pub v: i32, } impl Cpp17EqualityComparableUnsafe for Free { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Free, + |__lhs, __rhs| { (unsafe { let _a: *const Free = __lhs; operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - return (unsafe { - let _a: *const Free = __lhs; - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Free { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Free, + |__lhs, __rhs| { !(unsafe { let _a: *const Free = __lhs; operator_eq_0(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - return !(unsafe { - let _a: *const Free = __lhs; - operator_eq_0(_a, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Free { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Free, + |__lhs, __rhs| { (unsafe { let _a: *const Free = __lhs; operator_lt_1(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Free); - let __rhs = (__rhs.as_ptr() as *const Free); - return (unsafe { - let _a: *const Free = __lhs; - operator_lt_1(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_1(a: *const Free, b: *const Free) -> bool { return (((*a).v) < ((*b).v)); @@ -416,88 +274,49 @@ pub struct Wrapped_int_ { pub v: i32, } impl Cpp17EqualityComparableUnsafe for Wrapped_int_ { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Wrapped_int_, + |__lhs, __rhs| { (unsafe { let _a: *const Wrapped_int_ = __lhs; operator_eq_2(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - return (unsafe { - let _a: *const Wrapped_int_ = __lhs; - operator_eq_2(_a, __rhs) - }); - } + }) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Wrapped_int_ { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Wrapped_int_, + |__lhs, __rhs| { !(unsafe { let _a: *const Wrapped_int_ = __lhs; operator_eq_2(_a, __rhs) - }), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - return !(unsafe { - let _a: *const Wrapped_int_ = __lhs; - operator_eq_2(_a, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Wrapped_int_ { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Wrapped_int_, + |__lhs, __rhs| { (unsafe { let _a: *const Wrapped_int_ = __lhs; operator_lt_3(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Wrapped_int_); - let __rhs = (__rhs.as_ptr() as *const Wrapped_int_); - return (unsafe { - let _a: *const Wrapped_int_ = __lhs; - operator_lt_3(_a, __rhs) - }); - } + }) + } + ); } pub fn main() { unsafe { diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index 45583b4936..d340ef48f8 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -51,166 +51,89 @@ impl Meters { } } impl Cpp17EqualityComparableUnsafe for Meters { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - == (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - == (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } + == (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Meters { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - != (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - != (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } + != (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); } impl LessThanComparableUnsafe for Meters { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - < (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - < (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); } impl PartiallyOrderedWithUnsafe for Meters { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - < (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - < (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + < (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - > (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - > (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + > (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - <= (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - <= (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - __return.write( + <= (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Meters, + |__lhs, __rhs| { ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - >= (unsafe { Meters::to_i32(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Meters); - let __rhs = (__rhs.as_ptr() as *const Meters); - return ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - >= (unsafe { Meters::to_i32(&raw const (*__rhs)) })); - } + >= (unsafe { Meters::to_i32(&raw const (*__rhs)) })) + } + ); } #[repr(C)] #[derive( diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index e59e89160d..a9334dd867 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -52,32 +52,19 @@ impl MoveAssignableUnsafe for Tracked { } } impl LessThanComparableUnsafe for Tracked { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Tracked); - let __rhs = (__rhs.as_ptr() as *const Tracked); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Tracked, + |__lhs, __rhs| { (unsafe { let _a: *const Tracked = __lhs; operator_lt_1(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Tracked); - let __rhs = (__rhs.as_ptr() as *const Tracked); - return (unsafe { - let _a: *const Tracked = __lhs; - operator_lt_1(_a, __rhs) - }); - } + }) + } + ); } impl Default for Tracked { fn default() -> Self { @@ -118,32 +105,19 @@ impl MoveOnly { } } impl LessThanComparableUnsafe for MoveOnly { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const MoveOnly); - let __rhs = (__rhs.as_ptr() as *const MoveOnly); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + MoveOnly, + |__lhs, __rhs| { (unsafe { let _a: *const MoveOnly = __lhs; operator_lt_3(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const MoveOnly); - let __rhs = (__rhs.as_ptr() as *const MoveOnly); - return (unsafe { - let _a: *const MoveOnly = __lhs; - operator_lt_3(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_3(a: *const MoveOnly, b: *const MoveOnly) -> bool { return (((*a).v) < ((*b).v)); @@ -170,60 +144,34 @@ impl Bag { } } impl Cpp17EqualityComparableUnsafe for Bag { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Bag, + |__lhs, __rhs| { (unsafe { let _a: *const Bag = __lhs; operator_eq_4(_a, __rhs) - }), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - return (unsafe { - let _a: *const Bag = __lhs; - operator_eq_4(_a, __rhs) - }); - } + }) + } + ); } impl LessThanComparableUnsafe for Bag { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Bag, + |__lhs, __rhs| { (unsafe { let _a: *const Bag = __lhs; operator_lt_5(_a, __rhs) - }), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Bag); - let __rhs = (__rhs.as_ptr() as *const Bag); - return (unsafe { - let _a: *const Bag = __lhs; - operator_lt_5(_a, __rhs) - }); - } + }) + } + ); } pub unsafe fn operator_lt_5(a: *const Bag, b: *const Bag) -> bool { return (((*a).items.len()) < ((*b).items.len())); diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index ffd6666ee2..be5d033958 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -51,166 +51,89 @@ impl Reading { } } impl Cpp17EqualityComparableUnsafe for Reading { - type EqualResult = bool; - unsafe fn equal( - __return: *mut Self::EqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + comparison_unsafe!( + Cpp17EqualityComparableUnsafe, + equal, + is_equal, + EqualResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - == (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - == (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } + == (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); } impl WeaklyEqualityComparableWithUnsafe for Reading { - type NotEqualResult = bool; - unsafe fn not_equal( - __return: *mut Self::NotEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + comparison_unsafe!( + WeaklyEqualityComparableWithUnsafe, + not_equal, + is_not_equal, + NotEqualResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - != (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_not_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - != (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } + != (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); } impl LessThanComparableUnsafe for Reading { - type Result = bool; - unsafe fn less( - __return: *mut Self::Result, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - < (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - < (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); } impl PartiallyOrderedWithUnsafe for Reading { - type LessResult = bool; - unsafe fn less( - __return: *mut Self::LessResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less, + is_less, + LessResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - < (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - < (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } - type GreaterResult = bool; - unsafe fn greater( - __return: *mut Self::GreaterResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + < (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater, + is_greater, + GreaterResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - > (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - > (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } - type LessEqualResult = bool; - unsafe fn less_equal( - __return: *mut Self::LessEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + > (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + less_equal, + is_less_equal, + LessEqualResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - <= (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_less_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - <= (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } - type GreaterEqualResult = bool; - unsafe fn greater_equal( - __return: *mut Self::GreaterEqualResult, - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - __return.write( + <= (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); + comparison_unsafe!( + PartiallyOrderedWithUnsafe, + greater_equal, + is_greater_equal, + GreaterEqualResult = bool, + Reading, + |__lhs, __rhs| { ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - >= (unsafe { Reading::to_i64(&raw const (*__rhs)) })), - ); - } - unsafe fn is_greater_equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> bool { - let __lhs = (__lhs.as_ptr() as *const Reading); - let __rhs = (__rhs.as_ptr() as *const Reading); - return ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - >= (unsafe { Reading::to_i64(&raw const (*__rhs)) })); - } + >= (unsafe { Reading::to_i64(&raw const (*__rhs)) })) + } + ); } pub fn main() { unsafe { From ba70429d6beda6770621b879ac7ae148cc64f208 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 23:26:45 +0000 Subject: [PATCH 16/17] Make CppLessThanComparable a supertrait of EqualityComparable --- cpp2rust/converter/converter_lib.h | 5 +- libcc2rs/src/cmp.rs | 69 +++-------------- rules/iterator_category/shim.rs | 33 ++++---- rules/iterator_category/tgt_refcount.rs | 2 +- rules/iterator_category/tgt_unsafe.rs | 2 +- .../out/refcount/class.spaceship.rs | 68 ----------------- .../out/unsafe/class.spaceship.rs | 65 ---------------- .../class.conv/out/refcount/class.conv.fct.rs | 12 --- .../class.conv/out/unsafe/class.conv.fct.rs | 11 --- .../out/refcount/concept.totallyordered.rs | 46 ------------ .../out/unsafe/concept.totallyordered.rs | 43 ----------- .../out/refcount/concept.convertible.rs | 12 --- .../out/unsafe/concept.convertible.rs | 11 --- .../out/refcount/sequence.reqmts.rs | 12 --- .../out/unsafe/sequence.reqmts.rs | 14 ---- .../out/refcount/utility.arg.requirements.rs | 62 --------------- .../out/unsafe/utility.arg.requirements.rs | 56 -------------- .../stmt.select/out/refcount/stmt.switch.rs | 22 ------ .../stmt.select/out/unsafe/stmt.switch.rs | 18 ----- .../support/cmp/out/refcount/cmp.concept.rs | 59 --------------- .../std/support/cmp/out/unsafe/cmp.concept.rs | 56 -------------- .../refcount/operator_comparison_defaulted.rs | 68 ----------------- .../out/refcount/operator_comparison_free.rs | 28 +++++-- .../refcount/operator_comparison_member.rs | 18 +++-- .../out/refcount/operator_comparison_mixed.rs | 60 +++++++++++++++ .../refcount/operator_comparison_nonbool.rs | 47 ------------ tests/unit/out/refcount/operator_friend.rs | 8 -- .../out/refcount/operator_other_member.rs | 10 --- tests/unit/out/refcount/operator_three_way.rs | 10 --- tests/unit/out/refcount/operator_traits.rs | 10 --- .../refcount/pair_converting_construction.rs | 10 --- .../out/refcount/vector_iter_range_ctor.rs | 12 --- .../unsafe/operator_comparison_defaulted.rs | 68 ----------------- .../out/unsafe/operator_comparison_free.rs | 43 +++++++---- .../out/unsafe/operator_comparison_member.rs | 18 +++-- .../out/unsafe/operator_comparison_mixed.rs | 75 +++++++++++++++++++ .../out/unsafe/operator_comparison_nonbool.rs | 43 ----------- tests/unit/out/unsafe/operator_friend.rs | 15 ---- .../unit/out/unsafe/operator_other_member.rs | 11 --- tests/unit/out/unsafe/operator_three_way.rs | 10 --- tests/unit/out/unsafe/operator_traits.rs | 10 --- .../unsafe/pair_converting_construction.rs | 11 --- .../unit/out/unsafe/vector_iter_range_ctor.rs | 11 --- 43 files changed, 241 insertions(+), 1033 deletions(-) diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index fdc794f377..5eab57aab1 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -214,7 +214,6 @@ inline constexpr ComparisonRelation kNotEqualRelations[] = { inline constexpr ComparisonRelation kLessThanRelations[] = { {clang::BO_LT, "less", "is_less", "Result"}}; inline constexpr ComparisonRelation kOrderingRelations[] = { - {clang::BO_LT, "less", "is_less", "LessResult"}, {clang::BO_GT, "greater", "is_greater", "GreaterResult"}, {clang::BO_LE, "less_equal", "is_less_equal", "LessEqualResult"}, {clang::BO_GE, "greater_equal", "is_greater_equal", "GreaterEqualResult"}}; @@ -237,7 +236,7 @@ inline constexpr ComparisonTrait kLessThanComparable{ inline constexpr ComparisonTrait kPartiallyOrderedWith{ {nullptr, {"PartiallyOrderedWith"}, {"PartiallyOrderedWithUnsafe"}}, kOrderingRelations, - nullptr, + &kLessThanComparable, true}; inline constexpr ComparisonTrait kThreeWayComparable{ {nullptr, {"ThreeWayComparable"}, {"ThreeWayComparableUnsafe"}}, @@ -278,7 +277,7 @@ inline constexpr const ComparisonTrait *kHomogeneousComparisonTraits[] = { inline constexpr const ComparisonTrait *kHeterogeneousComparisonTraits[] = { &kCpp17EqualityComparable, &kWeaklyEqualityComparableWith, - &kPartiallyOrderedWith}; + &kLessThanComparable, &kPartiallyOrderedWith}; bool SatisfiesComparisonTrait(const ComparisonTrait &trait, const Comparisons &forward, diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index 4d0427235d..f7c802bb2a 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -19,14 +19,14 @@ pub trait BooleanTestableUnsafe: ConvertibleToUnsafe {} impl> BooleanTestableUnsafe for T {} -pub trait LessThanComparable: ByteRepr + Sized { +pub trait LessThanComparable: ByteRepr + Sized { type Result: BooleanTestable; - fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>); - fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool; + fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>); + fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool; } -pub trait LessThanComparableUnsafe: Sized { +pub trait LessThanComparableUnsafe: Sized { type Result: BooleanTestableUnsafe; /// # Safety @@ -35,11 +35,11 @@ pub trait LessThanComparableUnsafe: Sized { unsafe fn less( __return: *mut Self::Result, a: LvalueRefUnsafe>, - b: LvalueRefUnsafe>, + b: LvalueRefUnsafe>, ); /// # Safety /// `a` and `b` must refer to live values. - unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; + unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; } pub trait Cpp17EqualityComparable: ByteRepr + Sized { @@ -776,14 +776,13 @@ impl } } -pub trait PartiallyOrderedWith = Self>: ByteRepr + Sized { - type LessResult: BooleanTestable; +pub trait PartiallyOrderedWith = Self>: + LessThanComparable + ByteRepr + Sized +{ type GreaterResult: BooleanTestable; type LessEqualResult: BooleanTestable; type GreaterEqualResult: BooleanTestable; - fn less(__return: Ptr, a: LvalueRef>, b: LvalueRef>); - fn is_less(a: LvalueRef>, b: LvalueRef>) -> bool; fn greater( __return: Ptr, a: LvalueRef>, @@ -804,23 +803,13 @@ pub trait PartiallyOrderedWith = Self>: ByteRepr + fn is_greater_equal(a: LvalueRef>, b: LvalueRef>) -> bool; } -pub trait PartiallyOrderedWithUnsafe = Self>: Sized { - type LessResult: BooleanTestableUnsafe; +pub trait PartiallyOrderedWithUnsafe = Self>: + LessThanComparableUnsafe + Sized +{ type GreaterResult: BooleanTestableUnsafe; type LessEqualResult: BooleanTestableUnsafe; type GreaterEqualResult: BooleanTestableUnsafe; - /// # Safety - /// `__return` must point to writable storage for the result, and `a` and `b` must refer to - /// live values. - unsafe fn less( - __return: *mut Self::LessResult, - a: LvalueRefUnsafe>, - b: LvalueRefUnsafe>, - ); - /// # Safety - /// `a` and `b` must refer to live values. - unsafe fn is_less(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool; /// # Safety /// `__return` must point to writable storage for the result, and `a` and `b` must refer to /// live values. @@ -904,26 +893,10 @@ macro_rules! impl_partially_ordered_with { where $ty: PartialOrd + $crate::ByteRepr, { - type LessResult = bool; type GreaterResult = bool; type LessEqualResult = bool; type GreaterEqualResult = bool; - fn less( - __return: $crate::Ptr, - a: $crate::LvalueRef<$crate::Const>, - b: $crate::LvalueRef<$crate::Const>, - ) { - __return.write(::is_less(a, b)); - } - - fn is_less( - a: $crate::LvalueRef<$crate::Const>, - b: $crate::LvalueRef<$crate::Const>, - ) -> bool { - a.as_pointer().with(|a| b.as_pointer().with(|b| a < b)) - } - fn greater( __return: $crate::Ptr, a: $crate::LvalueRef<$crate::Const>, @@ -978,28 +951,10 @@ macro_rules! impl_partially_ordered_with_unsafe { where $ty: PartialOrd, { - type LessResult = bool; type GreaterResult = bool; type LessEqualResult = bool; type GreaterEqualResult = bool; - unsafe fn less( - __return: *mut bool, - a: $crate::LvalueRefUnsafe<$crate::Const>, - b: $crate::LvalueRefUnsafe<$crate::Const>, - ) { - unsafe { - __return.write(::is_less(a, b)); - } - } - - unsafe fn is_less( - a: $crate::LvalueRefUnsafe<$crate::Const>, - b: $crate::LvalueRefUnsafe<$crate::Const>, - ) -> bool { - unsafe { *a.as_const_ptr() < *b.as_const_ptr() } - } - unsafe fn greater( __return: *mut bool, a: $crate::LvalueRefUnsafe<$crate::Const>, diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index 499c8a4d56..0af1db9488 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -8,9 +8,10 @@ use std::marker::PhantomData; use std::rc::Rc; use crate::{ - ByteRepr, Const, EqualityComparable, EqualityComparableUnsafe, LvalueRef, LvalueRefUnsafe, - MapNode, PartiallyOrderedWith, PartiallyOrderedWithUnsafe, PostfixDec, PostfixInc, PrefixDec, - PrefixInc, Ptr, TotallyOrdered, TotallyOrderedUnsafe, UnsafeMapNode, Value, + ByteRepr, Const, EqualityComparable, EqualityComparableUnsafe, LessThanComparable, + LessThanComparableUnsafe, LvalueRef, LvalueRefUnsafe, MapNode, PartiallyOrderedWith, + PartiallyOrderedWithUnsafe, PostfixDec, PostfixInc, PrefixDec, PrefixInc, Ptr, TotallyOrdered, + TotallyOrderedUnsafe, UnsafeMapNode, Value, }; pub trait CppIterator: Clone { @@ -672,11 +673,8 @@ impl crate::WeaklyEqualityComparableWith for RandomAccessIterator PartiallyOrderedWith for RandomAccessIterator { - type LessResult = bool; - type GreaterResult = bool; - type LessEqualResult = bool; - type GreaterEqualResult = bool; +impl LessThanComparable for RandomAccessIterator { + type Result = bool; fn less(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { __return.write(Self::is_less(this, rhs)); } @@ -687,6 +685,12 @@ impl PartiallyOrderedWith for RandomAccessIterator { }) }) } +} + +impl PartiallyOrderedWith for RandomAccessIterator { + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; fn greater(__return: Ptr, this: LvalueRef>, rhs: LvalueRef>) { __return.write(Self::is_greater(this, rhs)); } @@ -765,11 +769,8 @@ impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator } } -impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { - type LessResult = bool; - type GreaterResult = bool; - type LessEqualResult = bool; - type GreaterEqualResult = bool; +impl LessThanComparableUnsafe for UnsafeRandomAccessIterator { + type Result = bool; unsafe fn less( __return: *mut bool, this: LvalueRefUnsafe>, @@ -787,6 +788,12 @@ impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { } } } +} + +impl PartiallyOrderedWithUnsafe for UnsafeRandomAccessIterator { + type GreaterResult = bool; + type LessEqualResult = bool; + type GreaterEqualResult = bool; unsafe fn greater( __return: *mut bool, this: LvalueRefUnsafe>, diff --git a/rules/iterator_category/tgt_refcount.rs b/rules/iterator_category/tgt_refcount.rs index 07f9d3dc7b..6945244326 100644 --- a/rules/iterator_category/tgt_refcount.rs +++ b/rules/iterator_category/tgt_refcount.rs @@ -112,7 +112,7 @@ fn f19, T2>(a0: T1, a1: isize) -> Ptr { } fn f20, T2>(a0: Ptr, a1: Ptr) -> bool { - PartiallyOrderedWith::is_less( + LessThanComparable::is_less( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), ) diff --git a/rules/iterator_category/tgt_unsafe.rs b/rules/iterator_category/tgt_unsafe.rs index 0999a65ca3..d36f1aba9e 100644 --- a/rules/iterator_category/tgt_unsafe.rs +++ b/rules/iterator_category/tgt_unsafe.rs @@ -112,7 +112,7 @@ fn f19, T2>(a0: T1, a1: isize) -> *mut T2 } unsafe fn f20, T2>(a0: T1, a1: T1) -> bool { - PartiallyOrderedWithUnsafe::is_less( + LessThanComparableUnsafe::is_less( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), ) diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index d5e1c50166..f882ac34eb 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -123,23 +123,6 @@ impl LessThanComparable for p1_memberwise_in_declaration_order_Date { ); } impl PartiallyOrderedWith for p1_memberwise_in_declaration_order_Date { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_memberwise_in_declaration_order_Date, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_memberwise_in_declaration_order_Date::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -405,23 +388,6 @@ impl LessThanComparable for p2_common_comparison_category_Reading { ); } impl PartiallyOrderedWith for p2_common_comparison_category_Reading { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p2_common_comparison_category_Reading, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p2_common_comparison_category_Reading::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -579,23 +545,6 @@ impl LessThanComparable for weak_ordering_from_user_operator_Fraction { ); } impl PartiallyOrderedWith for weak_ordering_from_user_operator_Fraction { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - weak_ordering_from_user_operator_Fraction, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - weak_ordering_from_user_operator_Fraction::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -805,23 +754,6 @@ impl LessThanComparable for partial_ordering_from_user_operator_Interval { ); } impl PartiallyOrderedWith for partial_ordering_from_user_operator_Interval { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - partial_ordering_from_user_operator_Interval, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - partial_ordering_from_user_operator_Interval::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index fd8c62d3d6..46b6cffd48 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -109,23 +109,6 @@ impl LessThanComparableUnsafe for p1_memberwise_in_declaration_order_Date { ); } impl PartiallyOrderedWithUnsafe for p1_memberwise_in_declaration_order_Date { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_memberwise_in_declaration_order_Date, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_memberwise_in_declaration_order_Date::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -351,20 +334,6 @@ impl LessThanComparableUnsafe for p2_common_comparison_category_Reading { ); } impl PartiallyOrderedWithUnsafe for p2_common_comparison_category_Reading { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p2_common_comparison_category_Reading, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p2_common_comparison_category_Reading::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -496,23 +465,6 @@ impl LessThanComparableUnsafe for weak_ordering_from_user_operator_Fraction { ); } impl PartiallyOrderedWithUnsafe for weak_ordering_from_user_operator_Fraction { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - weak_ordering_from_user_operator_Fraction, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - weak_ordering_from_user_operator_Fraction::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -698,23 +650,6 @@ impl LessThanComparableUnsafe for partial_ordering_from_user_operator_Interval { ); } impl PartiallyOrderedWithUnsafe for partial_ordering_from_user_operator_Interval { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - partial_ordering_from_user_operator_Interval, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - partial_ordering_from_user_operator_Interval::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index 5ca6475445..c38966cffc 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -111,18 +111,6 @@ impl LessThanComparable for p2_implicit_conversion_function_Ratio { ); } impl PartiallyOrderedWith for p2_implicit_conversion_function_Ratio { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p2_implicit_conversion_function_Ratio, - |__lhs, __rhs| { - ({ ({ p2_implicit_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index 37ca68f226..7a1c4429bc 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -99,17 +99,6 @@ impl LessThanComparableUnsafe for p2_implicit_conversion_function_Ratio { ); } impl PartiallyOrderedWithUnsafe for p2_implicit_conversion_function_Ratio { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p2_implicit_conversion_function_Ratio, - |__lhs, __rhs| { - ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index d709176dff..e51bc38568 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -97,18 +97,6 @@ impl LessThanComparable for p1_each_relation_is_an_operator_Score { ); } impl PartiallyOrderedWith for p1_each_relation_is_an_operator_Score { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_each_relation_is_an_operator_Score, - |__lhs, __rhs| { - ({ - p1_each_relation_is_an_operator_Score::operator_lt((__lhs).clone(), (__rhs).clone()) - }) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -266,23 +254,6 @@ impl LessThanComparable for p1_relations_from_three_way_Level { ); } impl PartiallyOrderedWith for p1_relations_from_three_way_Level { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_relations_from_three_way_Level, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_relations_from_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -449,23 +420,6 @@ impl LessThanComparable for p1_operator_preferred_over_three_way_Level { ); } impl PartiallyOrderedWith for p1_operator_preferred_over_three_way_Level { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_operator_preferred_over_three_way_Level, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_operator_preferred_over_three_way_Level::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index f6599020a7..bea3a27776 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -106,18 +106,6 @@ impl LessThanComparableUnsafe for p1_each_relation_is_an_operator_Score { ); } impl PartiallyOrderedWithUnsafe for p1_each_relation_is_an_operator_Score { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_each_relation_is_an_operator_Score, - |__lhs, __rhs| { - (unsafe { - p1_each_relation_is_an_operator_Score::operator_lt(&raw const (*__lhs), __rhs) - }) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -259,20 +247,6 @@ impl LessThanComparableUnsafe for p1_relations_from_three_way_Level { ); } impl PartiallyOrderedWithUnsafe for p1_relations_from_three_way_Level { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_relations_from_three_way_Level, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_relations_from_three_way_Level::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -413,23 +387,6 @@ impl LessThanComparableUnsafe for p1_operator_preferred_over_three_way_Level { ); } impl PartiallyOrderedWithUnsafe for p1_operator_preferred_over_three_way_Level { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_operator_preferred_over_three_way_Level, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_operator_preferred_over_three_way_Level::operator_cmp( - &raw const (*__lhs), - __rhs, - ) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index 779ab0685d..33e2b4a99e 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -126,18 +126,6 @@ impl LessThanComparable for p1_convertible_to_Ratio { ); } impl PartiallyOrderedWith for p1_convertible_to_Ratio { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_convertible_to_Ratio, - |__lhs, __rhs| { - ({ ({ p1_convertible_to_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 207e604914..bccca868ad 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -113,17 +113,6 @@ impl LessThanComparableUnsafe for p1_convertible_to_Ratio { ); } impl PartiallyOrderedWithUnsafe for p1_convertible_to_Ratio { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_convertible_to_Ratio, - |__lhs, __rhs| { - ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) - < (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index 5d21e9775a..c9873f4a28 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -74,18 +74,6 @@ impl LessThanComparable for p38_insert_range_by_conversion_function_Ratio { ); } impl PartiallyOrderedWith for p38_insert_range_by_conversion_function_Ratio { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p38_insert_range_by_conversion_function_Ratio, - |__lhs, __rhs| { - ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } < { - ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index ccbcdba668..570168cfef 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -77,20 +77,6 @@ impl LessThanComparableUnsafe for p38_insert_range_by_conversion_function_Ratio ); } impl PartiallyOrderedWithUnsafe for p38_insert_range_by_conversion_function_Ratio { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p38_insert_range_by_conversion_function_Ratio, - |__lhs, __rhs| { - ((unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__lhs)) - }) < (unsafe { - p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) - })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 837e9be022..73cd09c3c5 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -151,20 +151,6 @@ impl LessThanComparable for table28_result_convertible_to_bool_Truth { ); } impl PartiallyOrderedWith for table28_result_convertible_to_bool_Truth { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - table28_result_convertible_to_bool_Truth, - |__lhs, __rhs| { - ({ (({ table28_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } - < { - (({ table28_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) - as i32) - }) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -647,23 +633,6 @@ impl LessThanComparable for table29_other_operator_shapes_Depth { ); } impl PartiallyOrderedWith for table29_other_operator_shapes_Depth { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - table29_other_operator_shapes_Depth, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Depth::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -805,23 +774,6 @@ impl LessThanComparable for table29_other_operator_shapes_Length { ); } impl PartiallyOrderedWith for table29_other_operator_shapes_Length { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - table29_other_operator_shapes_Length, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - table29_other_operator_shapes_Length::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -1062,20 +1014,6 @@ impl LessThanComparable for table29_result_convertible_to_bool_Truth { ); } impl PartiallyOrderedWith for table29_result_convertible_to_bool_Truth { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - table29_result_convertible_to_bool_Truth, - |__lhs, __rhs| { - ({ (({ table29_result_convertible_to_bool_Truth::to_bool((__lhs).clone()) }) as i32) } - < { - (({ table29_result_convertible_to_bool_Truth::to_bool((__rhs).clone()) }) - as i32) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index dd07e86e1e..72dcbece5e 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -156,20 +156,6 @@ impl LessThanComparableUnsafe for table28_result_convertible_to_bool_Truth { ); } impl PartiallyOrderedWithUnsafe for table28_result_convertible_to_bool_Truth { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - table28_result_convertible_to_bool_Truth, - |__lhs, __rhs| { - (((unsafe { table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { - table28_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -632,20 +618,6 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Depth { ); } impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Depth { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - table29_other_operator_shapes_Depth, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Depth::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -772,20 +744,6 @@ impl LessThanComparableUnsafe for table29_other_operator_shapes_Length { ); } impl PartiallyOrderedWithUnsafe for table29_other_operator_shapes_Length { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - table29_other_operator_shapes_Length, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - table29_other_operator_shapes_Length::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -998,20 +956,6 @@ impl LessThanComparableUnsafe for table29_result_convertible_to_bool_Truth { ); } impl PartiallyOrderedWithUnsafe for table29_result_convertible_to_bool_Truth { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - table29_result_convertible_to_bool_Truth, - |__lhs, __rhs| { - (((unsafe { table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__lhs)) }) - as i32) - < ((unsafe { - table29_result_convertible_to_bool_Truth::to_bool(&raw const (*__rhs)) - }) as i32)) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index 32a820a7d1..b1a7a4f54f 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -193,28 +193,6 @@ impl LessThanComparable for p2_condition_variable_lives_for_whole_statement_Conv ); } impl PartiallyOrderedWith for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p2_condition_variable_lives_for_whole_statement_ConvertsToInt, - |__lhs, __rhs| { - ({ - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__lhs).clone(), - ) - }) - } < { - ({ - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - (__rhs).clone(), - ) - }) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index 8ab47ef771..7890487e09 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -157,24 +157,6 @@ impl LessThanComparableUnsafe for p2_condition_variable_lives_for_whole_statemen ); } impl PartiallyOrderedWithUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p2_condition_variable_lives_for_whole_statement_ConvertsToInt, - |__lhs, __rhs| { - ((unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__lhs), - ) - }) < (unsafe { - p2_condition_variable_lives_for_whole_statement_ConvertsToInt::to_i32( - &raw const (*__rhs), - ) - })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index d7826dd76b..718d033f14 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -98,20 +98,6 @@ impl LessThanComparable for p1_defaulted_three_way_Version { ); } impl PartiallyOrderedWith for p1_defaulted_three_way_Version { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_defaulted_three_way_Version, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_defaulted_three_way_Version::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -309,20 +295,6 @@ impl LessThanComparable for p1_user_written_three_way_Money { ); } impl PartiallyOrderedWith for p1_user_written_three_way_Money { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_user_written_three_way_Money, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_user_written_three_way_Money::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -487,20 +459,6 @@ impl LessThanComparable for p1_weaker_category_Temperature { ); } impl PartiallyOrderedWith for p1_weaker_category_Temperature { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_weaker_category_Temperature, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_weaker_category_Temperature::operator_cmp((__lhs).clone(), (__rhs).clone()) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -629,23 +587,6 @@ impl LessThanComparable for p1_three_way_without_equality_Rank { ); } impl PartiallyOrderedWith for p1_three_way_without_equality_Rank { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - p1_three_way_without_equality_Rank, - |__lhs, __rhs| { - libcc2rs::is_lt( - ({ - p1_three_way_without_equality_Rank::operator_cmp( - (__lhs).clone(), - (__rhs).clone(), - ) - }), - ) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index 3d3d0ad75e..8d79ad8ba2 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -94,20 +94,6 @@ impl LessThanComparableUnsafe for p1_defaulted_three_way_Version { ); } impl PartiallyOrderedWithUnsafe for p1_defaulted_three_way_Version { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_defaulted_three_way_Version, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_defaulted_three_way_Version::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -280,20 +266,6 @@ impl LessThanComparableUnsafe for p1_user_written_three_way_Money { ); } impl PartiallyOrderedWithUnsafe for p1_user_written_three_way_Money { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_user_written_three_way_Money, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_user_written_three_way_Money::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -452,20 +424,6 @@ impl LessThanComparableUnsafe for p1_weaker_category_Temperature { ); } impl PartiallyOrderedWithUnsafe for p1_weaker_category_Temperature { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_weaker_category_Temperature, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_weaker_category_Temperature::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -583,20 +541,6 @@ impl LessThanComparableUnsafe for p1_three_way_without_equality_Rank { ); } impl PartiallyOrderedWithUnsafe for p1_three_way_without_equality_Rank { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - p1_three_way_without_equality_Rank, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - p1_three_way_without_equality_Rank::operator_cmp(&raw const (*__lhs), __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/refcount/operator_comparison_defaulted.rs b/tests/unit/out/refcount/operator_comparison_defaulted.rs index 55f7b6bfcb..218e676e4b 100644 --- a/tests/unit/out/refcount/operator_comparison_defaulted.rs +++ b/tests/unit/out/refcount/operator_comparison_defaulted.rs @@ -134,16 +134,6 @@ impl LessThanComparable for Cmp { ); } impl PartiallyOrderedWith for Cmp { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Cmp, - |__lhs, __rhs| { - libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -252,16 +242,6 @@ impl LessThanComparable for Both { ); } impl PartiallyOrderedWith for Both { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Both, - |__lhs, __rhs| { - libcc2rs::is_lt(({ Both::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -347,16 +327,6 @@ impl LessThanComparable for OrdOnly { ); } impl PartiallyOrderedWith for OrdOnly { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - OrdOnly, - |__lhs, __rhs| { - libcc2rs::is_lt(({ OrdOnly::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -457,16 +427,6 @@ impl LessThanComparable for Inner { ); } impl PartiallyOrderedWith for Inner { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Inner, - |__lhs, __rhs| { - libcc2rs::is_lt(({ Inner::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -587,16 +547,6 @@ impl LessThanComparable for Outer { ); } impl PartiallyOrderedWith for Outer { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Outer, - |__lhs, __rhs| { - libcc2rs::is_lt(({ Outer::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -712,14 +662,6 @@ impl LessThanComparable for Secondary { ); } impl PartiallyOrderedWith for Secondary { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Secondary, - |__lhs, __rhs| { ({ Secondary::operator_lt((__lhs).clone(), (__rhs).clone(),) }) } - ); comparison!( PartiallyOrderedWith, greater, @@ -828,16 +770,6 @@ impl LessThanComparable for PtrMember { ); } impl PartiallyOrderedWith for PtrMember { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - PtrMember, - |__lhs, __rhs| { - libcc2rs::is_lt(({ PtrMember::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/operator_comparison_free.rs b/tests/unit/out/refcount/operator_comparison_free.rs index 00de564f9e..18079c2ff6 100644 --- a/tests/unit/out/refcount/operator_comparison_free.rs +++ b/tests/unit/out/refcount/operator_comparison_free.rs @@ -56,14 +56,6 @@ impl LessThanComparable for S { ); } impl PartiallyOrderedWith for S { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { ({ operator_lt_2((__lhs).clone(), (__rhs).clone(),) }) } - ); comparison!( PartiallyOrderedWith, greater, @@ -89,6 +81,26 @@ impl PartiallyOrderedWith for S { |__lhs, __rhs| { ({ operator_ge_5((__lhs).clone(), (__rhs).clone(),) }) } ); } +impl LessThanComparable for S { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { ({ operator_lt_6((__lhs).clone(), (__rhs.read()),) }) } + ); +} +impl LessThanComparable for i32 { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_7((__lhs.read()), (__rhs).clone(),) }) } + ); +} pub fn operator_eq_0(a: Ptr, b: Ptr) -> bool { return ({ a.with(|__s| __s.v) } == { b.with(|__s| __s.v) }); } diff --git a/tests/unit/out/refcount/operator_comparison_member.rs b/tests/unit/out/refcount/operator_comparison_member.rs index 933b683cb8..8d7bd371d0 100644 --- a/tests/unit/out/refcount/operator_comparison_member.rs +++ b/tests/unit/out/refcount/operator_comparison_member.rs @@ -79,14 +79,6 @@ impl LessThanComparable for S { ); } impl PartiallyOrderedWith for S { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { ({ S::operator_lt_3((__lhs).clone(), (__rhs).clone(),) }) } - ); comparison!( PartiallyOrderedWith, greater, @@ -112,6 +104,16 @@ impl PartiallyOrderedWith for S { |__lhs, __rhs| { ({ S::operator_ge((__lhs).clone(), (__rhs).clone(),) }) } ); } +impl LessThanComparable for S { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { ({ S::operator_lt_7((__lhs).clone(), (__rhs.read()),) }) } + ); +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); diff --git a/tests/unit/out/refcount/operator_comparison_mixed.rs b/tests/unit/out/refcount/operator_comparison_mixed.rs index 943927012d..203f3aada7 100644 --- a/tests/unit/out/refcount/operator_comparison_mixed.rs +++ b/tests/unit/out/refcount/operator_comparison_mixed.rs @@ -85,6 +85,26 @@ impl WeaklyEqualityComparableWith for i32 { |__lhs, __rhs| { ({ operator_ne_1((__lhs.read()), (__rhs).clone(),) }) } ); } +impl LessThanComparable for S { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { ({ S::operator_lt((__lhs).clone(), (__rhs.read()),) }) } + ); +} +impl LessThanComparable for i32 { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2((__lhs.read()), (__rhs).clone(),) }) } + ); +} impl Cpp17EqualityComparable for S { comparison!( Cpp17EqualityComparable, @@ -125,6 +145,26 @@ impl WeaklyEqualityComparableWith for f64 { |__lhs, __rhs| { ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone(),) }) } ); } +impl LessThanComparable for S { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + f64, + |__lhs, __rhs| { ({ S::operator_lt((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); +} +impl LessThanComparable for f64 { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); +} impl Cpp17EqualityComparable for S { comparison!( Cpp17EqualityComparable, @@ -165,6 +205,26 @@ impl WeaklyEqualityComparableWith for i64 { |__lhs, __rhs| { ({ operator_ne_1(((__lhs.read()) as i32), (__rhs).clone(),) }) } ); } +impl LessThanComparable for S { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + i64, + |__lhs, __rhs| { ({ S::operator_lt((__lhs).clone(), ((__rhs.read()) as i32),) }) } + ); +} +impl LessThanComparable for i64 { + comparison!( + LessThanComparable, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { ({ operator_lt_2(((__lhs.read()) as i32), (__rhs).clone(),) }) } + ); +} pub fn operator_eq_0(mut a: i32, b: Ptr) -> bool { return ({ a } == { b.with(|__s| __s.v) }); } diff --git a/tests/unit/out/refcount/operator_comparison_nonbool.rs b/tests/unit/out/refcount/operator_comparison_nonbool.rs index cb53da6855..dcb9bb8527 100644 --- a/tests/unit/out/refcount/operator_comparison_nonbool.rs +++ b/tests/unit/out/refcount/operator_comparison_nonbool.rs @@ -101,29 +101,6 @@ impl LessThanComparable for X { ); } impl PartiallyOrderedWith for X { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = i32, - X, - |__return, __lhs, __rhs| { - __return.write( - ({ - operator_lt_2({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }), - ); - }, - |__lhs, __rhs| { - (({ - operator_lt_2({ (*__lhs.upgrade().deref()) }, { - (*__rhs.upgrade().deref()) - }) - }) != 0) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -395,18 +372,6 @@ impl LessThanComparable for MyBool { ); } impl PartiallyOrderedWith for MyBool { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - MyBool, - |__lhs, __rhs| { - ({ (({ MyBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ MyBool::to_bool((__rhs).clone()) }) as i32) - }) - } - ); comparison!( PartiallyOrderedWith, greater, @@ -624,18 +589,6 @@ impl LessThanComparable for RefBool { ); } impl PartiallyOrderedWith for RefBool { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - RefBool, - |__lhs, __rhs| { - ({ (({ RefBool::to_bool((__lhs).clone()) }) as i32) } < { - (({ RefBool::to_bool((__rhs).clone()) }) as i32) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/operator_friend.rs b/tests/unit/out/refcount/operator_friend.rs index 5b150edcd8..1aaa95e6cc 100644 --- a/tests/unit/out/refcount/operator_friend.rs +++ b/tests/unit/out/refcount/operator_friend.rs @@ -116,14 +116,6 @@ impl LessThanComparable for DefaultedOrd { ); } impl PartiallyOrderedWith for DefaultedOrd { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - DefaultedOrd, - |__lhs, __rhs| { libcc2rs::is_lt(({ operator_cmp_1((__lhs).clone(), (__rhs).clone(),) })) } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/operator_other_member.rs b/tests/unit/out/refcount/operator_other_member.rs index 4f619f116f..686895afd6 100644 --- a/tests/unit/out/refcount/operator_other_member.rs +++ b/tests/unit/out/refcount/operator_other_member.rs @@ -107,16 +107,6 @@ impl LessThanComparable for S { ); } impl PartiallyOrderedWith for S { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { - ({ ({ S::to_i32((__lhs).clone()) }) } < { ({ S::to_i32((__rhs).clone()) }) }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/operator_three_way.rs b/tests/unit/out/refcount/operator_three_way.rs index 72d01074f1..e071bc30a1 100644 --- a/tests/unit/out/refcount/operator_three_way.rs +++ b/tests/unit/out/refcount/operator_three_way.rs @@ -72,16 +72,6 @@ impl LessThanComparable for S { ); } impl PartiallyOrderedWith for S { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { - libcc2rs::is_lt(({ S::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/operator_traits.rs b/tests/unit/out/refcount/operator_traits.rs index f224c1efb6..b2d233da08 100644 --- a/tests/unit/out/refcount/operator_traits.rs +++ b/tests/unit/out/refcount/operator_traits.rs @@ -147,16 +147,6 @@ impl LessThanComparable for Cmp { ); } impl PartiallyOrderedWith for Cmp { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Cmp, - |__lhs, __rhs| { - libcc2rs::is_lt(({ Cmp::operator_cmp((__lhs).clone(), (__rhs).clone()) })) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/pair_converting_construction.rs b/tests/unit/out/refcount/pair_converting_construction.rs index 46069179fa..2aafb3b871 100644 --- a/tests/unit/out/refcount/pair_converting_construction.rs +++ b/tests/unit/out/refcount/pair_converting_construction.rs @@ -93,16 +93,6 @@ impl LessThanComparable for Meters { ); } impl PartiallyOrderedWith for Meters { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Meters, - |__lhs, __rhs| { - ({ ({ Meters::to_i32((__lhs).clone()) }) } < { ({ Meters::to_i32((__rhs).clone()) }) }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/refcount/vector_iter_range_ctor.rs b/tests/unit/out/refcount/vector_iter_range_ctor.rs index 845697ca66..dd12352407 100644 --- a/tests/unit/out/refcount/vector_iter_range_ctor.rs +++ b/tests/unit/out/refcount/vector_iter_range_ctor.rs @@ -99,18 +99,6 @@ impl LessThanComparable for Reading { ); } impl PartiallyOrderedWith for Reading { - comparison!( - PartiallyOrderedWith, - less, - is_less, - LessResult = bool, - Reading, - |__lhs, __rhs| { - ({ ({ Reading::to_i64((__lhs).clone()) }) } < { - ({ Reading::to_i64((__rhs).clone()) }) - }) - } - ); comparison!( PartiallyOrderedWith, greater, diff --git a/tests/unit/out/unsafe/operator_comparison_defaulted.rs b/tests/unit/out/unsafe/operator_comparison_defaulted.rs index c3f403e865..672bc962c7 100644 --- a/tests/unit/out/unsafe/operator_comparison_defaulted.rs +++ b/tests/unit/out/unsafe/operator_comparison_defaulted.rs @@ -120,16 +120,6 @@ impl LessThanComparableUnsafe for Cmp { ); } impl PartiallyOrderedWithUnsafe for Cmp { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Cmp, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -233,16 +223,6 @@ impl LessThanComparableUnsafe for Both { ); } impl PartiallyOrderedWithUnsafe for Both { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Both, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { Both::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -323,16 +303,6 @@ impl LessThanComparableUnsafe for OrdOnly { ); } impl PartiallyOrderedWithUnsafe for OrdOnly { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - OrdOnly, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { OrdOnly::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -428,16 +398,6 @@ impl LessThanComparableUnsafe for Inner { ); } impl PartiallyOrderedWithUnsafe for Inner { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Inner, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { Inner::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -554,16 +514,6 @@ impl LessThanComparableUnsafe for Outer { ); } impl PartiallyOrderedWithUnsafe for Outer { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Outer, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { Outer::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -677,14 +627,6 @@ impl LessThanComparableUnsafe for Secondary { ); } impl PartiallyOrderedWithUnsafe for Secondary { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Secondary, - |__lhs, __rhs| { (unsafe { Secondary::operator_lt(&raw const (*__lhs), __rhs,) }) } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -789,16 +731,6 @@ impl LessThanComparableUnsafe for PtrMember { ); } impl PartiallyOrderedWithUnsafe for PtrMember { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - PtrMember, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { PtrMember::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/operator_comparison_free.rs b/tests/unit/out/unsafe/operator_comparison_free.rs index e8f9b45eed..91b4941e44 100644 --- a/tests/unit/out/unsafe/operator_comparison_free.rs +++ b/tests/unit/out/unsafe/operator_comparison_free.rs @@ -68,19 +68,6 @@ impl LessThanComparableUnsafe for S { ); } impl PartiallyOrderedWithUnsafe for S { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { - (unsafe { - let _a: *const S = __lhs; - operator_lt_2(_a, __rhs) - }) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -121,6 +108,36 @@ impl PartiallyOrderedWithUnsafe for S { } ); } +impl LessThanComparableUnsafe for S { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { + (unsafe { + let _a: *const S = __lhs; + operator_lt_6(_a, (*__rhs)) + }) + } + ); +} +impl LessThanComparableUnsafe for i32 { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + (unsafe { + let _a: i32 = (*__lhs); + operator_lt_7(_a, __rhs) + }) + } + ); +} pub unsafe fn operator_eq_0(a: *const S, b: *const S) -> bool { return (((*a).v) == ((*b).v)); } diff --git a/tests/unit/out/unsafe/operator_comparison_member.rs b/tests/unit/out/unsafe/operator_comparison_member.rs index 9f9afb2dbc..e7c8542c87 100644 --- a/tests/unit/out/unsafe/operator_comparison_member.rs +++ b/tests/unit/out/unsafe/operator_comparison_member.rs @@ -76,14 +76,6 @@ impl LessThanComparableUnsafe for S { ); } impl PartiallyOrderedWithUnsafe for S { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { (unsafe { S::operator_lt_3(&raw const (*__lhs), __rhs,) }) } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -109,6 +101,16 @@ impl PartiallyOrderedWithUnsafe for S { |__lhs, __rhs| { (unsafe { S::operator_ge(&raw const (*__lhs), __rhs,) }) } ); } +impl LessThanComparableUnsafe for S { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { (unsafe { S::operator_lt_7(&raw const (*__lhs), (*__rhs),) }) } + ); +} pub fn main() { unsafe { __cpp2rust_init_globals(); diff --git a/tests/unit/out/unsafe/operator_comparison_mixed.rs b/tests/unit/out/unsafe/operator_comparison_mixed.rs index c396b38642..7abfb2205b 100644 --- a/tests/unit/out/unsafe/operator_comparison_mixed.rs +++ b/tests/unit/out/unsafe/operator_comparison_mixed.rs @@ -92,6 +92,31 @@ impl WeaklyEqualityComparableWithUnsafe for i32 { } ); } +impl LessThanComparableUnsafe for S { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + i32, + |__lhs, __rhs| { (unsafe { S::operator_lt(&raw const (*__lhs), (*__rhs),) }) } + ); +} +impl LessThanComparableUnsafe for i32 { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + (unsafe { + let _a: i32 = (*__lhs); + operator_lt_2(_a, __rhs) + }) + } + ); +} impl Cpp17EqualityComparableUnsafe for S { comparison_unsafe!( Cpp17EqualityComparableUnsafe, @@ -142,6 +167,31 @@ impl WeaklyEqualityComparableWithUnsafe for f64 { } ); } +impl LessThanComparableUnsafe for S { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + f64, + |__lhs, __rhs| { (unsafe { S::operator_lt(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); +} +impl LessThanComparableUnsafe for f64 { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_lt_2(_a, __rhs) + }) + } + ); +} impl Cpp17EqualityComparableUnsafe for S { comparison_unsafe!( Cpp17EqualityComparableUnsafe, @@ -192,6 +242,31 @@ impl WeaklyEqualityComparableWithUnsafe for i64 { } ); } +impl LessThanComparableUnsafe for S { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + i64, + |__lhs, __rhs| { (unsafe { S::operator_lt(&raw const (*__lhs), ((*__rhs) as i32),) }) } + ); +} +impl LessThanComparableUnsafe for i64 { + comparison_unsafe!( + LessThanComparableUnsafe, + less, + is_less, + Result = bool, + S, + |__lhs, __rhs| { + (unsafe { + let _a: i32 = ((*__lhs) as i32); + operator_lt_2(_a, __rhs) + }) + } + ); +} pub unsafe fn operator_eq_0(mut a: i32, b: *const S) -> bool { return ((a) == ((*b).v)); } diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index 3f93f0fe50..b379e47a2e 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -92,27 +92,6 @@ impl LessThanComparableUnsafe for X { ); } impl PartiallyOrderedWithUnsafe for X { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = i32, - X, - |__return, __lhs, __rhs| { - __return.write( - (unsafe { - let _a: X = (*__lhs); - operator_lt_2(_a, (*__rhs)) - }), - ); - }, - |__lhs, __rhs| { - ((unsafe { - let _a: X = (*__lhs); - operator_lt_2(_a, (*__rhs)) - }) != 0) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -355,17 +334,6 @@ impl LessThanComparableUnsafe for MyBool { ); } impl PartiallyOrderedWithUnsafe for MyBool { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - MyBool, - |__lhs, __rhs| { - (((unsafe { MyBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { MyBool::to_bool(&raw const (*__rhs)) }) as i32)) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, @@ -561,17 +529,6 @@ impl LessThanComparableUnsafe for RefBool { ); } impl PartiallyOrderedWithUnsafe for RefBool { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - RefBool, - |__lhs, __rhs| { - (((unsafe { RefBool::to_bool(&raw const (*__lhs)) }) as i32) - < ((unsafe { RefBool::to_bool(&raw const (*__rhs)) }) as i32)) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/operator_friend.rs b/tests/unit/out/unsafe/operator_friend.rs index 6ffdf08d22..9d6722291e 100644 --- a/tests/unit/out/unsafe/operator_friend.rs +++ b/tests/unit/out/unsafe/operator_friend.rs @@ -136,21 +136,6 @@ impl LessThanComparableUnsafe for DefaultedOrd { ); } impl PartiallyOrderedWithUnsafe for DefaultedOrd { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - DefaultedOrd, - |__lhs, __rhs| { - libcc2rs::is_lt( - (unsafe { - let _arg0: *const DefaultedOrd = __lhs; - operator_cmp_1(_arg0, __rhs) - }), - ) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/operator_other_member.rs b/tests/unit/out/unsafe/operator_other_member.rs index f5887a379b..35306a244c 100644 --- a/tests/unit/out/unsafe/operator_other_member.rs +++ b/tests/unit/out/unsafe/operator_other_member.rs @@ -105,17 +105,6 @@ impl LessThanComparableUnsafe for S { ); } impl PartiallyOrderedWithUnsafe for S { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { - ((unsafe { S::to_i32(&raw const (*__lhs)) }) - < (unsafe { S::to_i32(&raw const (*__rhs)) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/operator_three_way.rs b/tests/unit/out/unsafe/operator_three_way.rs index 678a620986..5a93451f72 100644 --- a/tests/unit/out/unsafe/operator_three_way.rs +++ b/tests/unit/out/unsafe/operator_three_way.rs @@ -69,16 +69,6 @@ impl LessThanComparableUnsafe for S { ); } impl PartiallyOrderedWithUnsafe for S { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - S, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { S::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/operator_traits.rs b/tests/unit/out/unsafe/operator_traits.rs index bfe7787829..c5b2f53a6e 100644 --- a/tests/unit/out/unsafe/operator_traits.rs +++ b/tests/unit/out/unsafe/operator_traits.rs @@ -135,16 +135,6 @@ impl LessThanComparableUnsafe for Cmp { ); } impl PartiallyOrderedWithUnsafe for Cmp { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Cmp, - |__lhs, __rhs| { - libcc2rs::is_lt((unsafe { Cmp::operator_cmp(&raw const (*__lhs), __rhs) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/pair_converting_construction.rs b/tests/unit/out/unsafe/pair_converting_construction.rs index d340ef48f8..5e996e7a47 100644 --- a/tests/unit/out/unsafe/pair_converting_construction.rs +++ b/tests/unit/out/unsafe/pair_converting_construction.rs @@ -90,17 +90,6 @@ impl LessThanComparableUnsafe for Meters { ); } impl PartiallyOrderedWithUnsafe for Meters { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Meters, - |__lhs, __rhs| { - ((unsafe { Meters::to_i32(&raw const (*__lhs)) }) - < (unsafe { Meters::to_i32(&raw const (*__rhs)) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index be5d033958..25a02a8550 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -90,17 +90,6 @@ impl LessThanComparableUnsafe for Reading { ); } impl PartiallyOrderedWithUnsafe for Reading { - comparison_unsafe!( - PartiallyOrderedWithUnsafe, - less, - is_less, - LessResult = bool, - Reading, - |__lhs, __rhs| { - ((unsafe { Reading::to_i64(&raw const (*__lhs)) }) - < (unsafe { Reading::to_i64(&raw const (*__rhs)) })) - } - ); comparison_unsafe!( PartiallyOrderedWithUnsafe, greater, From a8cfa29a465ae53fac631aa7a8f2fd136deb859f Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Sat, 5 Dec 2026 12:54:14 +0000 Subject: [PATCH 17/17] Fix macos --- cpp2rust/converter/rules/rules_loader.cpp | 5 + .../out/refcount/utility.arg.requirements.rs | 138 +++++++++++------- .../out/unsafe/utility.arg.requirements.rs | 28 +++- .../utility.arg.requirements.cpp | 8 +- 4 files changed, 120 insertions(+), 59 deletions(-) diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index 9785f22c3a..b6f09835f8 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -53,6 +53,11 @@ class RuleUsageCollector } bool VisitCXXRecordDecl(clang::CXXRecordDecl *decl) { + if (auto *spec = + clang::dyn_cast(decl); + spec && IsLibraryOnlySpecialization(spec)) { + return true; + } if (decl->isThisDeclarationADefinition() && !decl->isDependentType() && IsConvertibleCXXRecordDecl(decl) && (decl->isStruct() || decl->isClass()) && !decl->isAbstract()) { diff --git a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs index 73cd09c3c5..7193cb942c 100644 --- a/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/refcount/utility.arg.requirements.rs @@ -71,11 +71,39 @@ pub fn test_0() { Rc::new(RefCell::new(tickets.decay().end())); if as Cpp17EqualityComparable>::is_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { __last.borrow().clone() } else { let mut __write = __it.borrow().clone(); __it.borrow_mut().iter_inc(); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) { if !::is_equal( LvalueRef::>::bind(__write.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), ) { __write.iter_inc(); __write.iter_deref().write(__it.borrow().iter_deref().read()); } __it.borrow_mut().iter_inc(); } __write.iter_inc(); __write } })); - assert!(((*last.borrow()).iter_distance(&tickets.decay().begin()) == 3_isize)); assert!( - ({ { (*tickets.borrow())[1_usize] }.number } == 7) + (({ { (*tickets.borrow())[0_usize] }.number } == 4) + && ({ { (*tickets.borrow())[1_usize] }.number } == 7)) && ({ { (*tickets.borrow())[2_usize] }.number } == 9) ); + { + (*last.borrow_mut()).iter_inc(); + }; + assert!(WeaklyEqualityComparableWith::is_not_equal( + LvalueRef::>>::bind( + last.as_pointer() + ), + LvalueRef::>>::bind( + Rc::new(RefCell::new(tickets.decay().end())).as_pointer() + ), + )); + { + (*last.borrow_mut()).iter_inc(); + }; + assert!( + match (Rc::new(RefCell::new(tickets.decay().end())).as_pointer(),) { + (__tmp_4,) => { + Cpp17EqualityComparable::is_equal( + LvalueRef::>>::bind( + last.as_pointer(), + ), + LvalueRef::>>::bind( + (__tmp_4).clone(), + ), + ) + } + } + ); } #[derive( Copy, @@ -340,16 +368,16 @@ pub fn test_1() { table28_result_convertible_to_bool_Ticket { number: 7 }, table28_result_convertible_to_bool_Ticket { number: 9 }, ]))); - assert!(( ({ let __tmp_4 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 9 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_4.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . number ) == 9 ) ); - assert!(match (Rc::new(RefCell::new(({ let __tmp_6 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 5 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_6.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(tickets .decay() .end() )).as_pointer(),) { (__tmp_5, __tmp_7,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_5 ).clone()), LvalueRef:: >>::bind((__tmp_7 ).clone()), ) } } ); + assert!(( ({ let __tmp_5 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 9 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_5.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . number ) == 9 ) ); + assert!(match (Rc::new(RefCell::new(({ let __tmp_7 : Value = Rc::new(RefCell::new(table28_result_convertible_to_bool_Ticket { number : 5 , } )); {let __it: Value > = Rc::new(RefCell::new(tickets .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(tickets .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind((__tmp_7.as_pointer()).clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(tickets .decay() .end() )).as_pointer(),) { (__tmp_6, __tmp_8,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_6 ).clone()), LvalueRef:: >>::bind((__tmp_8 ).clone()), ) } } ); let badges: Value> = Rc::new(RefCell::new(Vec::from([ table28_result_convertible_to_bool_Badge { id: 1 }, table28_result_convertible_to_bool_Badge { id: 2 }, table28_result_convertible_to_bool_Badge { id: 3 }, ]))); - assert!(( ({ let __tmp_8 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_8.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . id ) == 2 ) ); - assert!(match (Rc::new(RefCell::new(({ let __tmp_10 : Value = Rc::new(RefCell::new(8 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_10.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(badges .decay() .end() )).as_pointer(),) { (__tmp_9, __tmp_11,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_9 ).clone()), LvalueRef:: >>::bind((__tmp_11 ).clone()), ) } } ); + assert!(( ({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) .iter_deref() .with(|__s| __s . id ) == 2 ) ); + assert!(match (Rc::new(RefCell::new(({ let __tmp_11 : Value = Rc::new(RefCell::new(8 )); {let __it: Value > = Rc::new(RefCell::new(badges .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(badges .decay() .end() )); while as WeaklyEqualityComparableWith>::is_not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), ) && !>::is_equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_11.as_pointer().clone()), ) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(badges .decay() .end() )).as_pointer(),) { (__tmp_10, __tmp_12,) => { Cpp17EqualityComparable::is_equal( LvalueRef:: >>::bind((__tmp_10 ).clone()), LvalueRef:: >>::bind((__tmp_12 ).clone()), ) } } ); } thread_local!( pub static less_calls_2: Value = Rc::new(RefCell::new(0)); @@ -445,11 +473,11 @@ pub fn test_3() { table29_member_operator_Version { major: 2, minor: 0 }, ]))); { - let mut __tmp_12 = { versions.decay().begin() }; - let __n = versions.decay().end().iter_distance(&__tmp_12); + let mut __tmp_13 = { versions.decay().begin() }; + let __n = versions.decay().end().iter_distance(&__tmp_13); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_12.iter_at(__x), &__tmp_12.iter_at(__y))); - reorder(__order, |__i| __tmp_12.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_13.iter_at(__x), &__tmp_13.iter_at(__y))); + reorder(__order, |__i| __tmp_13.iter_at(__i)); }; assert!( ({ { (*versions.borrow())[0_usize] }.major } == 1) @@ -468,16 +496,16 @@ pub fn test_3() { Map, Value)>, > = Rc::new(RefCell::new(Map::new())); match (new_version.as_pointer(),) { - (__tmp_13,) => ({ (*downloads.borrow_mut()).subscript(__tmp_13, || 0_i32) }), + (__tmp_14,) => ({ (*downloads.borrow_mut()).subscript(__tmp_14, || 0_i32) }), } .write(7); match (old_version.as_pointer(),) { - (__tmp_14,) => ({ (*downloads.borrow_mut()).subscript(__tmp_14, || 0_i32) }), + (__tmp_15,) => ({ (*downloads.borrow_mut()).subscript(__tmp_15, || 0_i32) }), } .write(3); { match (new_version.as_pointer(),) { - (__tmp_15,) => ({ (*downloads.borrow_mut()).subscript(__tmp_15, || 0_i32) }), + (__tmp_16,) => ({ (*downloads.borrow_mut()).subscript(__tmp_16, || 0_i32) }), } .with_mut(|__v| *__v = *__v + 1) }; @@ -500,8 +528,8 @@ pub fn test_3() { ); assert!( ((match (new_version.as_pointer(),) { - (__tmp_16,) => { - ({ (*downloads.borrow_mut()).subscript(__tmp_16, || 0_i32) }) + (__tmp_17,) => { + ({ (*downloads.borrow_mut()).subscript(__tmp_17, || 0_i32) }) } } .read()) @@ -841,100 +869,100 @@ impl ThreeWayComparable for table29_other_operator_shapes_Length { pub fn test_5() { assert!( ({ - let __tmp_17: Value = + let __tmp_18: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 3, })); - let __tmp_18: Value = + let __tmp_19: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Weight { grams: 5, })); if ::is_less( LvalueRef::>::bind( - (__tmp_17.as_pointer()).clone(), + (__tmp_18.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_18.as_pointer()).clone(), + (__tmp_19.as_pointer()).clone(), ), ) { - (__tmp_18.as_pointer()) + (__tmp_19.as_pointer()) } else { - (__tmp_17.as_pointer()) + (__tmp_18.as_pointer()) } .with(|__s| __s.grams) } == 5) ); assert!( ({ - let __tmp_19: Value = + let __tmp_20: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 50, })); - let __tmp_20: Value = + let __tmp_21: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Height { millimeters: 30, })); if ::is_less( LvalueRef::>::bind( - (__tmp_19.as_pointer()).clone(), + (__tmp_20.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_20.as_pointer()).clone(), + (__tmp_21.as_pointer()).clone(), ), ) { - (__tmp_19.as_pointer()) - } else { (__tmp_20.as_pointer()) + } else { + (__tmp_21.as_pointer()) } .with(|__s| __s.millimeters) } == 30) ); assert!( ({ - let __tmp_21: Value = + let __tmp_22: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 7, })); - let __tmp_22: Value = + let __tmp_23: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Depth { millimeters: 4, })); if ::is_less( LvalueRef::>::bind( - (__tmp_21.as_pointer()).clone(), + (__tmp_22.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_22.as_pointer()).clone(), + (__tmp_23.as_pointer()).clone(), ), ) { - (__tmp_22.as_pointer()) + (__tmp_23.as_pointer()) } else { - (__tmp_21.as_pointer()) + (__tmp_22.as_pointer()) } .with(|__s| __s.millimeters) } == 7) ); assert!( ({ - let __tmp_23: Value = + let __tmp_24: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Length { meters: 9, })); - let __tmp_24: Value = + let __tmp_25: Value = Rc::new(RefCell::new(table29_other_operator_shapes_Length { meters: 2, })); if ::is_less( LvalueRef::>::bind( - (__tmp_23.as_pointer()).clone(), + (__tmp_24.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_24.as_pointer()).clone(), + (__tmp_25.as_pointer()).clone(), ), ) { - (__tmp_23.as_pointer()) - } else { (__tmp_24.as_pointer()) + } else { + (__tmp_25.as_pointer()) } .with(|__s| __s.meters) } == 2) @@ -1136,50 +1164,50 @@ impl LessThanComparable for table29_result_convertible_to_bool_Priority { pub fn test_6() { assert!( ({ - let __tmp_25: Value = + let __tmp_26: Value = Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { level: 2, })); - let __tmp_26: Value = + let __tmp_27: Value = Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { level: 6, })); if ::is_less( LvalueRef::>::bind( - (__tmp_25.as_pointer()).clone(), + (__tmp_26.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_26.as_pointer()).clone(), + (__tmp_27.as_pointer()).clone(), ), ) { - (__tmp_26.as_pointer()) + (__tmp_27.as_pointer()) } else { - (__tmp_25.as_pointer()) + (__tmp_26.as_pointer()) } .with(|__s| __s.level) } == 6) ); assert!( ({ - let __tmp_27: Value = + let __tmp_28: Value = Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { level: 6, })); - let __tmp_28: Value = + let __tmp_29: Value = Rc::new(RefCell::new(table29_result_convertible_to_bool_Priority { level: 2, })); if ::is_less( LvalueRef::>::bind( - (__tmp_27.as_pointer()).clone(), + (__tmp_28.as_pointer()).clone(), ), LvalueRef::>::bind( - (__tmp_28.as_pointer()).clone(), + (__tmp_29.as_pointer()).clone(), ), ) { - (__tmp_27.as_pointer()) - } else { (__tmp_28.as_pointer()) + } else { + (__tmp_29.as_pointer()) } .with(|__s| __s.level) } == 2) @@ -1191,11 +1219,11 @@ pub fn test_6() { table29_result_convertible_to_bool_Priority { level: 3 }, ]))); { - let mut __tmp_29 = { priorities.decay().begin() }; - let __n = priorities.decay().end().iter_distance(&__tmp_29); + let mut __tmp_30 = { priorities.decay().begin() }; + let __n = priorities.decay().end().iter_distance(&__tmp_30); let mut __order: Vec = (0..__n).collect(); - __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_29.iter_at(__x), &__tmp_29.iter_at(__y))); - reorder(__order, |__i| __tmp_29.iter_at(__i)); + __order.sort_by(|&__x, &__y| cpp_cmp(&__tmp_30.iter_at(__x), &__tmp_30.iter_at(__y))); + reorder(__order, |__i| __tmp_30.iter_at(__i)); }; assert!(({ { (*priorities.borrow())[0_usize] }.level } == 1)); assert!(({ { (*priorities.borrow())[1_usize] }.level } == 3)); diff --git a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs index 72dcbece5e..54392adba2 100644 --- a/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs +++ b/tests/std/library/requirements/utility.requirements/out/unsafe/utility.arg.requirements.rs @@ -82,8 +82,32 @@ pub unsafe fn test_0() { let mut __tmp_5 = { tickets.end() }; if as Cpp17EqualityComparableUnsafe>::is_equal( LvalueRefUnsafe:: >>::bind(&__tmp_4 ), LvalueRefUnsafe:: >>::bind(&__tmp_5 ), ) { (__tmp_5 ).clone() } else { let mut __write = __tmp_4 .clone(); let mut __it = (__tmp_4 ).clone(); __it.iter_inc(); while as WeaklyEqualityComparableWithUnsafe>::is_not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_5 ), ) { if !::is_equal( LvalueRefUnsafe::>::bind(__write.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ) { __write.iter_inc(); *__write.iter_deref() = (*__it.iter_deref()).clone(); } __it.iter_inc(); } __write.iter_inc(); __write } }; - assert!(((last.iter_distance(&tickets.begin())) == (3_isize))); - assert!(((tickets[(1_usize)].number) == (7)) && ((tickets[(2_usize)].number) == (9))); + assert!( + (((tickets[(0_usize)].number) == (4)) && ((tickets[(1_usize)].number) == (7))) + && ((tickets[(2_usize)].number) == (9)) + ); + { + last.iter_inc(); + }; + assert!(WeaklyEqualityComparableWithUnsafe::is_not_equal( + LvalueRefUnsafe::>>::bind( + &last + ), + LvalueRefUnsafe::>>::bind( + &tickets.end() + ), + )); + { + last.iter_inc(); + }; + assert!(Cpp17EqualityComparableUnsafe::is_equal( + LvalueRefUnsafe::>>::bind( + &last + ), + LvalueRefUnsafe::>>::bind( + &tickets.end() + ), + )); } #[repr(C)] #[derive( diff --git a/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp b/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp index 11a89c1996..37d22cb042 100644 --- a/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp +++ b/tests/std/library/requirements/utility.requirements/utility.arg.requirements.cpp @@ -19,8 +19,12 @@ void test() { assert(std::find(tickets.begin(), tickets.end(), Ticket{7})->number == 7); assert(std::find(tickets.begin(), tickets.end(), Ticket{5}) == tickets.end()); auto last = std::unique(tickets.begin(), tickets.end()); - assert(last - tickets.begin() == 3); - assert(tickets[1].number == 7 && tickets[2].number == 9); + assert(tickets[0].number == 4 && tickets[1].number == 7 && + tickets[2].number == 9); + ++last; + assert(last != tickets.end()); + ++last; + assert(last == tickets.end()); } } // namespace table28_equal_operator

>::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&(P { x : 1 , } )), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( - &raw const p.begin().iter_add(1_isize) + &p.begin().iter_add(1_isize) ), ) )); diff --git a/tests/unit/out/unsafe/global_call_temporaries.rs b/tests/unit/out/unsafe/global_call_temporaries.rs index a24e70a1e8..3287e46f21 100644 --- a/tests/unit/out/unsafe/global_call_temporaries.rs +++ b/tests/unit/out/unsafe/global_call_temporaries.rs @@ -20,10 +20,12 @@ pub static mut selected_1: std::cell::LazyCell = std::cell::LazyCell::new(| { let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -46,10 +48,12 @@ pub static mut assigned_4: std::cell::LazyCell = std::cell::LazyCell::new(| (*{ let __a: *const _ = &mut __tmp_2; let __b: *const _ = &mut __tmp_3; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -71,10 +75,12 @@ pub static mut accumulated_5: std::cell::LazyCell = std::cell::LazyCell::ne (*{ let __a: *const _ = &mut __tmp_4; let __b: *const _ = &mut __tmp_5; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -135,10 +141,12 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_8; let __b: *const _ = &mut __tmp_9; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -154,10 +162,12 @@ pub static mut aggregate_selected_9: std::cell::LazyCell = (*{ let __a: *const _ = &mut __tmp_11; let __b: *const _ = &mut __tmp_12; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -182,10 +192,12 @@ pub static mut mapped_selected_12: std::cell::LazyCell = let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_13; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -205,10 +217,12 @@ static mut value_14: std::cell::LazyCell = std::cell::LazyCell::new(|| un (*{ let __a: *const _ = &mut (*std::cell::LazyCell::force_mut(&mut *&raw mut left_10)); let __b: *const _ = &mut __tmp_14; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -249,10 +263,12 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_16; let __b: *const _ = &mut __tmp_17; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -268,10 +284,12 @@ static mut aggregate_static_15: std::cell::LazyCell = std::cell::LazyCell:: (*{ let __a: *const _ = &mut __tmp_19; let __b: *const _ = &mut __tmp_20; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/map.rs b/tests/unit/out/unsafe/map.rs index 8e180a7086..6d9de3db75 100644 --- a/tests/unit/out/unsafe/map.rs +++ b/tests/unit/out/unsafe/map.rs @@ -227,8 +227,8 @@ unsafe fn main_0() -> i32 { >::from(m.find(&10_i16)); let mut x1: u32 = if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind(&raw const end), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&end), )) { 0_u32 } else { @@ -237,11 +237,9 @@ unsafe fn main_0() -> i32 { assert!(((x1) == (4_u32))); let mut x2: u32 = if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( - &raw const const_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const >::from((end).clone()), + &>::from((end).clone()), ), )) { 0_u32 @@ -251,10 +249,8 @@ unsafe fn main_0() -> i32 { assert!(((x2) == (0_u32))); let mut x3: u32 = if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind( - &raw const m.end(), - ), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&m.end()), )) { 0_u32 } else { @@ -263,11 +259,9 @@ unsafe fn main_0() -> i32 { assert!(((x3) == (4_u32))); let mut x4: u32 = if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( - &raw const const_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const >::from(m.end()), + &>::from(m.end()), ), )) { 0_u32 @@ -318,11 +312,9 @@ unsafe fn main_0() -> i32 { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( LvalueRefUnsafe::>>::bind( - &raw const m.find(&4_i16) - ), - LvalueRefUnsafe::>>::bind( - &raw const m.end() + &m.find(&4_i16) ), + LvalueRefUnsafe::>>::bind(&m.end()), ) )); (*r).erase(&(it4).clone()); @@ -330,11 +322,9 @@ unsafe fn main_0() -> i32 { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const m.find(&4_i16) - ), - LvalueRefUnsafe::>>::bind( - &raw const m.end() + &m.find(&4_i16) ), + LvalueRefUnsafe::>>::bind(&m.end()), ) )); { @@ -368,11 +358,9 @@ unsafe fn main_0() -> i32 { let mut next: UnsafeBidirectionalIterator<(i16, u32)> = m.erase(&(cit).clone()); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&next), LvalueRefUnsafe::>>::bind( - &raw const next - ), - LvalueRefUnsafe::>>::bind( - &raw const m.find(&8_i16) + &m.find(&8_i16) ), ) )); @@ -381,23 +369,17 @@ unsafe fn main_0() -> i32 { }; assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &raw const next - ), - LvalueRefUnsafe::>>::bind( - &raw const m.end() - ), + LvalueRefUnsafe::>>::bind(&next), + LvalueRefUnsafe::>>::bind(&m.end()), ) )); assert!((((*r).len()) == (3_usize))); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const m.find(&8_i16) - ), - LvalueRefUnsafe::>>::bind( - &raw const m.end() + &m.find(&8_i16) ), + LvalueRefUnsafe::>>::bind(&m.end()), ) )); let mut other_map: UnsafeMap<(i32, i64), ((i32, i64), f64)> = UnsafeMap::new(); diff --git a/tests/unit/out/unsafe/map_key_identity.rs b/tests/unit/out/unsafe/map_key_identity.rs index 0a6b5aed9c..86ef2ec38a 100644 --- a/tests/unit/out/unsafe/map_key_identity.rs +++ b/tests/unit/out/unsafe/map_key_identity.rs @@ -120,32 +120,26 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((((*a).value) == (11)) && (((*b).value) == (22))) as i32)) != 0; ok = ((ok as i32) & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&a_it), LvalueRefUnsafe::>>::bind( - &raw const a_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const distinct.find(&distinct_a), + &distinct.find(&distinct_a), ), ))) as i32)) != 0; ok = ((ok as i32) & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&b_it), LvalueRefUnsafe::>>::bind( - &raw const b_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const distinct.find(&distinct_b), + &distinct.find(&distinct_b), ), ))) as i32)) != 0; ok = ((ok as i32) & ((ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&b_it), LvalueRefUnsafe::>>::bind( - &raw const b_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const distinct.end(), + &distinct.end(), ), ), )) as i32)) @@ -208,10 +202,10 @@ unsafe fn main_0() -> i32 { & ((ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( LvalueRefUnsafe::>>::bind( - &raw const first_it, + &first_it, ), LvalueRefUnsafe::>>::bind( - &raw const equivalent.end(), + &equivalent.end(), ), ), )) as i32)) @@ -221,10 +215,10 @@ unsafe fn main_0() -> i32 { & ((ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const first_it, + &first_it, ), LvalueRefUnsafe::>>::bind( - &raw const equivalent.find(&equivalent_a), + &equivalent.find(&equivalent_a), ), ), )) as i32)) @@ -233,10 +227,10 @@ unsafe fn main_0() -> i32 { & ((ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const first_it, + &first_it, ), LvalueRefUnsafe::>>::bind( - &raw const equivalent.find(&equivalent_b), + &equivalent.find(&equivalent_b), ), ), )) as i32)) @@ -280,10 +274,10 @@ unsafe fn main_0() -> i32 { & ((ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const first_it, + &first_it, ), LvalueRefUnsafe::>>::bind( - &raw const equivalent.find(&equivalent_a), + &equivalent.find(&equivalent_a), ), ), )) as i32)) @@ -326,11 +320,9 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((matched) == (matched_again)) as i32)) != 0; ok = ((ok as i32) & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( - &raw const matched_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const matching.find(&matching_b), + &matching.find(&matching_b), ), ))) as i32)) != 0; @@ -347,11 +339,9 @@ unsafe fn main_0() -> i32 { ok = ((ok as i32) & (((matching.len()) == (2_usize)) as i32)) != 0; ok = ((ok as i32) & ((ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&matched_it), LvalueRefUnsafe::>>::bind( - &raw const matched_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const matching.find(&matching_a), + &matching.find(&matching_a), ), ))) as i32)) != 0; diff --git a/tests/unit/out/unsafe/map_try_emplace.rs b/tests/unit/out/unsafe/map_try_emplace.rs index 6ad18231c0..119de50a7a 100644 --- a/tests/unit/out/unsafe/map_try_emplace.rs +++ b/tests/unit/out/unsafe/map_try_emplace.rs @@ -219,7 +219,7 @@ unsafe fn main_0() -> i32 { & ((((result.1) as i32) == (!(hit) as i32)) as i32)) != 0; - let mut found : bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe:: >>::bind(&raw const result .0 ), LvalueRefUnsafe:: >>::bind(&raw const m .find(&key ) ), )) ; + let mut found : bool = ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe:: >>::bind(&result .0 ), LvalueRefUnsafe:: >>::bind(&m .find(&key ) ), )) ; ok = ((ok as i32) & (found as i32)) != 0; ok = ((ok as i32) & ((((*result.0.iter_deref()).0) == (key)) diff --git a/tests/unit/out/unsafe/max.rs b/tests/unit/out/unsafe/max.rs index 10f010b582..f7b84612b1 100644 --- a/tests/unit/out/unsafe/max.rs +++ b/tests/unit/out/unsafe/max.rs @@ -82,7 +82,7 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = &mut x1; let __b: *const _ = &mut x2; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -94,7 +94,7 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = &mut x3; let __b: *const _ = &mut x4; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -106,7 +106,7 @@ unsafe fn main_0() -> i32 { let mut r3: i32 = (*{ let __a: *const _ = p1; let __b: *const _ = &mut x2; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -118,7 +118,7 @@ unsafe fn main_0() -> i32 { let mut r4: i32 = (*{ let __a: *const _ = p2; let __b: *const _ = &mut x3; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -133,7 +133,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_0; let __b: *const _ = &mut __tmp_1; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -149,20 +149,26 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { values.as_mut_ptr() }; let mut __tmp_3 = { values.as_mut_ptr().offset((4) as isize) }; let mut __best = __tmp_2.clone(); - if ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __tmp_2), - LvalueRefUnsafe::>::bind(&raw const __tmp_3), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__tmp_2), + LvalueRefUnsafe::>::bind(&__tmp_3), + ), + ) { let mut __it = __tmp_2; __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_3), - )) { - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__best.iter_deref()), - LvalueRefUnsafe::>::bind(__it.iter_deref()), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), + ), + ) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__best.iter_deref()), + LvalueRefUnsafe::>::bind(__it.iter_deref()), + ), + ) { __best = __it.clone(); } __it.iter_inc(); @@ -175,7 +181,7 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(0) }); let __b: *const _ = (unsafe { pick_3(1) }); - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -190,7 +196,7 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = (unsafe { pick_3(1) }); let __b: *const _ = (unsafe { pick_3(0) }); - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -219,10 +225,12 @@ unsafe fn main_0() -> i32 { (__tmp_4, __tmp_6) => { let __a: *const _ = __tmp_4; let __b: *const _ = __tmp_6; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -246,10 +254,12 @@ unsafe fn main_0() -> i32 { (__tmp_8, __tmp_10) => { let __a: *const _ = __tmp_8; let __b: *const _ = __tmp_10; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -271,10 +281,12 @@ unsafe fn main_0() -> i32 { (__tmp_12,) => { let __a: *const _ = &mut __tmp_13; let __b: *const _ = __tmp_12; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/min_max_ptr2ptr.rs b/tests/unit/out/unsafe/min_max_ptr2ptr.rs index a60a31f9ac..9d5fdf97eb 100644 --- a/tests/unit/out/unsafe/min_max_ptr2ptr.rs +++ b/tests/unit/out/unsafe/min_max_ptr2ptr.rs @@ -22,7 +22,7 @@ unsafe fn main_0() -> i32 { let mut r1: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -34,7 +34,7 @@ unsafe fn main_0() -> i32 { let mut r2: i32 = (*{ let __a: *const _ = (*ppa); let __b: *const _ = (*ppb); - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -51,10 +51,12 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -65,10 +67,12 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -79,10 +83,12 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut low; let __b: *const _ = &mut high; - if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a @@ -93,10 +99,12 @@ unsafe fn main_0() -> i32 { ((*{ let __a: *const _ = &mut high; let __b: *const _ = &mut low; - if ConvertibleToUnsafe::::convert_value(<*mut i32>::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + <*mut i32 as LessThanComparableUnsafe>::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/operator_comparison_nonbool.rs b/tests/unit/out/unsafe/operator_comparison_nonbool.rs index b119f79e51..f05f26c54c 100644 --- a/tests/unit/out/unsafe/operator_comparison_nonbool.rs +++ b/tests/unit/out/unsafe/operator_comparison_nonbool.rs @@ -571,15 +571,17 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const X; let __b = __tmp_0.iter_at(__y) as *const X; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -613,15 +615,19 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_1.iter_at(__x) as *const Mixed; let __b = __tmp_1.iter_at(__y) as *const Mixed; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -680,15 +686,19 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_2.iter_at(__x) as *const Boolish; let __b = __tmp_2.iter_at(__y) as *const Boolish; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -718,13 +728,17 @@ unsafe fn main_0() -> i32 { (({ let mut __tmp_3 = { ris.as_mut_ptr().offset((2) as isize) }; let mut __it = ris.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut RefInt>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_3), - )) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const ri2), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut RefInt as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), + ), + ) && !ConvertibleToUnsafe::::convert_value( + >::equal( + LvalueRefUnsafe::>::bind(__it.iter_deref()), + LvalueRefUnsafe::>::bind(&ri2), + ), + ) { __it.iter_inc(); } __it diff --git a/tests/unit/out/unsafe/push_emplace_back.rs b/tests/unit/out/unsafe/push_emplace_back.rs index 9c6f7f5402..07d8381c9e 100644 --- a/tests/unit/out/unsafe/push_emplace_back.rs +++ b/tests/unit/out/unsafe/push_emplace_back.rs @@ -82,10 +82,12 @@ pub unsafe fn push_local_from_field_1(mut jpg: *mut JPEGData, mut cond: bool) { let mut __tmp_2 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_2), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_2), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -117,10 +119,12 @@ pub unsafe fn emplace_local_from_field_4(mut jpg: *mut JPEGData, mut cond: bool) let mut __tmp_3 = { head.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = head.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_3), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -282,10 +286,12 @@ pub unsafe fn emplace_from_element_14(mut v: *mut Vec>) { let mut __tmp_4 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_4), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_4), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -361,10 +367,12 @@ pub unsafe fn emplace_from_sibling_18(mut s: *mut Bytes) { let mut __tmp_5 = { p.offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = p; - while ConvertibleToUnsafe::::convert_value(<*mut u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_5), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_5), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs index cce76c888d..9cd13c38d0 100644 --- a/tests/unit/out/unsafe/redundant_copy_in_conversion.rs +++ b/tests/unit/out/unsafe/redundant_copy_in_conversion.rs @@ -10,9 +10,9 @@ pub unsafe fn sink_0(mut it: UnsafeBidirectionalIterator<(i32, i32)>) -> i32 { let mut cit: UnsafeBidirectionalIterator<(i32, i32)> = >::from((it).clone()); return if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const cit), + LvalueRefUnsafe::>>::bind(&cit), LvalueRefUnsafe::>>::bind( - &raw const >::from((it).clone()), + &>::from((it).clone()), ), )) { (*it.iter_deref()).1 @@ -41,11 +41,9 @@ unsafe fn main_0() -> i32 { >::from((it0).clone()); let mut r: i32 = if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + LvalueRefUnsafe::>>::bind(&const_it), LvalueRefUnsafe::>>::bind( - &raw const const_it, - ), - LvalueRefUnsafe::>>::bind( - &raw const >::from((end).clone()), + &>::from((end).clone()), ), )) { 0 @@ -54,8 +52,8 @@ unsafe fn main_0() -> i32 { }; r += (unsafe { sink_0((it0).clone()) }); r += if ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const end), - LvalueRefUnsafe::>>::bind(&raw const end), + LvalueRefUnsafe::>>::bind(&end), + LvalueRefUnsafe::>>::bind(&end), )) { 0 } else { @@ -69,10 +67,8 @@ unsafe fn main_0() -> i32 { assert!(((*const_middle.iter_deref()) == (8_u32))); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind( - &raw const const_middle - ), - LvalueRefUnsafe::>>::bind(&raw const middle), + LvalueRefUnsafe::>>::bind(&const_middle), + LvalueRefUnsafe::>>::bind(&middle), ) )); return 0; diff --git a/tests/unit/out/unsafe/size_t_ssize_t.rs b/tests/unit/out/unsafe/size_t_ssize_t.rs index e67c519982..369bca8144 100644 --- a/tests/unit/out/unsafe/size_t_ssize_t.rs +++ b/tests/unit/out/unsafe/size_t_ssize_t.rs @@ -36,10 +36,12 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __first = src.as_mut_ptr(); let mut __out = (dst.as_mut_ptr() as *mut usize).cast::(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const __tmp_0), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_0), + ), + ) { object_unsafe!(__value, u64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -88,11 +90,9 @@ pub unsafe fn size_t_in_rules_3() { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( LvalueRefUnsafe::>>::bind( - &raw const m.find(&1_u64) - ), - LvalueRefUnsafe::>>::bind( - &raw const m.end() + &m.find(&1_u64) ), + LvalueRefUnsafe::>>::bind(&m.end()), ) )); assert!((((*m.begin().iter_deref()).0) == (1_u64))); @@ -213,10 +213,12 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_6 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_6), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_6), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -238,9 +240,9 @@ pub unsafe fn size_t_in_rules_3() { let mut __tmp_9 = { v.end() }; let mut __it = (__tmp_8).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind(&raw const __it), - LvalueRefUnsafe::>>::bind(&raw const __tmp_9), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_9), ), ) { *__it.iter_deref() = Clone::clone(&(k as u64)); @@ -257,7 +259,7 @@ pub unsafe fn size_t_in_rules_3() { (*{ let __a: *const _ = &mut v[(1_usize)]; let __b: *const _ = &mut __tmp_10; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -313,28 +315,14 @@ pub unsafe fn size_t_in_rules_3() { }; assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_13 = { v3.begin() }; let mut __tmp_14 = { v3.end() }; let mut __it = (__tmp_13).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_14, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const (k as u64)), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_14 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( k as u64 ) ), ), ) { __it.iter_inc(); } __it }), - LvalueRefUnsafe::>>::bind(&raw const v3.end()), + LvalueRefUnsafe::>>::bind(&v3.end()), ) )); assert!((((v3.len()) == (5_usize)) && ((big) >= (k))) && (((pk.1) as usize) == (k))); @@ -396,7 +384,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_15; let __b: *const _ = &mut __tmp_16; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -411,7 +399,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_17; let __b: *const _ = &mut ul; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -429,7 +417,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_18; let __b: *const _ = &mut __tmp_19; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -491,7 +479,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_20; let __b: *const _ = &mut __tmp_21; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -507,7 +495,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_22; let __b: *const _ = &mut __tmp_23; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -540,10 +528,12 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_24; let __b: *const _ = &mut __tmp_25; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a @@ -556,10 +546,12 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut __tmp_26; let __b: *const _ = &mut __tmp_27; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { __b } else { __a diff --git a/tests/unit/out/unsafe/sort.rs b/tests/unit/out/unsafe/sort.rs index 5cd37dcea5..d7f3e5fd52 100644 --- a/tests/unit/out/unsafe/sort.rs +++ b/tests/unit/out/unsafe/sort.rs @@ -61,15 +61,17 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_10.iter_at(__x) as *const i32; let __b = __tmp_10.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/sort_no_copy.rs b/tests/unit/out/unsafe/sort_no_copy.rs index c3849e9d7e..8587c74a2f 100644 --- a/tests/unit/out/unsafe/sort_no_copy.rs +++ b/tests/unit/out/unsafe/sort_no_copy.rs @@ -205,15 +205,19 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const Tracked; let __b = __tmp_0.iter_at(__y) as *const Tracked; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -266,15 +270,19 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_1.iter_at(__x) as *const Tracked; let __b = __tmp_1.iter_at(__y) as *const Tracked; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -422,15 +430,17 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_5.iter_at(__x) as *const Bag; let __b = __tmp_5.iter_at(__y) as *const Bag; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -472,15 +482,17 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_6.iter_at(__x) as *const Bag; let __b = __tmp_6.iter_at(__y) as *const Bag; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -501,73 +513,29 @@ unsafe fn main_0() -> i32 { assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_7 = { bag_vec.begin() }; let mut __tmp_8 = { bag_vec.end() }; let mut __it = (__tmp_7).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_8, - ), - ), - ) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind(&raw const bags[(1) as usize]), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_8 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&bags [ ( 1 ) as usize ] ), ), ) { __it.iter_inc(); } __it }), LvalueRefUnsafe::>>::bind( - &raw const bag_vec.begin().iter_add(1_isize) + &bag_vec.begin().iter_add(1_isize) ), ) )); assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( - LvalueRefUnsafe::>>::bind(&raw const { + LvalueRefUnsafe::>>::bind(&{ let mut __tmp_9 = { bag_vec.begin() }; let mut __tmp_10 = { bag_vec.end() }; let mut __best = __tmp_9.clone(); - if ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __tmp_9, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_10, - ), - ), - ) { - let mut __it = (__tmp_9).clone(); - __it.iter_inc(); - while ConvertibleToUnsafe::::convert_value(>::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_10, - ), - )) { - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__best.iter_deref()), - LvalueRefUnsafe::>::bind(__it.iter_deref()), - )) { - __best = __it.clone(); - } - __it.iter_inc(); - } - } + if ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__tmp_9 ), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { let mut __it = (__tmp_9 ).clone(); __it.iter_inc(); while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__best.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), )) { __best = __it.clone(); } __it.iter_inc(); } } __best }), LvalueRefUnsafe::>>::bind( - &raw const bag_vec.begin().iter_add(2_isize) + &bag_vec.begin().iter_add(2_isize) ), ) )); @@ -575,7 +543,7 @@ unsafe fn main_0() -> i32 { (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { @@ -589,7 +557,7 @@ unsafe fn main_0() -> i32 { (({ let __a: *const _ = &mut bags[(0) as usize]; let __b: *const _ = &mut bags[(2) as usize]; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { @@ -615,11 +583,9 @@ unsafe fn main_0() -> i32 { assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::equal( LvalueRefUnsafe::>>::bind( - &raw const bag_map.find(&bags[(1) as usize]) - ), - LvalueRefUnsafe::>>::bind( - &raw const bag_map.end() + &bag_map.find(&bags[(1) as usize]) ), + LvalueRefUnsafe::>>::bind(&bag_map.end()), ) )); assert!(((*std::cell::LazyCell::force_mut(&mut *&raw mut copies_0)) == (0))); @@ -646,15 +612,19 @@ unsafe fn main_0() -> i32 { __order.sort_by(|&__x, &__y| { let __a = __tmp_11.iter_at(__x) as *const MoveOnly; let __b = __tmp_11.iter_at(__y) as *const MoveOnly; - if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__a), - LvalueRefUnsafe::>::bind(__b), - )) { + if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__a), + LvalueRefUnsafe::>::bind(__b), + ), + ) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal diff --git a/tests/unit/out/unsafe/stdcopy.rs b/tests/unit/out/unsafe/stdcopy.rs index 0873210463..6095ed86d6 100644 --- a/tests/unit/out/unsafe/stdcopy.rs +++ b/tests/unit/out/unsafe/stdcopy.rs @@ -41,10 +41,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = output.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const __tmp_0), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_0), + ), + ) { object_unsafe!(__value, i32, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -63,10 +65,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = widened.begin(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const __tmp_1), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_1), + ), + ) { object_unsafe!(__value, i64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -95,10 +99,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_4 = { input.as_mut_ptr().offset((3) as isize) }; let mut __first = input.as_mut_ptr(); let mut __out = constructed.begin(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const __tmp_4), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_4), + ), + ) { object_unsafe!(__value, Degrees, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this @@ -119,10 +125,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { wide.as_mut_ptr().offset((2) as isize) }; let mut __first = wide.as_mut_ptr(); let mut __out = floating.begin(); - while ConvertibleToUnsafe::::convert_value(<*mut i64>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __first), - LvalueRefUnsafe::>::bind(&raw const __tmp_5), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i64 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__first), + LvalueRefUnsafe::>::bind(&__tmp_5), + ), + ) { object_unsafe!(__value, f64, |__this| ConvertibleToUnsafe::convert( LvalueRefUnsafe::::bind(__first.iter_deref()), __this diff --git a/tests/unit/out/unsafe/stdcopy_ostream.rs b/tests/unit/out/unsafe/stdcopy_ostream.rs index 49ced1b2aa..a7d80bdf16 100644 --- a/tests/unit/out/unsafe/stdcopy_ostream.rs +++ b/tests/unit/out/unsafe/stdcopy_ostream.rs @@ -39,13 +39,9 @@ unsafe fn main_0() -> i32 { let mut __bytes: Vec = Vec::new(); while ConvertibleToUnsafe::::convert_value(>::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_1, - ), + > as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_1), )) { __bytes.push(*__it.iter_deref() as u8); __it.iter_inc(); diff --git a/tests/unit/out/unsafe/stdmin_fpoint.rs b/tests/unit/out/unsafe/stdmin_fpoint.rs index 60f0ca193b..f92209e4eb 100644 --- a/tests/unit/out/unsafe/stdmin_fpoint.rs +++ b/tests/unit/out/unsafe/stdmin_fpoint.rs @@ -18,7 +18,7 @@ unsafe fn main_0() -> i32 { { let __a: *const _ = &mut a0; let __b: *const _ = &mut a1; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { diff --git a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs index fa9a190ecf..3e73e5b8ff 100644 --- a/tests/unit/out/unsafe/unboxed_conditional_iterator.rs +++ b/tests/unit/out/unsafe/unboxed_conditional_iterator.rs @@ -55,32 +55,14 @@ pub unsafe fn lehmer_3(mut sigma: *const u32, mut len: u32, mut code: *mut u32) let mut __tmp_0 = { items.begin() }; let mut __tmp_1 = { items.end() }; let mut __it = (__tmp_0).clone(); - while ConvertibleToUnsafe::::convert_value(>::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_1, - ), - )) && !ConvertibleToUnsafe::::convert_value(::equal( - LvalueRefUnsafe::>::bind(__it.iter_deref()), - LvalueRefUnsafe::>::bind( - &raw const (*sigma.offset((i) as isize)), - ), - )) { - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_1 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&( * sigma . offset ( ( i ) as isize ) ) ), ), ) { __it.iter_inc(); } __it }; assert!(ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( + LvalueRefUnsafe::>>::bind(&it), LvalueRefUnsafe::>>::bind( - &raw const it - ), - LvalueRefUnsafe::>>::bind( - &raw const items.end() + &items.end() ), ) )); @@ -104,10 +86,8 @@ pub unsafe fn sum_4(v: *mut Vec) -> i32 { let mut it: UnsafeRandomAccessIterator = (*v).begin(); 'loop_: while ConvertibleToUnsafe::::convert_value( WeaklyEqualityComparableWithUnsafe::not_equal( - LvalueRefUnsafe::>>::bind(&raw const it), - LvalueRefUnsafe::>>::bind( - &raw const (*v).end(), - ), + LvalueRefUnsafe::>>::bind(&it), + LvalueRefUnsafe::>>::bind(&(*v).end()), ), ) { 'for_body: { diff --git a/tests/unit/out/unsafe/unboxed_locals.rs b/tests/unit/out/unsafe/unboxed_locals.rs index 0a807d1100..9c68116c95 100644 --- a/tests/unit/out/unsafe/unboxed_locals.rs +++ b/tests/unit/out/unsafe/unboxed_locals.rs @@ -170,7 +170,7 @@ unsafe fn main_0() -> i32 { (*{ let __a: *const _ = &mut high; let __b: *const _ = &mut __tmp_0; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__b), LvalueRefUnsafe::>::bind(__a), )) { diff --git a/tests/unit/out/unsafe/vector.rs b/tests/unit/out/unsafe/vector.rs index ad09acaaef..1c524792fa 100644 --- a/tests/unit/out/unsafe/vector.rs +++ b/tests/unit/out/unsafe/vector.rs @@ -192,9 +192,9 @@ unsafe fn main_0() -> i32 { let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_8).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind(&raw const __it), - LvalueRefUnsafe::>>::bind(&raw const __tmp_9), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_9), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); @@ -524,10 +524,12 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_20), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_20), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -553,13 +555,9 @@ unsafe fn main_0() -> i32 { let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_22).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_23, - ), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_23), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); @@ -582,10 +580,12 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_25), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_25), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -606,10 +606,12 @@ unsafe fn main_0() -> i32 { as usize; let mut __tmp: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_27), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_27), + ), + ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), @@ -631,13 +633,9 @@ unsafe fn main_0() -> i32 { let mut __tmp: Vec = Vec::new(); let mut __it = (__tmp_29).clone(); while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_30, - ), + as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>>::bind(&__it), + LvalueRefUnsafe::>>::bind(&__tmp_30), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); diff --git a/tests/unit/out/unsafe/vector_iter_range_ctor.rs b/tests/unit/out/unsafe/vector_iter_range_ctor.rs index 2fb259d2d6..910e681fa0 100644 --- a/tests/unit/out/unsafe/vector_iter_range_ctor.rs +++ b/tests/unit/out/unsafe/vector_iter_range_ctor.rs @@ -138,10 +138,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_0 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_0), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_0), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -160,10 +162,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_1 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_1), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_1), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -182,10 +186,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_2 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_2), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_2), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -202,10 +208,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_3 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while ConvertibleToUnsafe::::convert_value(<*const u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_3), - )) { + while ConvertibleToUnsafe::::convert_value( + <*const u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_3), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -233,10 +241,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_5 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while ConvertibleToUnsafe::::convert_value(<*const u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_5), - )) { + while ConvertibleToUnsafe::::convert_value( + <*const u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_5), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -275,25 +285,7 @@ unsafe fn main_0() -> i32 { let mut __tmp_10 = { m.end() }; let mut __v: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_9).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_10, - ), - ), - ) { - __v.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __v.as_mut_ptr().add(__v.len() - 1), - (LvalueRefUnsafe::>::bind( - __it.iter_deref(), - ),), - ); - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_10 ), ), ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } __v }; assert!(((v6.len()) == (3_usize))); @@ -308,25 +300,7 @@ unsafe fn main_0() -> i32 { __tmp_11.iter_distance(&UnsafeRandomAccessIterator::Vec(v6.as_mut_ptr())) as usize; let mut __tmp: Vec<(i32, i32)> = Vec::new(); let mut __it = (__tmp_12).clone(); - while ConvertibleToUnsafe::::convert_value( - >::not_equal( - LvalueRefUnsafe::>>::bind( - &raw const __it, - ), - LvalueRefUnsafe::>>::bind( - &raw const __tmp_13, - ), - ), - ) { - __tmp.push(ZeroInitializationUnsafe::zero_init()); - ConstructibleFromUnsafe::construct( - __tmp.as_mut_ptr().add(__tmp.len() - 1), - (LvalueRefUnsafe::>::bind( - __it.iter_deref(), - ),), - ); - __it.iter_inc(); - } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_13 ), ), ) { __tmp.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __tmp.as_mut_ptr().add(__tmp.len() - 1), (LvalueRefUnsafe::>::bind(__it.iter_deref()),), ); __it.iter_inc(); } v6.splice(__off..__off, __tmp); UnsafeRandomAccessIterator::Vec(v6.as_mut_ptr().add(__off)) }; @@ -339,10 +313,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_14 = { ints.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = ints.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut i32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_14), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut i32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_14), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -358,10 +334,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_15 = { readings.as_mut_ptr().offset((2) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = readings.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut Reading>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_15), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut Reading as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_15), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/vector_with_allocator.rs b/tests/unit/out/unsafe/vector_with_allocator.rs index bf36fe931d..a5c6aa3237 100644 --- a/tests/unit/out/unsafe/vector_with_allocator.rs +++ b/tests/unit/out/unsafe/vector_with_allocator.rs @@ -321,10 +321,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_16 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_16), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_16), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -343,10 +345,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_17 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_17), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_17), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -365,10 +369,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_18 = { src.as_mut_ptr().offset((3) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = src.as_mut_ptr(); - while ConvertibleToUnsafe::::convert_value(<*mut u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_18), - )) { + while ConvertibleToUnsafe::::convert_value( + <*mut u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_18), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -385,10 +391,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_19 = { src1.as_ptr().add(src1.len()) }; let mut __v: Vec = Vec::new(); let mut __it = src1.as_ptr(); - while ConvertibleToUnsafe::::convert_value(<*const u32>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_19), - )) { + while ConvertibleToUnsafe::::convert_value( + <*const u32 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_19), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), @@ -410,10 +418,12 @@ unsafe fn main_0() -> i32 { let mut __tmp_20 = { start.offset((len) as isize) }; let mut __v: Vec = Vec::new(); let mut __it = start; - while ConvertibleToUnsafe::::convert_value(<*const u8>::not_equal( - LvalueRefUnsafe::>::bind(&raw const __it), - LvalueRefUnsafe::>::bind(&raw const __tmp_20), - )) { + while ConvertibleToUnsafe::::convert_value( + <*const u8 as WeaklyEqualityComparableWithUnsafe>::not_equal( + LvalueRefUnsafe::>::bind(&__it), + LvalueRefUnsafe::>::bind(&__tmp_20), + ), + ) { __v.push(ZeroInitializationUnsafe::zero_init()); ConstructibleFromUnsafe::construct( __v.as_mut_ptr().add(__v.len() - 1), diff --git a/tests/unit/out/unsafe/void_return.rs b/tests/unit/out/unsafe/void_return.rs index 2d8962a25f..4d45939ff1 100644 --- a/tests/unit/out/unsafe/void_return.rs +++ b/tests/unit/out/unsafe/void_return.rs @@ -17,15 +17,17 @@ pub unsafe fn f1_0( __order.sort_by(|&__x, &__y| { let __a = __tmp_0.iter_at(__x) as *const i32; let __b = __tmp_0.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal @@ -48,15 +50,17 @@ pub unsafe fn f1_1(mut first: *mut i32, mut last: *mut i32) { __order.sort_by(|&__x, &__y| { let __a = first.iter_at(__x) as *const i32; let __b = first.iter_at(__y) as *const i32; - if ConvertibleToUnsafe::::convert_value(::less( + if ConvertibleToUnsafe::::convert_value(::less( LvalueRefUnsafe::>::bind(__a), LvalueRefUnsafe::>::bind(__b), )) { std::cmp::Ordering::Less - } else if ConvertibleToUnsafe::::convert_value(::less( - LvalueRefUnsafe::>::bind(__b), - LvalueRefUnsafe::>::bind(__a), - )) { + } else if ConvertibleToUnsafe::::convert_value( + ::less( + LvalueRefUnsafe::>::bind(__b), + LvalueRefUnsafe::>::bind(__a), + ), + ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Equal From 06b55f49cd2b9a0f99dd45af067eaf7d9f54c39c Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Fri, 4 Dec 2026 22:22:40 +0000 Subject: [PATCH 08/17] Add Cpp17EqualityComparable --- cpp2rust/converter/converter.cpp | 77 +++-------- cpp2rust/converter/converter.h | 15 --- cpp2rust/converter/converter_lib.cpp | 77 ++++++++++- cpp2rust/converter/converter_lib.h | 56 +++++++- cpp2rust/converter/rules/rules_loader.cpp | 14 ++ libcc2rs/src/cmp.rs | 125 ++++++++++++++---- libcc2rs/src/fn_ptr.rs | 14 +- libcc2rs/src/reference.rs | 36 +++-- libcc2rs/src/void.rs | 7 +- rules/algorithm/tgt_refcount.rs | 17 +-- rules/algorithm/tgt_unsafe.rs | 17 +-- rules/iterator_category/shim.rs | 42 ++++-- rules/iterator_category/tgt_refcount.rs | 10 +- rules/iterator_category/tgt_unsafe.rs | 8 +- rules/pair/tgt_refcount.rs | 12 +- rules/pair/tgt_unsafe.rs | 34 ++--- .../out/refcount/friend_operator.rs | 4 +- .../out/unsafe/friend_operator.rs | 4 +- .../out/refcount/class.spaceship.rs | 8 +- .../out/unsafe/class.spaceship.rs | 8 +- .../class.conv/out/refcount/class.conv.fct.rs | 4 +- .../class.conv/out/unsafe/class.conv.fct.rs | 4 +- .../refcount/concept.equalitycomparable.rs | 58 ++++---- .../out/refcount/concept.totallyordered.rs | 8 +- .../out/unsafe/concept.equalitycomparable.rs | 58 ++++---- .../out/unsafe/concept.totallyordered.rs | 8 +- .../out/refcount/concept.convertible.rs | 4 +- .../out/unsafe/concept.convertible.rs | 4 +- .../out/refcount/sequence.reqmts.rs | 4 +- .../out/unsafe/sequence.reqmts.rs | 4 +- .../allocator.requirements.general.rs | 4 +- .../unsafe/allocator.requirements.general.rs | 4 +- .../stmt.select/out/refcount/stmt.switch.rs | 8 +- .../stmt.select/out/unsafe/stmt.switch.rs | 6 +- .../support/cmp/out/refcount/cmp.concept.rs | 12 +- .../std/support/cmp/out/unsafe/cmp.concept.rs | 12 +- .../pairs/out/refcount/pairs.pair.rs | 32 ++--- .../utilities/pairs/out/unsafe/pairs.pair.rs | 24 ++-- tests/unit/out/refcount/class.rs | 11 ++ .../refcount/elidable_iterator_copy_cxx11.rs | 12 +- tests/unit/out/refcount/find.rs | 38 +++--- tests/unit/out/refcount/friend.rs | 8 ++ tests/unit/out/refcount/map.rs | 16 +-- tests/unit/out/refcount/map_key_identity.rs | 114 ++++++++++++---- tests/unit/out/refcount/map_try_emplace.rs | 2 +- .../out/refcount/operator_comparison_free.rs | 8 +- .../refcount/operator_comparison_member.rs | 4 +- .../out/refcount/operator_comparison_mixed.rs | 54 +++++--- .../refcount/operator_comparison_nonbool.rs | 70 +++++++--- .../operator_comparison_noncopyable.rs | 8 ++ .../out/refcount/operator_other_member.rs | 4 +- tests/unit/out/refcount/operator_overloads.rs | 64 +++++++-- tests/unit/out/refcount/operator_three_way.rs | 4 +- .../refcount/pair_converting_construction.rs | 4 +- .../refcount/redundant_copy_in_conversion.rs | 8 +- tests/unit/out/refcount/size_t_ssize_t.rs | 2 +- tests/unit/out/refcount/sort_no_copy.rs | 32 +++-- .../refcount/unboxed_conditional_iterator.rs | 2 +- .../out/refcount/vector_iter_range_ctor.rs | 4 +- tests/unit/out/unsafe/class.rs | 11 ++ .../unsafe/elidable_iterator_copy_cxx11.rs | 2 +- tests/unit/out/unsafe/find.rs | 51 ++++--- tests/unit/out/unsafe/friend.rs | 14 ++ tests/unit/out/unsafe/map.rs | 16 +-- tests/unit/out/unsafe/map_key_identity.rs | 84 ++++++------ tests/unit/out/unsafe/map_try_emplace.rs | 24 +++- .../out/unsafe/operator_comparison_free.rs | 8 +- .../out/unsafe/operator_comparison_member.rs | 4 +- .../out/unsafe/operator_comparison_mixed.rs | 78 ++++++----- .../out/unsafe/operator_comparison_nonbool.rs | 64 +++++++-- .../unsafe/operator_comparison_noncopyable.rs | 14 ++ .../unit/out/unsafe/operator_other_member.rs | 4 +- tests/unit/out/unsafe/operator_overloads.rs | 85 ++++++++++-- tests/unit/out/unsafe/operator_three_way.rs | 4 +- .../unsafe/pair_converting_construction.rs | 4 +- .../unsafe/redundant_copy_in_conversion.rs | 8 +- tests/unit/out/unsafe/size_t_ssize_t.rs | 2 +- tests/unit/out/unsafe/sort_no_copy.rs | 28 +++- .../unsafe/unboxed_conditional_iterator.rs | 2 +- .../unit/out/unsafe/vector_iter_range_ctor.rs | 4 +- 80 files changed, 1244 insertions(+), 579 deletions(-) diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 0ec64dabd8..6b69b53b46 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -5871,80 +5871,37 @@ bool Converter::ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl) { void Converter::EmitComparisonTraits(const clang::CXXRecordDecl *decl) { ScopedValue no_function(curr_function_, nullptr); - auto *context = clang::BlockDecl::Create( - ctx_, ctx_.getTranslationUnitDecl(), decl->getLocation()); - clang::QualType self = ctx_.getCanonicalTagType(decl); - auto comparisons = - BuildComparisons(context, self, self, - {&kWeaklyEqualityComparableWith, &kLessThanComparable, - &kPartiallyOrderedWith, &kThreeWayComparable}); - for (const auto *trait : {&kWeaklyEqualityComparableWith, - &kLessThanComparable, &kPartiallyOrderedWith}) { - if (comparisons.Has(*trait)) { - EmitComparisonTrait(*trait, comparisons); + const auto &comparisons = GetRecordComparisons(GetSema(), decl); + for (const auto *trait : + {&kCpp17EqualityComparable, &kWeaklyEqualityComparableWith, + &kLessThanComparable, &kPartiallyOrderedWith}) { + if (SatisfiesComparisonTrait(*trait, comparisons.self, comparisons.self)) { + EmitComparisonTrait(*trait, comparisons.self); } } - if (auto *three_way = comparisons.exprs.at(clang::BO_Cmp); + if (auto *three_way = comparisons.self.exprs.at(clang::BO_Cmp); three_way && three_way->isPRValue() && ctx_.CompCategories.lookupInfoForType(three_way->getType()) && - comparisons.Has(kWeaklyEqualityComparableWith) && - comparisons.Has(kPartiallyOrderedWith)) { - EmitComparisonTrait(kThreeWayComparable, comparisons); + comparisons.self.Has(kWeaklyEqualityComparableWith) && + comparisons.self.Has(kPartiallyOrderedWith)) { + EmitComparisonTrait(kThreeWayComparable, comparisons.self); } - std::initializer_list symmetric = { - &kWeaklyEqualityComparableWith, &kPartiallyOrderedWith}; - for (auto other : GetComparisonOperandTypes(decl)) { + clang::QualType self = ctx_.getCanonicalTagType(decl); + for (const auto &[other, forward, reverse] : comparisons.others) { auto *other_record = other->getAsCXXRecordDecl(); bool other_emits_reverse = other_record && IsUserDefinedDecl(other_record) && llvm::is_contained(GetComparisonOperandTypes(other_record), self); - auto forward = BuildComparisons(context, self, other, symmetric); - auto reverse = BuildComparisons(context, other, self, symmetric); - for (const auto *trait : symmetric) { - if (forward.Has(*trait) && reverse.Has(*trait)) { + for (const auto *trait : kHeterogeneousComparisonTraits) { + if (SatisfiesComparisonTrait(*trait, forward, reverse)) { EmitComparisonTrait(*trait, forward); - if (!other_emits_reverse) { - EmitComparisonTrait(*trait, reverse); - } } - } - } -} - -bool Converter::Comparisons::Has(const ComparisonTrait &trait) const { - return llvm::all_of(trait.relations, [&](const ComparisonRelation &relation) { - return exprs.at(relation.op) != nullptr; - }); -} - -Converter::Comparisons Converter::BuildComparisons( - clang::BlockDecl *context, clang::QualType lhs, clang::QualType rhs, - std::initializer_list traits) { - auto loc = context->getCaretLocation(); - auto operand = [&](llvm::StringRef name, clang::QualType type) { - auto reference = ctx_.getLValueReferenceType(type.withConst()); - return clang::VarDecl::Create( - ctx_, context, loc, loc, &ctx_.Idents.get(name), reference, - ctx_.getTrivialTypeSourceInfo(reference, loc), clang::SC_None); - }; - Comparisons comparisons{lhs, rhs, operand("__lhs", lhs), - operand("__rhs", rhs), {}}; - auto refer = [&](clang::VarDecl *var) -> clang::Expr * { - return clang::DeclRefExpr::Create(ctx_, {}, {}, var, false, loc, - var->getType().getNonReferenceType(), - clang::VK_LValue); - }; - for (const auto *trait : traits) { - for (const auto &relation : trait->relations) { - if (!comparisons.exprs.contains(relation.op)) { - comparisons.exprs.emplace( - relation.op, - BuildComparison(GetSema(), relation.op, refer(comparisons.lhs), - refer(comparisons.rhs))); + if (!other_emits_reverse && + SatisfiesComparisonTrait(*trait, reverse, forward)) { + EmitComparisonTrait(*trait, reverse); } } } - return comparisons; } void Converter::EmitComparisonTrait(const ComparisonTrait &trait, diff --git a/cpp2rust/converter/converter.h b/cpp2rust/converter/converter.h index 81c1d0dba1..2c80ea540f 100644 --- a/cpp2rust/converter/converter.h +++ b/cpp2rust/converter/converter.h @@ -505,23 +505,8 @@ class Converter : public clang::RecursiveASTVisitor { CallInfo CollectCallInfo(clang::CallExpr *expr); - struct Comparisons { - clang::QualType lhs_type; - clang::QualType rhs_type; - clang::VarDecl *lhs; - clang::VarDecl *rhs; - std::unordered_map exprs; - - bool Has(const ComparisonTrait &trait) const; - }; - void EmitComparisonTraits(const clang::CXXRecordDecl *decl); - Comparisons - BuildComparisons(clang::BlockDecl *context, clang::QualType lhs, - clang::QualType rhs, - std::initializer_list traits); - void EmitComparisonTrait(const ComparisonTrait &trait, const Comparisons &comparisons); diff --git a/cpp2rust/converter/converter_lib.cpp b/cpp2rust/converter/converter_lib.cpp index 1eacd3ad0a..60ad69b75b 100644 --- a/cpp2rust/converter/converter_lib.cpp +++ b/cpp2rust/converter/converter_lib.cpp @@ -2321,8 +2321,9 @@ class TranslationUnitScope { }; } // namespace -clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, - clang::Expr *lhs, clang::Expr *rhs) { +static clang::Expr *BuildComparison(clang::Sema &sema, + clang::BinaryOperatorKind op, + clang::Expr *lhs, clang::Expr *rhs) { TranslationUnitScope tu_scope(sema); RuleDecls::Trial trial(sema); clang::ExprResult result; @@ -2338,6 +2339,78 @@ clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, return result.isUsable() && !trial.failed() ? result.get() : nullptr; } +bool Comparisons::Has(const ComparisonTrait &trait) const { + return llvm::all_of(trait.relations, + [&](const ComparisonRelation &relation) { + return exprs.at(relation.op) != nullptr; + }) && + (!trait.supertrait || Has(*trait.supertrait)); +} + +bool SatisfiesComparisonTrait(const ComparisonTrait &trait, + const Comparisons &forward, + const Comparisons &reverse) { + return forward.Has(trait) && (!trait.is_symmetric || reverse.Has(trait)); +} + +static Comparisons +BuildComparisons(clang::Sema &sema, clang::BlockDecl *context, + clang::QualType lhs, clang::QualType rhs, + std::span traits) { + auto &ctx = sema.getASTContext(); + auto loc = context->getCaretLocation(); + auto operand = [&](llvm::StringRef name, clang::QualType type) { + auto reference = ctx.getLValueReferenceType(type.withConst()); + return clang::VarDecl::Create( + ctx, context, loc, loc, &ctx.Idents.get(name), reference, + ctx.getTrivialTypeSourceInfo(reference, loc), clang::SC_None); + }; + Comparisons comparisons{lhs, rhs, operand("__lhs", lhs), + operand("__rhs", rhs), {}}; + auto refer = [&](clang::VarDecl *var) -> clang::Expr * { + return clang::DeclRefExpr::Create(ctx, {}, {}, var, false, loc, + var->getType().getNonReferenceType(), + clang::VK_LValue); + }; + for (const auto *trait : traits) { + for (const auto &relation : trait->relations) { + if (!comparisons.exprs.contains(relation.op)) { + comparisons.exprs.emplace( + relation.op, BuildComparison(sema, relation.op, + refer(comparisons.lhs), + refer(comparisons.rhs))); + } + } + } + return comparisons; +} + +const RecordComparisons &GetRecordComparisons(clang::Sema &sema, + const clang::CXXRecordDecl *decl) { + static std::unordered_map + built; + decl = decl->getCanonicalDecl(); + if (auto it = built.find(decl); it != built.end()) { + return it->second; + } + auto &ctx = sema.getASTContext(); + auto *context = clang::BlockDecl::Create(ctx, ctx.getTranslationUnitDecl(), + decl->getLocation()); + clang::QualType self = ctx.getCanonicalTagType(decl); + RecordComparisons comparisons{ + BuildComparisons(sema, context, self, self, kHomogeneousComparisonTraits), + {}}; + for (auto other : GetComparisonOperandTypes(decl)) { + comparisons.others.push_back( + {other, + BuildComparisons(sema, context, self, other, + kHeterogeneousComparisonTraits), + BuildComparisons(sema, context, other, self, + kHeterogeneousComparisonTraits)}); + } + return built.emplace(decl, std::move(comparisons)).first->second; +} + void DefineImplicitMembers(clang::Sema &sema, clang::CXXRecordDecl *decl) { TranslationUnitScope tu_scope(sema); sema.ForceDeclarationOfImplicitMembers(decl); diff --git a/cpp2rust/converter/converter_lib.h b/cpp2rust/converter/converter_lib.h index 4104b26a21..5ac5234606 100644 --- a/cpp2rust/converter/converter_lib.h +++ b/cpp2rust/converter/converter_lib.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -201,10 +202,13 @@ struct ComparisonRelation { struct ComparisonTrait { RecordTrait trait; std::span relations; + const ComparisonTrait *supertrait = nullptr; + bool is_symmetric = false; }; -inline constexpr ComparisonRelation kEqualityRelations[] = { - {clang::BO_EQ, "equal", "EqualResult"}, +inline constexpr ComparisonRelation kEqualRelations[] = { + {clang::BO_EQ, "equal", "EqualResult"}}; +inline constexpr ComparisonRelation kNotEqualRelations[] = { {clang::BO_NE, "not_equal", "NotEqualResult"}}; inline constexpr ComparisonRelation kLessThanRelations[] = { {clang::BO_LT, "less", "Result"}}; @@ -216,17 +220,24 @@ inline constexpr ComparisonRelation kOrderingRelations[] = { inline constexpr ComparisonRelation kThreeWayRelations[] = { {clang::BO_Cmp, "three_way", "Category"}}; +inline constexpr ComparisonTrait kCpp17EqualityComparable{ + {nullptr, {"Cpp17EqualityComparable"}, {"Cpp17EqualityComparableUnsafe"}}, + kEqualRelations}; inline constexpr ComparisonTrait kWeaklyEqualityComparableWith{ {nullptr, {"WeaklyEqualityComparableWith"}, {"WeaklyEqualityComparableWithUnsafe"}}, - kEqualityRelations}; + kNotEqualRelations, + &kCpp17EqualityComparable, + true}; inline constexpr ComparisonTrait kLessThanComparable{ {nullptr, {"LessThanComparable"}, {"LessThanComparableUnsafe"}}, kLessThanRelations}; inline constexpr ComparisonTrait kPartiallyOrderedWith{ {nullptr, {"PartiallyOrderedWith"}, {"PartiallyOrderedWithUnsafe"}}, - kOrderingRelations}; + kOrderingRelations, + nullptr, + true}; inline constexpr ComparisonTrait kThreeWayComparable{ {nullptr, {"ThreeWayComparable"}, {"ThreeWayComparableUnsafe"}}, kThreeWayRelations}; @@ -238,8 +249,41 @@ const clang::CXXRecordDecl *GetComparisonRecord(const clang::FunctionDecl *fn); std::vector GetComparisonOperandTypes(const clang::CXXRecordDecl *decl); -clang::Expr *BuildComparison(clang::Sema &sema, clang::BinaryOperatorKind op, - clang::Expr *lhs, clang::Expr *rhs); +struct Comparisons { + clang::QualType lhs_type; + clang::QualType rhs_type; + clang::VarDecl *lhs; + clang::VarDecl *rhs; + std::unordered_map exprs; + + bool Has(const ComparisonTrait &trait) const; +}; + +struct HeterogeneousComparisons { + clang::QualType other; + Comparisons forward; + Comparisons reverse; +}; + +struct RecordComparisons { + Comparisons self; + std::vector others; +}; + +inline constexpr const ComparisonTrait *kHomogeneousComparisonTraits[] = { + &kCpp17EqualityComparable, &kWeaklyEqualityComparableWith, + &kLessThanComparable, &kPartiallyOrderedWith, &kThreeWayComparable}; + +inline constexpr const ComparisonTrait *kHeterogeneousComparisonTraits[] = { + &kCpp17EqualityComparable, &kWeaklyEqualityComparableWith, + &kPartiallyOrderedWith}; + +bool SatisfiesComparisonTrait(const ComparisonTrait &trait, + const Comparisons &forward, + const Comparisons &reverse); + +const RecordComparisons &GetRecordComparisons(clang::Sema &sema, + const clang::CXXRecordDecl *decl); // Whether method is a C++ defaulted copy or move member that is translated as // a memberwise derive of its trait, rather than from its body. diff --git a/cpp2rust/converter/rules/rules_loader.cpp b/cpp2rust/converter/rules/rules_loader.cpp index f969e9168f..9180326334 100644 --- a/cpp2rust/converter/rules/rules_loader.cpp +++ b/cpp2rust/converter/rules/rules_loader.cpp @@ -57,10 +57,24 @@ class RuleUsageCollector IsConvertibleCXXRecordDecl(decl) && (decl->isStruct() || decl->isClass()) && !decl->isAbstract()) { DefineImplicitMembers(sema_, decl); + const auto &comparisons = GetRecordComparisons(sema_, decl); + TraverseComparisons(comparisons.self); + for (const auto &other : comparisons.others) { + TraverseComparisons(other.forward); + TraverseComparisons(other.reverse); + } } return true; } + void TraverseComparisons(const Comparisons &comparisons) { + for (const auto &[op, expr] : comparisons.exprs) { + if (expr) { + TraverseStmt(expr); + } + } + } + bool VisitExpr(clang::Expr *expr) { if (expr->isTypeDependent() || expr->isValueDependent()) { return true; diff --git a/libcc2rs/src/cmp.rs b/libcc2rs/src/cmp.rs index fbb968a679..b1fed6f006 100644 --- a/libcc2rs/src/cmp.rs +++ b/libcc2rs/src/cmp.rs @@ -34,27 +34,33 @@ pub trait LessThanComparableUnsafe: Sized { -> Self::Result; } -pub trait WeaklyEqualityComparableWith = Self>: - ByteRepr + Sized -{ +pub trait Cpp17EqualityComparable: ByteRepr + Sized { type EqualResult: BooleanTestable; - type NotEqualResult: BooleanTestable; fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult; - - fn not_equal(a: LvalueRef>, b: LvalueRef>) -> Self::NotEqualResult; } -pub trait WeaklyEqualityComparableWithUnsafe = Self>: - Sized -{ +pub trait Cpp17EqualityComparableUnsafe: Sized { type EqualResult: BooleanTestableUnsafe; - type NotEqualResult: BooleanTestableUnsafe; /// # Safety /// `a` and `b` must refer to live values. unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> Self::EqualResult; +} + +pub trait WeaklyEqualityComparableWith = Self>: + Cpp17EqualityComparable +{ + type NotEqualResult: BooleanTestable; + + fn not_equal(a: LvalueRef>, b: LvalueRef>) -> Self::NotEqualResult; +} + +pub trait WeaklyEqualityComparableWithUnsafe = Self>: + Cpp17EqualityComparableUnsafe +{ + type NotEqualResult: BooleanTestableUnsafe; /// # Safety /// `a` and `b` must refer to live values. @@ -282,14 +288,13 @@ impl LessThanComparabl } } -macro_rules! impl_weakly_equality_comparable_with { +macro_rules! impl_cpp17_equality_comparable { ($(<$($param:ident $(: $bound:path)?),*> $ty:ty),* $(,)?) => {$( - impl<$($param $(: $bound)?),*> $crate::WeaklyEqualityComparableWith for $ty + impl<$($param $(: $bound)?),*> $crate::Cpp17EqualityComparable for $ty where $ty: PartialEq + $crate::ByteRepr, { type EqualResult = bool; - type NotEqualResult = bool; fn equal( a: $crate::LvalueRef<$crate::Const>, @@ -297,6 +302,17 @@ macro_rules! impl_weakly_equality_comparable_with { ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| a == b)) } + } + )*}; +} + +macro_rules! impl_weakly_equality_comparable_with { + ($(<$($param:ident $(: $bound:path)?),*> $ty:ty),* $(,)?) => {$( + impl<$($param $(: $bound)?),*> $crate::WeaklyEqualityComparableWith for $ty + where + $ty: PartialEq + $crate::ByteRepr, + { + type NotEqualResult = bool; fn not_equal( a: $crate::LvalueRef<$crate::Const>, @@ -308,14 +324,13 @@ macro_rules! impl_weakly_equality_comparable_with { )*}; } -macro_rules! impl_weakly_equality_comparable_with_unsafe { +macro_rules! impl_cpp17_equality_comparable_unsafe { ($(<$($param:ident $(: $bound:path)?),*> $ty:ty),* $(,)?) => {$( - impl<$($param $(: $bound)?),*> $crate::WeaklyEqualityComparableWithUnsafe for $ty + impl<$($param $(: $bound)?),*> $crate::Cpp17EqualityComparableUnsafe for $ty where $ty: PartialEq, { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal( a: $crate::LvalueRefUnsafe<$crate::Const>, @@ -323,6 +338,17 @@ macro_rules! impl_weakly_equality_comparable_with_unsafe { ) -> bool { unsafe { *a.as_const_ptr() == *b.as_const_ptr() } } + } + )*}; +} + +macro_rules! impl_weakly_equality_comparable_with_unsafe { + ($(<$($param:ident $(: $bound:path)?),*> $ty:ty),* $(,)?) => {$( + impl<$($param $(: $bound)?),*> $crate::WeaklyEqualityComparableWithUnsafe for $ty + where + $ty: PartialEq, + { + type NotEqualResult = bool; unsafe fn not_equal( a: $crate::LvalueRefUnsafe<$crate::Const>, @@ -334,18 +360,23 @@ macro_rules! impl_weakly_equality_comparable_with_unsafe { )*}; } +impl_cpp17_equality_comparable!( + <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, + <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, + Ptr, Option, +); + impl_weakly_equality_comparable_with!( <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, Ptr, Option, ); -impl WeaklyEqualityComparableWith for Vec +impl Cpp17EqualityComparable for Vec where Self: ByteRepr, { type EqualResult = bool; - type NotEqualResult = bool; fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); @@ -359,15 +390,21 @@ where ConvertibleTo::::convert_value(T::equal(x, y)) }) } +} + +impl WeaklyEqualityComparableWith for Vec +where + Self: ByteRepr, +{ + type NotEqualResult = bool; fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { !Self::equal(a, b) } } -impl WeaklyEqualityComparableWith for Box<[T]> { +impl Cpp17EqualityComparable for Box<[T]> { type EqualResult = bool; - type NotEqualResult = bool; fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { let (a, b) = (a.as_pointer(), b.as_pointer()); @@ -381,19 +418,22 @@ impl WeaklyEqualityComparableWith for Box<[T]> { ConvertibleTo::::convert_value(T::equal(x, y)) }) } +} + +impl WeaklyEqualityComparableWith for Box<[T]> { + type NotEqualResult = bool; fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { !Self::equal(a, b) } } -impl WeaklyEqualityComparableWith +impl Cpp17EqualityComparable for (Value, Value) where Self: ByteRepr, { type EqualResult = bool; - type NotEqualResult = bool; fn equal(a: LvalueRef>, b: LvalueRef>) -> bool { let pointers = |pair: &Self| { @@ -410,21 +450,34 @@ where } ConvertibleTo::::convert_value(B::equal(LvalueRef::bind(a1), LvalueRef::bind(b1))) } +} + +impl WeaklyEqualityComparableWith + for (Value, Value) +where + Self: ByteRepr, +{ + type NotEqualResult = bool; fn not_equal(a: LvalueRef>, b: LvalueRef>) -> bool { !Self::equal(a, b) } } +impl_cpp17_equality_comparable_unsafe!( + <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, + <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, + *mut T, *const T, Option, +); + impl_weakly_equality_comparable_with_unsafe!( <> bool, <> i8, <> i16, <> i32, <> i64, <> i128, <> isize, <> u8, <> u16, <> u32, <> u64, <> u128, <> usize, <> f32, <> f64, *mut T, *const T, Option, ); -impl WeaklyEqualityComparableWithUnsafe for Vec { +impl Cpp17EqualityComparableUnsafe for Vec { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { @@ -440,15 +493,18 @@ impl WeaklyEqualityComparableWithUnsafe for Vec }) } } +} + +impl WeaklyEqualityComparableWithUnsafe for Vec { + type NotEqualResult = bool; unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { !Self::equal(a, b) } } } -impl WeaklyEqualityComparableWithUnsafe for [T; N] { +impl Cpp17EqualityComparableUnsafe for [T; N] { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { let (a, b) = (a.as_const_ptr().cast::(), b.as_const_ptr().cast::()); @@ -457,17 +513,22 @@ impl WeaklyEqualityComparableWithUn ConvertibleToUnsafe::::convert_value(T::equal(x, y)) }) } +} + +impl WeaklyEqualityComparableWithUnsafe + for [T; N] +{ + type NotEqualResult = bool; unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { !Self::equal(a, b) } } } -impl WeaklyEqualityComparableWithUnsafe - for (A, B) +impl + Cpp17EqualityComparableUnsafe for (A, B) { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { @@ -486,6 +547,12 @@ impl WeaklyEqualityCom ConvertibleToUnsafe::::convert_value(B::equal(x, y)) } } +} + +impl + WeaklyEqualityComparableWithUnsafe for (A, B) +{ + type NotEqualResult = bool; unsafe fn not_equal(a: LvalueRefUnsafe>, b: LvalueRefUnsafe>) -> bool { unsafe { !Self::equal(a, b) } diff --git a/libcc2rs/src/fn_ptr.rs b/libcc2rs/src/fn_ptr.rs index d627365b88..12a4d12f6e 100644 --- a/libcc2rs/src/fn_ptr.rs +++ b/libcc2rs/src/fn_ptr.rs @@ -493,9 +493,8 @@ impl PartialEq for FnPtr { impl Eq for FnPtr {} -impl crate::WeaklyEqualityComparableWith for FnPtr { +impl crate::Cpp17EqualityComparable for FnPtr { type EqualResult = bool; - type NotEqualResult = bool; fn equal( a: crate::LvalueRef>, @@ -503,6 +502,10 @@ impl crate::WeaklyEqualityComparableWith for FnPtr { ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| a.addr == b.addr)) } +} + +impl crate::WeaklyEqualityComparableWith for FnPtr { + type NotEqualResult = bool; fn not_equal( a: crate::LvalueRef>, @@ -512,9 +515,8 @@ impl crate::WeaklyEqualityComparableWith for FnPtr { } } -impl crate::WeaklyEqualityComparableWithUnsafe for FnPtr { +impl crate::Cpp17EqualityComparableUnsafe for FnPtr { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal( a: crate::LvalueRefUnsafe>, @@ -522,6 +524,10 @@ impl crate::WeaklyEqualityComparableWithUnsafe for FnPtr { ) -> bool { unsafe { (*a.as_const_ptr()).addr == (*b.as_const_ptr()).addr } } +} + +impl crate::WeaklyEqualityComparableWithUnsafe for FnPtr { + type NotEqualResult = bool; unsafe fn not_equal( a: crate::LvalueRefUnsafe>, diff --git a/libcc2rs/src/reference.rs b/libcc2rs/src/reference.rs index 3a73830ca3..81d20837b3 100644 --- a/libcc2rs/src/reference.rs +++ b/libcc2rs/src/reference.rs @@ -121,20 +121,26 @@ macro_rules! reference { } } - impl crate::WeaklyEqualityComparableWith for $name + impl crate::Cpp17EqualityComparable for $name where - T::Object: crate::WeaklyEqualityComparableWith + ByteRepr, + T::Object: crate::Cpp17EqualityComparable + ByteRepr, { - type EqualResult = ::EqualResult; - type NotEqualResult = - ::NotEqualResult; + type EqualResult = ::EqualResult; fn equal(a: LvalueRef>, b: LvalueRef>) -> Self::EqualResult { - ::equal( + ::equal( LvalueRef::bind(a.as_pointer().with(|r| r.0.clone())), LvalueRef::bind(b.as_pointer().with(|r| r.0.clone())), ) } + } + + impl crate::WeaklyEqualityComparableWith for $name + where + T::Object: crate::WeaklyEqualityComparableWith + ByteRepr, + { + type NotEqualResult = + ::NotEqualResult; fn not_equal( a: LvalueRef>, @@ -284,11 +290,10 @@ macro_rules! reference_unsafe { } } - impl crate::WeaklyEqualityComparableWithUnsafe + impl crate::Cpp17EqualityComparableUnsafe for $name { type EqualResult = T::EqualResult; - type NotEqualResult = T::NotEqualResult; unsafe fn equal( a: LvalueRefUnsafe>, @@ -301,6 +306,12 @@ macro_rules! reference_unsafe { ) } } + } + + impl crate::WeaklyEqualityComparableWithUnsafe + for $name + { + type NotEqualResult = T::NotEqualResult; unsafe fn not_equal( a: LvalueRefUnsafe>, @@ -315,11 +326,10 @@ macro_rules! reference_unsafe { } } - impl crate::WeaklyEqualityComparableWithUnsafe + impl crate::Cpp17EqualityComparableUnsafe for $name> { type EqualResult = T::EqualResult; - type NotEqualResult = T::NotEqualResult; unsafe fn equal( a: LvalueRefUnsafe>, @@ -332,6 +342,12 @@ macro_rules! reference_unsafe { ) } } + } + + impl crate::WeaklyEqualityComparableWithUnsafe + for $name> + { + type NotEqualResult = T::NotEqualResult; unsafe fn not_equal( a: LvalueRefUnsafe>, diff --git a/libcc2rs/src/void.rs b/libcc2rs/src/void.rs index 2466da31c0..0163a1bb31 100644 --- a/libcc2rs/src/void.rs +++ b/libcc2rs/src/void.rs @@ -148,9 +148,8 @@ impl PartialEq for AnyPtr { } } -impl crate::WeaklyEqualityComparableWith for AnyPtr { +impl crate::Cpp17EqualityComparable for AnyPtr { type EqualResult = bool; - type NotEqualResult = bool; fn equal( a: crate::LvalueRef>, @@ -158,6 +157,10 @@ impl crate::WeaklyEqualityComparableWith for AnyPtr { ) -> bool { a.as_pointer().with(|a| b.as_pointer().with(|b| *a.ptr == *b.ptr)) } +} + +impl crate::WeaklyEqualityComparableWith for AnyPtr { + type NotEqualResult = bool; fn not_equal( a: crate::LvalueRef>, diff --git a/rules/algorithm/tgt_refcount.rs b/rules/algorithm/tgt_refcount.rs index c0a13f2128..9f17e3d64c 100644 --- a/rules/algorithm/tgt_refcount.rs +++ b/rules/algorithm/tgt_refcount.rs @@ -48,11 +48,7 @@ where __out } -fn f3< - T1: CppInputIterator, - T2: WeaklyEqualityComparableWith, - T3: WeaklyEqualityComparableWith, ->( +fn f3, T2: ByteRepr, T3: Cpp17EqualityComparable>( a0: T1, a1: T1, a2: Ptr, @@ -62,7 +58,7 @@ fn f3< while ConvertibleTo::::convert_value(::not_equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), - )) && !ConvertibleTo::::convert_value(>::equal( + )) && !ConvertibleTo::::convert_value(>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(a2.clone()), )) { @@ -120,16 +116,13 @@ fn f9(a0: Ptr, a1: Ptr) { Swappable::swap(a0, a1) } -fn f10< - T1: CppInputIterator, - T2: WeaklyEqualityComparableWith + TriviallyCopyable + ByteRepr, ->( +fn f10, T2: Cpp17EqualityComparable + TriviallyCopyable + ByteRepr>( a0: T1, a1: T1, ) -> T1 { let __it: Value = Rc::new(RefCell::new(a0)); let __last: Value = Rc::new(RefCell::new(a1)); - if ConvertibleTo::::convert_value(::equal( + if ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), )) { @@ -141,7 +134,7 @@ fn f10< LvalueRef::>::bind(__it.as_pointer()), LvalueRef::>::bind(__last.as_pointer()), )) { - if !ConvertibleTo::::convert_value(::equal( + if !ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(__write.iter_deref()), LvalueRef::>::bind(__it.borrow().iter_deref()), )) { diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index d921c27ddd..50377541a0 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -69,11 +69,7 @@ where __out } -unsafe fn f3< - T1: UnsafeCppInputIterator, - T2: WeaklyEqualityComparableWithUnsafe, - T3: WeaklyEqualityComparableWithUnsafe, ->( +unsafe fn f3, T2, T3: Cpp17EqualityComparableUnsafe>( a0: T1, a1: T1, a2: T2, @@ -85,7 +81,7 @@ unsafe fn f3< LvalueRefUnsafe::>::bind(&a1), ), ) && !ConvertibleToUnsafe::::convert_value( - >::equal( + >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&a2), ), @@ -155,14 +151,11 @@ unsafe fn f9(a0: *mut T1, a1: *mut T1) { SwappableUnsafe::swap(&mut *__a, __b) } -unsafe fn f10< - T1: UnsafeCppInputIterator, - T2: WeaklyEqualityComparableWithUnsafe + Clone, ->( +unsafe fn f10, T2: Cpp17EqualityComparableUnsafe + Clone>( a0: T1, a1: T1, ) -> T1 { - if ConvertibleToUnsafe::::convert_value(::equal( + if ConvertibleToUnsafe::::convert_value(::equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), )) { @@ -178,7 +171,7 @@ unsafe fn f10< ), ) { if !ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(__write.iter_deref()), LvalueRefUnsafe::>::bind(__it.iter_deref()), ), diff --git a/rules/iterator_category/shim.rs b/rules/iterator_category/shim.rs index d24a62347a..fd949f8ccc 100644 --- a/rules/iterator_category/shim.rs +++ b/rules/iterator_category/shim.rs @@ -173,26 +173,32 @@ macro_rules! uninhabited_iterator { impl ByteRepr for $name {} - impl crate::WeaklyEqualityComparableWith for $name { + impl crate::Cpp17EqualityComparable for $name { type EqualResult = bool; - type NotEqualResult = bool; fn equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) } + } + + impl crate::WeaklyEqualityComparableWith for $name { + type NotEqualResult = bool; fn not_equal(this: LvalueRef>, _: LvalueRef>) -> bool { this.as_pointer().with(|it| it.never()) } } - impl crate::WeaklyEqualityComparableWithUnsafe for $name { + impl crate::Cpp17EqualityComparableUnsafe for $name { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal( this: LvalueRefUnsafe>, _: LvalueRefUnsafe>, ) -> bool { unsafe { (*this.as_const_ptr()).never() } } + } + + impl crate::WeaklyEqualityComparableWithUnsafe for $name { + type NotEqualResult = bool; unsafe fn not_equal( this: LvalueRefUnsafe>, _: LvalueRefUnsafe>, @@ -301,9 +307,8 @@ impl Clone for BidirectionalIterator { impl ByteRepr for BidirectionalIterator {} -impl crate::WeaklyEqualityComparableWith for BidirectionalIterator { +impl crate::Cpp17EqualityComparable for BidirectionalIterator { type EqualResult = bool; - type NotEqualResult = bool; fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { @@ -311,6 +316,10 @@ impl crate::WeaklyEqualityComparableWith for BidirectionalIterator crate::WeaklyEqualityComparableWith for BidirectionalIterator { + type NotEqualResult = bool; fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { @@ -373,9 +382,8 @@ impl Clone for UnsafeBidirectionalIterator { } } -impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeBidirectionalIterator { +impl crate::Cpp17EqualityComparableUnsafe for UnsafeBidirectionalIterator { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal(this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>) -> bool { unsafe { match (&*this.as_const_ptr(), &*rhs.as_const_ptr()) { @@ -383,6 +391,10 @@ impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeBidirectionalIterato } } } +} + +impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeBidirectionalIterator { + type NotEqualResult = bool; unsafe fn not_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, @@ -572,9 +584,8 @@ crate::constructor::impl_trivial_copy_move!( UnsafeBidirectionalIterator, UnsafeRandomAccessIterator, ); -impl crate::WeaklyEqualityComparableWith for RandomAccessIterator { +impl crate::Cpp17EqualityComparable for RandomAccessIterator { type EqualResult = bool; - type NotEqualResult = bool; fn equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { @@ -582,6 +593,10 @@ impl crate::WeaklyEqualityComparableWith for RandomAccessIterator crate::WeaklyEqualityComparableWith for RandomAccessIterator { + type NotEqualResult = bool; fn not_equal(this: LvalueRef>, rhs: LvalueRef>) -> bool { this.as_pointer().with(|a| { rhs.as_pointer().with(|b| match (a, b) { @@ -626,9 +641,8 @@ impl PartiallyOrderedWith for RandomAccessIterator { } } -impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator { +impl crate::Cpp17EqualityComparableUnsafe for UnsafeRandomAccessIterator { type EqualResult = bool; - type NotEqualResult = bool; unsafe fn equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, @@ -639,6 +653,10 @@ impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator } } } +} + +impl crate::WeaklyEqualityComparableWithUnsafe for UnsafeRandomAccessIterator { + type NotEqualResult = bool; unsafe fn not_equal( this: LvalueRefUnsafe>, rhs: LvalueRefUnsafe>, diff --git a/rules/iterator_category/tgt_refcount.rs b/rules/iterator_category/tgt_refcount.rs index bd7953b275..737c99a744 100644 --- a/rules/iterator_category/tgt_refcount.rs +++ b/rules/iterator_category/tgt_refcount.rs @@ -59,7 +59,7 @@ fn f8, T2>(a0: T1) -> Ptr { } fn f9, T2>(a0: Ptr, a1: Ptr) -> bool { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), )) @@ -153,15 +153,11 @@ fn f26, T2>(a0: &mut T1) -> &mut T1 { a0 } -fn f27< - T1: CppInputIterator + WeaklyEqualityComparableWith, - T2: CppInputIterator + WeaklyEqualityComparableWith, - T3, ->( +fn f27 + Cpp17EqualityComparable, T2: CppInputIterator, T3>( a0: Ptr, a1: Ptr, ) -> bool { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>::bind(a0), LvalueRef::>::bind(a1), )) diff --git a/rules/iterator_category/tgt_unsafe.rs b/rules/iterator_category/tgt_unsafe.rs index 21a5a7bb2b..9b21b74d92 100644 --- a/rules/iterator_category/tgt_unsafe.rs +++ b/rules/iterator_category/tgt_unsafe.rs @@ -59,7 +59,7 @@ fn f8, T2>(a0: T1) -> *mut T2 { } unsafe fn f9, T2>(a0: T1, a1: T1) -> bool { - ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), )) @@ -154,14 +154,14 @@ fn f26, T2>(a0: &mut T1) -> &mut T1 { } unsafe fn f27< - T1: UnsafeCppInputIterator + WeaklyEqualityComparableWithUnsafe, - T2: UnsafeCppInputIterator + WeaklyEqualityComparableWithUnsafe, + T1: UnsafeCppInputIterator + Cpp17EqualityComparableUnsafe, + T2: UnsafeCppInputIterator, T3, >( a0: T1, a1: T2, ) -> bool { - ConvertibleToUnsafe::::convert_value(WeaklyEqualityComparableWithUnsafe::equal( + ConvertibleToUnsafe::::convert_value(Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>::bind(&a0), LvalueRefUnsafe::>::bind(&a1), )) diff --git a/rules/pair/tgt_refcount.rs b/rules/pair/tgt_refcount.rs index bb299f1a9b..b0a32386a0 100644 --- a/rules/pair/tgt_refcount.rs +++ b/rules/pair/tgt_refcount.rs @@ -214,14 +214,14 @@ where a0.get_value::().as_pointer() } -fn f28, T2: WeaklyEqualityComparableWith>( +fn f28, T2: Cpp17EqualityComparable>( a0: (Value, Value), a1: (Value, Value), ) -> bool { - !(ConvertibleTo::::convert_value(::equal( + !(ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(a0.0.as_pointer()), LvalueRef::>::bind(a1.0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + )) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(a0.1.as_pointer()), LvalueRef::>::bind(a1.1.as_pointer()), ))) @@ -289,14 +289,14 @@ fn f32( )) } -fn f33, T2: WeaklyEqualityComparableWith>( +fn f33, T2: Cpp17EqualityComparable>( a0: (Value, Value), a1: (Value, Value), ) -> bool { - ConvertibleTo::::convert_value(::equal( + ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(a0.0.as_pointer()), LvalueRef::>::bind(a1.0.as_pointer()), - )) && ConvertibleTo::::convert_value(::equal( + )) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind(a0.1.as_pointer()), LvalueRef::>::bind(a1.1.as_pointer()), )) diff --git a/rules/pair/tgt_unsafe.rs b/rules/pair/tgt_unsafe.rs index 02554ed816..c69d1bd22f 100644 --- a/rules/pair/tgt_unsafe.rs +++ b/rules/pair/tgt_unsafe.rs @@ -203,22 +203,17 @@ where &*a0.get::() } -unsafe fn f28< - T1: WeaklyEqualityComparableWithUnsafe, - T2: WeaklyEqualityComparableWithUnsafe, ->( +unsafe fn f28, T2: Cpp17EqualityComparableUnsafe>( a0: (T1, T2), a1: (T1, T2), ) -> bool { - !(ConvertibleToUnsafe::::convert_value(::equal( + !(ConvertibleToUnsafe::::convert_value(::equal( LvalueRefUnsafe::>::bind(&a0.0), LvalueRefUnsafe::>::bind(&a1.0), - )) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a0.1), - LvalueRefUnsafe::>::bind(&a1.1), - ), - )) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), + ))) } unsafe fn f29( @@ -261,22 +256,17 @@ unsafe fn f32( )) } -unsafe fn f33< - T1: WeaklyEqualityComparableWithUnsafe, - T2: WeaklyEqualityComparableWithUnsafe, ->( +unsafe fn f33, T2: Cpp17EqualityComparableUnsafe>( a0: (T1, T2), a1: (T1, T2), ) -> bool { - ConvertibleToUnsafe::::convert_value(::equal( + ConvertibleToUnsafe::::convert_value(::equal( LvalueRefUnsafe::>::bind(&a0.0), LvalueRefUnsafe::>::bind(&a1.0), - )) && ConvertibleToUnsafe::::convert_value( - ::equal( - LvalueRefUnsafe::>::bind(&a0.1), - LvalueRefUnsafe::>::bind(&a1.1), - ), - ) + )) && ConvertibleToUnsafe::::convert_value(::equal( + LvalueRefUnsafe::>::bind(&a0.1), + LvalueRefUnsafe::>::bind(&a1.1), + )) } unsafe fn f34< diff --git a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs index d08e61c30b..7a90000fb5 100644 --- a/tests/multi-file/friend_operator/out/refcount/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/refcount/friend_operator.rs @@ -27,13 +27,15 @@ pub struct S { #[offset(4)] pub b: i32, } -impl WeaklyEqualityComparableWith for S { +impl Cpp17EqualityComparable for S { type EqualResult = bool; fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { let __lhs = __lhs.as_pointer(); let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for S { type NotEqualResult = bool; fn not_equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::NotEqualResult { let __lhs = __lhs.as_pointer(); diff --git a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs index a25a0c3d5d..35da325f09 100644 --- a/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs +++ b/tests/multi-file/friend_operator/out/unsafe/friend_operator.rs @@ -23,7 +23,7 @@ pub struct S { pub a: i32, pub b: i32, } -impl WeaklyEqualityComparableWithUnsafe for S { +impl Cpp17EqualityComparableUnsafe for S { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -36,6 +36,8 @@ impl WeaklyEqualityComparableWithUnsafe for S { operator_eq_0(_x, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for S { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/class/class.compare/out/refcount/class.spaceship.rs b/tests/std/class/class.compare/out/refcount/class.spaceship.rs index 07b918f02c..98d2d65227 100644 --- a/tests/std/class/class.compare/out/refcount/class.spaceship.rs +++ b/tests/std/class/class.compare/out/refcount/class.spaceship.rs @@ -69,7 +69,7 @@ impl p1_memberwise_in_declaration_order_Date { && ({ this.with(|__s| __s.day) } == { _a0.with(|__s| __s.day) })); } } -impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { +impl Cpp17EqualityComparable for p1_memberwise_in_declaration_order_Date { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -81,6 +81,8 @@ impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { p1_memberwise_in_declaration_order_Date::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_memberwise_in_declaration_order_Date { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -340,7 +342,7 @@ impl p2_common_comparison_category_Reading { && ({ this.with(|__s| __s.value) } == { _a0.with(|__s| __s.value) }); } } -impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { +impl Cpp17EqualityComparable for p2_common_comparison_category_Reading { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -352,6 +354,8 @@ impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { p2_common_comparison_category_Reading::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p2_common_comparison_category_Reading { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs index 88224a90d1..21eef60d63 100644 --- a/tests/std/class/class.compare/out/unsafe/class.spaceship.rs +++ b/tests/std/class/class.compare/out/unsafe/class.spaceship.rs @@ -61,7 +61,7 @@ impl p1_memberwise_in_declaration_order_Date { && ((((*this).month) == ((*_a0).month)) && (((*this).day) == ((*_a0).day))); } } -impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { +impl Cpp17EqualityComparableUnsafe for p1_memberwise_in_declaration_order_Date { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -73,6 +73,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_D p1_memberwise_in_declaration_order_Date::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_memberwise_in_declaration_order_Date { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -283,7 +285,7 @@ impl p2_common_comparison_category_Reading { return (((*this).sensor) == ((*_a0).sensor)) && (((*this).value) == ((*_a0).value)); } } -impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { +impl Cpp17EqualityComparableUnsafe for p2_common_comparison_category_Reading { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -295,6 +297,8 @@ impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Readin p2_common_comparison_category_Reading::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p2_common_comparison_category_Reading { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs index f2ea868c9e..f583775736 100644 --- a/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/refcount/class.conv.fct.rs @@ -68,7 +68,7 @@ impl p2_implicit_conversion_function_Ratio { return (this.with(|__s| __s.numerator) / this.with(|__s| __s.denominator)); } } -impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { +impl Cpp17EqualityComparable for p2_implicit_conversion_function_Ratio { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -80,6 +80,8 @@ impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { ({ p2_implicit_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for p2_implicit_conversion_function_Ratio { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs index bd0797a523..d8abbc180c 100644 --- a/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs +++ b/tests/std/class/class.mem/class.conv/out/unsafe/class.conv.fct.rs @@ -59,7 +59,7 @@ impl p2_implicit_conversion_function_Ratio { return (((*this).numerator) / ((*this).denominator)); } } -impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Ratio { +impl Cpp17EqualityComparableUnsafe for p2_implicit_conversion_function_Ratio { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -70,6 +70,8 @@ impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Rati return ((unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__lhs)) }) == (unsafe { p2_implicit_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for p2_implicit_conversion_function_Ratio { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs index d585346d25..8d7517c0fb 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.equalitycomparable.rs @@ -37,7 +37,7 @@ impl p1_3_not_equal_Meters { return ({ this.with(|__s| __s.value) } != { other.with(|__s| __s.value) }); } } -impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { +impl Cpp17EqualityComparable for p1_3_not_equal_Meters { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -47,6 +47,8 @@ impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { let __rhs = __rhs.as_pointer(); return ({ p1_3_not_equal_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_3_not_equal_Meters { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -95,7 +97,7 @@ impl p1_2_reversed_operands_Meters { return ({ this.with(|__s| __s.value) } == { (other.read()) }); } } -impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { +impl Cpp17EqualityComparable for p1_2_reversed_operands_Meters { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -105,6 +107,19 @@ impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { let __rhs = __rhs.as_pointer(); return ({ p1_2_reversed_operands_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl Cpp17EqualityComparable for i32 { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -116,15 +131,6 @@ impl WeaklyEqualityComparableWith for p1_2_reversed_operands_Meters { } } impl WeaklyEqualityComparableWith for i32 { - type EqualResult = bool; - fn equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::EqualResult { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_2_reversed_operands_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -187,7 +193,7 @@ impl p1_different_types_Meters { return ({ this.with(|__s| __s.value) } == { (other.read()) }); } } -impl WeaklyEqualityComparableWith for p1_different_types_Meters { +impl Cpp17EqualityComparable for p1_different_types_Meters { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -197,6 +203,19 @@ impl WeaklyEqualityComparableWith for p1_different_types_Meters { let __rhs = __rhs.as_pointer(); return ({ p1_different_types_Meters::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl Cpp17EqualityComparable for i32 { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); + } +} +impl WeaklyEqualityComparableWith for p1_different_types_Meters { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -208,15 +227,6 @@ impl WeaklyEqualityComparableWith for p1_different_types_Meters { } } impl WeaklyEqualityComparableWith for i32 { - type EqualResult = bool; - fn equal( - __lhs: LvalueRef>, - __rhs: LvalueRef>, - ) -> Self::EqualResult { - let __lhs = __lhs.as_pointer(); - let __rhs = __rhs.as_pointer(); - return ({ p1_different_types_Meters::operator_eq((__rhs).clone(), (__lhs).clone()) }); - } type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -251,7 +261,7 @@ pub fn test_3() { __last.as_pointer(), ), )) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind( __it.borrow().iter_deref(), ), @@ -294,7 +304,7 @@ pub fn test_3() { __last.as_pointer(), ), )) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind( __it.borrow().iter_deref(), ), @@ -311,7 +321,7 @@ pub fn test_3() { Rc::new(RefCell::new(lengths.decay().end())).as_pointer(), ) { (__tmp_1, __tmp_3) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind( (__tmp_1).clone(), ), diff --git a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs index cc3dc1fced..787ab38811 100644 --- a/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/refcount/concept.totallyordered.rs @@ -54,7 +54,7 @@ impl p1_each_relation_is_an_operator_Score { return ({ this.with(|__s| __s.points) } >= { other.with(|__s| __s.points) }); } } -impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { +impl Cpp17EqualityComparable for p1_each_relation_is_an_operator_Score { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -66,6 +66,8 @@ impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { p1_each_relation_is_an_operator_Score::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_each_relation_is_an_operator_Score { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -213,7 +215,7 @@ impl p1_relations_from_three_way_Level { )); } } -impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { +impl Cpp17EqualityComparable for p1_relations_from_three_way_Level { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -225,6 +227,8 @@ impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { p1_relations_from_three_way_Level::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_relations_from_three_way_Level { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs index 87c8fbb8e2..6247b064da 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.equalitycomparable.rs @@ -33,7 +33,7 @@ impl p1_3_not_equal_Meters { return (((*this).value) != ((*other).value)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { +impl Cpp17EqualityComparableUnsafe for p1_3_not_equal_Meters { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -43,6 +43,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { let __rhs = (__rhs.as_ptr() as *const p1_3_not_equal_Meters); return (unsafe { p1_3_not_equal_Meters::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_3_not_equal_Meters { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -83,7 +85,7 @@ impl p1_2_reversed_operands_Meters { return (((*this).value) == (*other)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { +impl Cpp17EqualityComparableUnsafe for p1_2_reversed_operands_Meters { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -93,6 +95,19 @@ impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl Cpp17EqualityComparableUnsafe for i32 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); + return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -106,15 +121,6 @@ impl WeaklyEqualityComparableWithUnsafe for p1_2_reversed_operands_Meters { } } impl WeaklyEqualityComparableWithUnsafe for i32 { - type EqualResult = bool; - unsafe fn equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_2_reversed_operands_Meters); - return (unsafe { p1_2_reversed_operands_Meters::operator_eq(&raw const (*__rhs), __lhs) }); - } type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -175,7 +181,7 @@ impl p1_different_types_Meters { return (((*this).value) == (*other)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { +impl Cpp17EqualityComparableUnsafe for p1_different_types_Meters { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -185,6 +191,19 @@ impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { let __rhs = (__rhs.as_ptr() as *const i32); return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl Cpp17EqualityComparableUnsafe for i32 { + type EqualResult = bool; + unsafe fn equal( + __lhs: LvalueRefUnsafe>, + __rhs: LvalueRefUnsafe>, + ) -> Self::EqualResult { + let __lhs = (__lhs.as_ptr() as *const i32); + let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); + return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); + } +} +impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -196,15 +215,6 @@ impl WeaklyEqualityComparableWithUnsafe for p1_different_types_Meters { } } impl WeaklyEqualityComparableWithUnsafe for i32 { - type EqualResult = bool; - unsafe fn equal( - __lhs: LvalueRefUnsafe>, - __rhs: LvalueRefUnsafe>, - ) -> Self::EqualResult { - let __lhs = (__lhs.as_ptr() as *const i32); - let __rhs = (__rhs.as_ptr() as *const p1_different_types_Meters); - return (unsafe { p1_different_types_Meters::operator_eq(&raw const (*__rhs), __lhs) }); - } type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -235,7 +245,7 @@ pub unsafe fn test_3() { &__tmp_1, ), )) && !ConvertibleToUnsafe::::convert_value( - >::equal( + >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&2), ), @@ -256,13 +266,13 @@ pub unsafe fn test_3() { )); assert!((((*found.iter_deref()).value) == (2))); assert!(ConvertibleToUnsafe::::convert_value( - WeaklyEqualityComparableWithUnsafe::equal( + Cpp17EqualityComparableUnsafe::equal( LvalueRefUnsafe::>>::bind( &{ let mut __tmp_2 = { lengths.begin() }; let mut __tmp_3 = { lengths.end() }; let mut __it = (__tmp_2).clone(); - while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), ), ) { __it.iter_inc(); } + while ConvertibleToUnsafe::::convert_value( as WeaklyEqualityComparableWithUnsafe>::not_equal( LvalueRefUnsafe:: >>::bind(&__it), LvalueRefUnsafe:: >>::bind(&__tmp_3 ), ), ) && !ConvertibleToUnsafe::::convert_value( >::equal( LvalueRefUnsafe::>::bind(__it.iter_deref()), LvalueRefUnsafe::>::bind(&7 ), ), ) { __it.iter_inc(); } __it } ), diff --git a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs index ff68b5ff34..01a8d0c932 100644 --- a/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs +++ b/tests/std/concepts/concepts.compare/out/unsafe/concept.totallyordered.rs @@ -63,7 +63,7 @@ impl p1_each_relation_is_an_operator_Score { return (((*this).points) >= ((*other).points)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { +impl Cpp17EqualityComparableUnsafe for p1_each_relation_is_an_operator_Score { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -75,6 +75,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Scor p1_each_relation_is_an_operator_Score::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_each_relation_is_an_operator_Score { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -209,7 +211,7 @@ impl p1_relations_from_three_way_Level { )); } } -impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { +impl Cpp17EqualityComparableUnsafe for p1_relations_from_three_way_Level { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -221,6 +223,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { p1_relations_from_three_way_Level::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_relations_from_three_way_Level { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs index c739773f45..88c8318f65 100644 --- a/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/refcount/concept.convertible.rs @@ -83,7 +83,7 @@ impl p1_convertible_to_Ratio { return (this.with(|__s| __s.numerator) / this.with(|__s| __s.denominator)); } } -impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { +impl Cpp17EqualityComparable for p1_convertible_to_Ratio { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -95,6 +95,8 @@ impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { ({ p1_convertible_to_Ratio::to_i32((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for p1_convertible_to_Ratio { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs index 82d5c9cdf8..ab7b5ab97a 100644 --- a/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs +++ b/tests/std/concepts/concepts.lang/out/unsafe/concept.convertible.rs @@ -73,7 +73,7 @@ impl p1_convertible_to_Ratio { return (((*this).numerator) / ((*this).denominator)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { +impl Cpp17EqualityComparableUnsafe for p1_convertible_to_Ratio { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -84,6 +84,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { return ((unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__lhs)) }) == (unsafe { p1_convertible_to_Ratio::to_i32(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_convertible_to_Ratio { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs index f9110dac11..7becf3e3d9 100644 --- a/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/refcount/sequence.reqmts.rs @@ -31,7 +31,7 @@ impl p38_insert_range_by_conversion_function_Ratio { return this.with(|__s| __s.num); } } -impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ratio { +impl Cpp17EqualityComparable for p38_insert_range_by_conversion_function_Ratio { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -42,6 +42,8 @@ impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ra return ({ ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__lhs).clone()) }) } == { ({ p38_insert_range_by_conversion_function_Ratio::to_i32((__rhs).clone()) }) }); } +} +impl WeaklyEqualityComparableWith for p38_insert_range_by_conversion_function_Ratio { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs index 417ee6db18..4dd364a683 100644 --- a/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs +++ b/tests/std/containers/container.requirements/out/unsafe/sequence.reqmts.rs @@ -28,7 +28,7 @@ impl p38_insert_range_by_conversion_function_Ratio { return (*this).num; } } -impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_function_Ratio { +impl Cpp17EqualityComparableUnsafe for p38_insert_range_by_conversion_function_Ratio { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -42,6 +42,8 @@ impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_funct p38_insert_range_by_conversion_function_Ratio::to_i32(&raw const (*__rhs)) })); } +} +impl WeaklyEqualityComparableWithUnsafe for p38_insert_range_by_conversion_function_Ratio { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs index 397e667d7b..d3dffb2181 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/refcount/allocator.requirements.general.rs @@ -45,7 +45,7 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { field!(this, id).write(0); } } -impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int__int__ { +impl Cpp17EqualityComparable for p16_rebind_member_Alloc_std_pair_const_int__int__ { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -55,6 +55,8 @@ impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int let __rhs = __rhs.as_pointer(); return ({ operator_eq_0((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p16_rebind_member_Alloc_std_pair_const_int__int__ { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs index 6f13c98c37..9178501f0b 100644 --- a/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs +++ b/tests/std/library/requirements/utility.requirements/allocator.requirements/out/unsafe/allocator.requirements.general.rs @@ -40,7 +40,7 @@ impl p16_rebind_member_Alloc_std_pair_const_int__int__ { (&raw mut (*this).id).write(0); } } -impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { +impl Cpp17EqualityComparableUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -53,6 +53,8 @@ impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_con operator_eq_0(_a, __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p16_rebind_member_Alloc_std_pair_const_int__int__ { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs index fb70a77b26..e4d9303eca 100644 --- a/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/refcount/stmt.switch.rs @@ -118,9 +118,7 @@ impl Destructible for p2_condition_variable_lives_for_whole_statement_ConvertsTo (*dtorCount_6.with(Value::clone).borrow_mut()).prefix_inc(); } } -impl WeaklyEqualityComparableWith - for p2_condition_variable_lives_for_whole_statement_ConvertsToInt -{ +impl Cpp17EqualityComparable for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -142,6 +140,10 @@ impl WeaklyEqualityComparableWith }) }); } +} +impl WeaklyEqualityComparableWith + for p2_condition_variable_lives_for_whole_statement_ConvertsToInt +{ type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs index 6517dedc86..4f8614a052 100644 --- a/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs +++ b/tests/std/stmt.stmt/stmt.select/out/unsafe/stmt.switch.rs @@ -92,7 +92,7 @@ impl DestructibleUnsafe for p2_condition_variable_lives_for_whole_statement_Conv (*std::cell::LazyCell::force_mut(&mut *&raw mut dtorCount_6)).prefix_inc(); } } -impl WeaklyEqualityComparableWithUnsafe +impl Cpp17EqualityComparableUnsafe for p2_condition_variable_lives_for_whole_statement_ConvertsToInt { type EqualResult = bool; @@ -118,6 +118,10 @@ impl WeaklyEqualityComparableWithUnsafe ) })); } +} +impl WeaklyEqualityComparableWithUnsafe + for p2_condition_variable_lives_for_whole_statement_ConvertsToInt +{ type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe< diff --git a/tests/std/support/cmp/out/refcount/cmp.concept.rs b/tests/std/support/cmp/out/refcount/cmp.concept.rs index 8bce80b37d..838235d049 100644 --- a/tests/std/support/cmp/out/refcount/cmp.concept.rs +++ b/tests/std/support/cmp/out/refcount/cmp.concept.rs @@ -57,7 +57,7 @@ impl p1_defaulted_three_way_Version { && ({ this.with(|__s| __s.minor) } == { _a0.with(|__s| __s.minor) }); } } -impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { +impl Cpp17EqualityComparable for p1_defaulted_three_way_Version { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -67,6 +67,8 @@ impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { let __rhs = __rhs.as_pointer(); return ({ p1_defaulted_three_way_Version::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_defaulted_three_way_Version { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -254,7 +256,7 @@ impl p1_user_written_three_way_Money { )); } } -impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { +impl Cpp17EqualityComparable for p1_user_written_three_way_Money { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -266,6 +268,8 @@ impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { p1_user_written_three_way_Money::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_user_written_three_way_Money { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, @@ -420,7 +424,7 @@ impl p1_weaker_category_Temperature { )); } } -impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { +impl Cpp17EqualityComparable for p1_weaker_category_Temperature { type EqualResult = bool; fn equal( __lhs: LvalueRef>, @@ -430,6 +434,8 @@ impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { let __rhs = __rhs.as_pointer(); return ({ p1_weaker_category_Temperature::operator_eq((__lhs).clone(), (__rhs).clone()) }); } +} +impl WeaklyEqualityComparableWith for p1_weaker_category_Temperature { type NotEqualResult = bool; fn not_equal( __lhs: LvalueRef>, diff --git a/tests/std/support/cmp/out/unsafe/cmp.concept.rs b/tests/std/support/cmp/out/unsafe/cmp.concept.rs index d1391ae638..c4d2570526 100644 --- a/tests/std/support/cmp/out/unsafe/cmp.concept.rs +++ b/tests/std/support/cmp/out/unsafe/cmp.concept.rs @@ -53,7 +53,7 @@ impl p1_defaulted_three_way_Version { return (((*this).major) == ((*_a0).major)) && (((*this).minor) == ((*_a0).minor)); } } -impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { +impl Cpp17EqualityComparableUnsafe for p1_defaulted_three_way_Version { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -65,6 +65,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { p1_defaulted_three_way_Version::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_defaulted_three_way_Version { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -227,7 +229,7 @@ impl p1_user_written_three_way_Money { )); } } -impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { +impl Cpp17EqualityComparableUnsafe for p1_user_written_three_way_Money { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -239,6 +241,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { p1_user_written_three_way_Money::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_user_written_three_way_Money { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, @@ -387,7 +391,7 @@ impl p1_weaker_category_Temperature { )); } } -impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { +impl Cpp17EqualityComparableUnsafe for p1_weaker_category_Temperature { type EqualResult = bool; unsafe fn equal( __lhs: LvalueRefUnsafe>, @@ -399,6 +403,8 @@ impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { p1_weaker_category_Temperature::operator_eq(&raw const (*__lhs), __rhs) }); } +} +impl WeaklyEqualityComparableWithUnsafe for p1_weaker_category_Temperature { type NotEqualResult = bool; unsafe fn not_equal( __lhs: LvalueRefUnsafe>, diff --git a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs index 3350d167b6..dee72ccfb8 100644 --- a/tests/std/utilities/pairs/out/refcount/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/refcount/pairs.pair.rs @@ -156,25 +156,21 @@ pub fn test_4() { Rc::new(RefCell::new(0)), ))); assert!( - !(ConvertibleTo::::convert_value(::equal( + !(ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*a.borrow()).0.as_pointer()), LvalueRef::>::bind((*b.borrow()).0.as_pointer()), - )) && ConvertibleTo::::convert_value( - ::equal( - LvalueRef::>::bind((*a.borrow()).1.as_pointer()), - LvalueRef::>::bind((*b.borrow()).1.as_pointer()), - ) - )) + )) && ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).1.as_pointer()), + LvalueRef::>::bind((*b.borrow()).1.as_pointer()), + ))) ); assert!( ({ - !(!(ConvertibleTo::::convert_value( - ::equal( - LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - LvalueRef::>::bind((*a.borrow()).0.as_pointer()), - ), - ) && ConvertibleTo::::convert_value( - ::equal( + !(!(ConvertibleTo::::convert_value(::equal( + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + LvalueRef::>::bind((*a.borrow()).0.as_pointer()), + )) && ConvertibleTo::::convert_value( + ::equal( LvalueRef::>::bind((*a.borrow()).1.as_pointer()), LvalueRef::>::bind((*a.borrow()).1.as_pointer()), ), @@ -331,11 +327,11 @@ pub fn test_7() { assert!( ({ ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::equal( + as Cpp17EqualityComparable>::equal( LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), ), - ) && ConvertibleTo::::convert_value(::equal( + ) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), )) @@ -344,11 +340,11 @@ pub fn test_7() { (*y.borrow_mut()) = 5; assert!( !(ConvertibleTo::::convert_value( - as WeaklyEqualityComparableWith>::equal( + as Cpp17EqualityComparable>::equal( LvalueRef::>>::bind((*to_x.borrow()).0.as_pointer()), LvalueRef::>>::bind((*to_y.borrow()).0.as_pointer()), ) - ) && ConvertibleTo::::convert_value(::equal( + ) && ConvertibleTo::::convert_value(::equal( LvalueRef::>::bind((*to_x.borrow()).1.as_pointer()), LvalueRef::>::bind((*to_y.borrow()).1.as_pointer()), ))) diff --git a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs index fd2e3dbfa4..e25948f17c 100644 --- a/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs +++ b/tests/std/utilities/pairs/out/unsafe/pairs.pair.rs @@ -173,28 +173,28 @@ pub unsafe fn test_4() { let mut c: (i32, i32) = (2, 0); assert!( !(ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&a.0), LvalueRefUnsafe::>::bind(&b.0), ) ) && ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&a.1), LvalueRefUnsafe::>::bind(&b.1), - ), + ) )) ); assert!( !(!(ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&a.0), LvalueRefUnsafe::>::bind(&a.0), ) ) && ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&a.1), LvalueRefUnsafe::>::bind(&a.1), - ), + ) ))) ); assert!(ConvertibleToUnsafe::::convert_value( @@ -317,29 +317,29 @@ pub unsafe fn test_7() { let mut to_y: (LvalueRefUnsafe, i32) = (LvalueRefUnsafe::bind(&mut y), 0); assert!( ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::equal( + as Cpp17EqualityComparableUnsafe>::equal( LvalueRefUnsafe::>>::bind(&to_x.0), LvalueRefUnsafe::>>::bind(&to_y.0), ) ) && ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&to_x.1), LvalueRefUnsafe::>::bind(&to_y.1), - ), + ) ) ); y = 5; assert!( !(ConvertibleToUnsafe::::convert_value( - as WeaklyEqualityComparableWithUnsafe>::equal( + as Cpp17EqualityComparableUnsafe>::equal( LvalueRefUnsafe::>>::bind(&to_x.0), LvalueRefUnsafe::>>::bind(&to_y.0), ) ) && ConvertibleToUnsafe::::convert_value( - ::equal( + ::equal( LvalueRefUnsafe::>::bind(&to_x.1), LvalueRefUnsafe::>::bind(&to_y.1), - ), + ) )) ); } diff --git a/tests/unit/out/refcount/class.rs b/tests/unit/out/refcount/class.rs index 2c3aea2601..94e211bf62 100644 --- a/tests/unit/out/refcount/class.rs +++ b/tests/unit/out/refcount/class.rs @@ -114,6 +114,17 @@ impl Counter { return ({ this.with(|__s| __s.v) } == { o.with(|__s| __s.v) }); } } +impl Cpp17EqualityComparable for Counter { + type EqualResult = bool; + fn equal( + __lhs: LvalueRef>, + __rhs: LvalueRef>, + ) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ Counter::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} #[derive( Copy, Clone, diff --git a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs index 3a644061f9..9c9fe83903 100644 --- a/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs +++ b/tests/unit/out/refcount/elidable_iterator_copy_cxx11.rs @@ -33,12 +33,12 @@ fn main_0() -> i32 { LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_2.as_pointer().clone()), - ), - ) { + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_2.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() diff --git a/tests/unit/out/refcount/find.rs b/tests/unit/out/refcount/find.rs index dbd0aeaf2a..1370029f23 100644 --- a/tests/unit/out/refcount/find.rs +++ b/tests/unit/out/refcount/find.rs @@ -30,6 +30,14 @@ impl P { return ({ this.with(|__s| __s.x) } == { o.with(|__s| __s.x) }); } } +impl Cpp17EqualityComparable for P { + type EqualResult = bool; + fn equal(__lhs: LvalueRef>, __rhs: LvalueRef>) -> Self::EqualResult { + let __lhs = __lhs.as_pointer(); + let __rhs = __rhs.as_pointer(); + return ({ P::operator_eq((__lhs).clone(), (__rhs).clone()) }); + } +} pub fn main() { __cpp2rust_init_globals(); libcc2rs::cpp2rust_exit(main_0()); @@ -63,12 +71,12 @@ fn main_0() -> i32 { LvalueRef::>>::bind(__it.as_pointer()), LvalueRef::>>::bind(__last.as_pointer()), ), - ) && !ConvertibleTo::::convert_value( - >::equal( - LvalueRef::>::bind(__it.borrow().iter_deref()), - LvalueRef::>::bind(__tmp_3.as_pointer().clone()), - ), - ) { + ) && !ConvertibleTo::::convert_value(>::equal( + LvalueRef::>::bind(__it.borrow().iter_deref()), + LvalueRef::>::bind(__tmp_3.as_pointer().clone()), + )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone() @@ -119,7 +127,7 @@ fn main_0() -> i32 { m_end.as_pointer(), ), )); - assert!(( ( v_result_true ) && ( m_result_true ) ) && ( match (Rc::new(RefCell::new(({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(v .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(v .decay() .begin() )); while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), )) && !ConvertibleTo::::convert_value(>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(v .decay() .begin() )).as_pointer(),) { (__tmp_8, __tmp_10,) => { ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( LvalueRef:: >>::bind((__tmp_8 ).clone()), LvalueRef:: >>::bind((__tmp_10 ).clone()), )) } } ) ); + assert!(( ( v_result_true ) && ( m_result_true ) ) && ( match (Rc::new(RefCell::new(({ let __tmp_9 : Value = Rc::new(RefCell::new(2 )); {let __it: Value > = Rc::new(RefCell::new(v .decay() .begin() )); let __last: Value > = Rc::new(RefCell::new(v .decay() .begin() )); while ConvertibleTo::::convert_value( as WeaklyEqualityComparableWith>::not_equal( LvalueRef:: >>::bind(__it.as_pointer()), LvalueRef:: >>::bind(__last.as_pointer()), )) && !ConvertibleTo::::convert_value(>::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_9.as_pointer().clone()), )) { __it.borrow_mut().iter_inc(); } __it.borrow().clone()} }) )).as_pointer(), Rc::new(RefCell::new(v .decay() .begin() )).as_pointer(),) { (__tmp_8, __tmp_10,) => { ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef:: >>::bind((__tmp_8 ).clone()), LvalueRef:: >>::bind((__tmp_10 ).clone()), )) } } ) ); let w: Value> = Rc::new(RefCell::new(Vec::from([1, 2, 3, 4, 5]))); assert!(match ( Rc::new(RefCell::new( @@ -138,7 +146,7 @@ fn main_0() -> i32 { ), ), ) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_12.as_pointer().clone()), ), @@ -153,7 +161,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(3_isize))).as_pointer(), ) { (__tmp_11, __tmp_13) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_11).clone()), LvalueRef::>>::bind((__tmp_13).clone()), )) @@ -176,7 +184,7 @@ fn main_0() -> i32 { ), ), ) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_15.as_pointer().clone()), ), @@ -191,7 +199,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().end())).as_pointer(), ) { (__tmp_14, __tmp_16) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_14).clone()), LvalueRef::>>::bind((__tmp_16).clone()), )) @@ -214,7 +222,7 @@ fn main_0() -> i32 { ), ), ) && !ConvertibleTo::::convert_value( - >::equal( + >::equal( LvalueRef::>::bind(__it.borrow().iter_deref()), LvalueRef::>::bind(__tmp_18.as_pointer().clone()), ), @@ -229,7 +237,7 @@ fn main_0() -> i32 { Rc::new(RefCell::new(w.decay().begin().iter_add(4_isize))).as_pointer(), ) { (__tmp_17, __tmp_19) => { - ConvertibleTo::::convert_value(WeaklyEqualityComparableWith::equal( + ConvertibleTo::::convert_value(Cpp17EqualityComparable::equal( LvalueRef::>>::bind((__tmp_17).clone()), LvalueRef::>>::bind((__tmp_19).clone()), )) @@ -255,7 +263,7 @@ fn main_0() -> i32 { LvalueRef::>>::bind(__last.as_pointer()), ), ) && !ConvertibleTo::::convert_value( -