Skip to content

Commit 062f2fc

Browse files
authored
Rollup merge of #104125 - ink-feather-org:const_cmp_tuples, r=fee1-dead
Const Compare for Tuples Makes the impls for Tuples of ~const `PartialEq` types also `PartialEq`, impls for Tuples of ~const `PartialOrd` types also `PartialOrd`, for Tuples of ~const `Ord` types also `Ord`. behind the `#![feature(const_cmp)]` gate. ~~Do not merge before #104113 is merged because I want to use this feature to clean up the new test that I added there.~~ r? ``@fee1-dead``
2 parents 64e737c + b6c05eb commit 062f2fc

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Diff for: library/core/src/tuple.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ macro_rules! tuple_impls {
2222
maybe_tuple_doc! {
2323
$($T)+ @
2424
#[stable(feature = "rust1", since = "1.0.0")]
25-
impl<$($T:PartialEq),+> PartialEq for ($($T,)+)
25+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
26+
impl<$($T: ~const PartialEq),+> const PartialEq for ($($T,)+)
2627
where
2728
last_type!($($T,)+): ?Sized
2829
{
@@ -40,7 +41,7 @@ macro_rules! tuple_impls {
4041
maybe_tuple_doc! {
4142
$($T)+ @
4243
#[stable(feature = "rust1", since = "1.0.0")]
43-
impl<$($T:Eq),+> Eq for ($($T,)+)
44+
impl<$($T: Eq),+> Eq for ($($T,)+)
4445
where
4546
last_type!($($T,)+): ?Sized
4647
{}
@@ -49,7 +50,8 @@ macro_rules! tuple_impls {
4950
maybe_tuple_doc! {
5051
$($T)+ @
5152
#[stable(feature = "rust1", since = "1.0.0")]
52-
impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+)
53+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
54+
impl<$($T: ~const PartialOrd + ~const PartialEq),+> const PartialOrd for ($($T,)+)
5355
where
5456
last_type!($($T,)+): ?Sized
5557
{
@@ -79,7 +81,8 @@ macro_rules! tuple_impls {
7981
maybe_tuple_doc! {
8082
$($T)+ @
8183
#[stable(feature = "rust1", since = "1.0.0")]
82-
impl<$($T:Ord),+> Ord for ($($T,)+)
84+
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
85+
impl<$($T: ~const Ord),+> const Ord for ($($T,)+)
8386
where
8487
last_type!($($T,)+): ?Sized
8588
{

Diff for: src/test/ui/consts/fn_trait_refs.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build-pass
1+
// check-pass
22

33
#![feature(const_fn_trait_ref_impls)]
44
#![feature(fn_traits)]
@@ -60,21 +60,18 @@ const fn test(i: i32) -> i32 {
6060
i + 1
6161
}
6262

63-
const fn main() {
63+
fn main() {
6464
const fn one() -> i32 {
6565
1
6666
};
6767
const fn two() -> i32 {
6868
2
6969
};
70+
const _: () = {
71+
let test_one = test_fn(one);
72+
assert!(test_one == (1, 1, 1));
7073

71-
// FIXME(const_cmp_tuple)
72-
let test_one = test_fn(one);
73-
assert!(test_one.0 == 1);
74-
assert!(test_one.1 == 1);
75-
assert!(test_one.2 == 1);
76-
77-
let test_two = test_fn_mut(two);
78-
assert!(test_two.0 == 1);
79-
assert!(test_two.1 == 1);
74+
let test_two = test_fn_mut(two);
75+
assert!(test_two == (2, 2));
76+
};
8077
}

0 commit comments

Comments
 (0)