Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e9ddf54
Group test diffs by stage in post-merge analysis
Kobzol Mar 22, 2025
eb3707e
Stabilize precise_capturing_in_traits
compiler-errors Mar 6, 2025
fbcf765
Revert "resume one waiter at a call"
Zoxc Mar 24, 2025
14786ce
Batch mark waiters as unblocked when resuming in the deadlock handler
Zoxc Mar 24, 2025
b672659
Trusty: Fix build for anonymous pipes and std::sys::process
thaliaarchi Mar 24, 2025
38c39ff
Remove `QueryWaiter::notify`
Zoxc Mar 24, 2025
02e1f11
Fix ui pattern_types test for big-endian platforms
fneddy Mar 24, 2025
43653c1
linker: Fix staticlib naming for UEFI
petrochenkov Mar 23, 2025
27e95f9
linker: Avoid calling `linker_and_flavor` twice
petrochenkov Mar 23, 2025
7c55782
rustc_session: Add a helper function for obtaining staticlib prefix a…
petrochenkov Mar 24, 2025
1a8ddee
Add target maintainer information for powerpc64-unknown-linux-musl
Gelbpunkt Mar 24, 2025
90c541d
ignore doctests only in specified targets
TaKO8Ki Mar 24, 2025
6bea9c7
rustdoc: remove useless `Symbol::is_empty` checks.
nnethercote Mar 25, 2025
2bf0c2d
Make printing define_opaque less goofy
compiler-errors Mar 24, 2025
f8df298
Allow defining opaques in statics and consts
compiler-errors Mar 24, 2025
0827f76
Test define opaques in extern items
compiler-errors Mar 24, 2025
154cb08
Override PartialOrd methods for bool
DaniPopes Mar 25, 2025
1c84c06
Rollup merge of #138128 - compiler-errors:precise-capturing-in-traits…
jhpratt Mar 26, 2025
277902b
Rollup merge of #138834 - Kobzol:test-diff-group-by-stage, r=marcoieni
jhpratt Mar 26, 2025
a883b23
Rollup merge of #138867 - petrochenkov:linkfix, r=nnethercote
jhpratt Mar 26, 2025
8b61871
Rollup merge of #138874 - Zoxc:waiter-race, r=SparrowLii,davidtwco
jhpratt Mar 26, 2025
0d61b83
Rollup merge of #138875 - thaliaarchi:trusty-build, r=randomPoison,sa…
jhpratt Mar 26, 2025
fc8fc05
Rollup merge of #138877 - TaKO8Ki:enable-per-target-ignores-for-docte…
jhpratt Mar 26, 2025
2da6e4d
Rollup merge of #138885 - fneddy:fix_pattern_types_tests, r=compiler-…
jhpratt Mar 26, 2025
f6bfdff
Rollup merge of #138905 - Gelbpunkt:powerpc64-unknown-linux-musl-main…
jhpratt Mar 26, 2025
5bd69d9
Rollup merge of #138911 - compiler-errors:define-opaque, r=oli-obk
jhpratt Mar 26, 2025
04cbe28
Rollup merge of #138917 - nnethercote:rustdoc-remove-useless, r=Guill…
jhpratt Mar 26, 2025
deb987b
Rollup merge of #138945 - DaniPopes:override-partialord-bool, r=scottmcm
jhpratt Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Override PartialOrd methods for bool
I noticed that `PartialOrd` implementation for `bool` does not override the
individual operator methods, unlike the other primitive types like `char`
and integers.

This commit extracts these `PartialOrd` overrides shared by the other
primitive types into a macro and calls it on `bool` too.
  • Loading branch information
DaniPopes committed Mar 25, 2025
commit 154cb083e705feca7509143352887dd293db61b2
50 changes: 23 additions & 27 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,9 +1810,9 @@ mod impls {
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for $t {
#[inline]
fn eq(&self, other: &$t) -> bool { (*self) == (*other) }
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
fn ne(&self, other: &Self) -> bool { *self != *other }
}
)*)
}
Expand Down Expand Up @@ -1842,8 +1842,18 @@ mod impls {

eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }

macro_rules! chaining_methods_impl {
($t:ty) => {
#[rustfmt::skip]
macro_rules! partial_ord_methods_primitive_impl {
() => {
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }

// These implementations are the same for `Ord` or `PartialOrd` types
// because if either is NAN the `==` test will fail so we end up in
// the `Break` case and the comparison will correctly return `false`.
Expand Down Expand Up @@ -1876,24 +1886,16 @@ mod impls {
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
(false, false) => None,
(false, true) => Some(Greater),
(true, false) => Some(Less),
(true, true) => Some(Equal),
}
}
#[inline(always)]
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
#[inline(always)]
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
#[inline(always)]
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
#[inline(always)]
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }

chaining_methods_impl!($t);

partial_ord_methods_primitive_impl!();
}
)*)
}
Expand All @@ -1912,6 +1914,8 @@ mod impls {
fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
Some(self.cmp(other))
}

partial_ord_methods_primitive_impl!();
}

partial_ord_impl! { f16 f32 f64 f128 }
Expand All @@ -1921,25 +1925,17 @@ mod impls {
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &$t) -> bool { (*self) < (*other) }
#[inline(always)]
fn le(&self, other: &$t) -> bool { (*self) <= (*other) }
#[inline(always)]
fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
#[inline(always)]
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }

chaining_methods_impl!($t);

partial_ord_methods_primitive_impl!();
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Ord for $t {
#[inline]
fn cmp(&self, other: &$t) -> Ordering {
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
}
Expand Down
Loading