-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override PartialOrd methods for bool #138945
Conversation
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.
rustbot has assigned @Mark-Simulacrum. Use |
@@ -1912,6 +1914,8 @@ mod impls { | |||
fn partial_cmp(&self, other: &bool) -> Option<Ordering> { | |||
Some(self.cmp(other)) | |||
} | |||
|
|||
partial_ord_methods_primitive_impl!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I was also adding the chaining ones here in https://github.com/rust-lang/rust/pull/138881/files#diff-792af5fefd1cfdfab121523d464c37a6793eea3b804ac5a9cb3aaa8aa1b2ade4R1916, but I like this version instead that merges the lt
/le
/etc in too.
I'll rebase mine atop yours; this can go in first.
Thanks! Definitely agreed that the current behaviour https://rust.godbolt.org/z/s14bshzGE where we get core::cmp::PartialOrd::lt::ha3b3e39dc7c4e4d4:
sub rsp, 40
mov qword ptr [rsp + 16], rdi
mov qword ptr [rsp + 24], rsi
call core::cmp::impls::<impl core::cmp::PartialOrd for bool>::partial_cmp::h0dc623f7b1df1961
mov byte ptr [rsp + 15], al
mov eax, 1
xor ecx, ecx
cmp byte ptr [rsp + 15], 2
cmove rax, rcx
test rax, 1
je .LBB0_2
mov al, byte ptr [rsp + 15]
mov byte ptr [rsp + 39], al
cmp al, 0
setl al
and al, 1
mov byte ptr [rsp + 14], al
jmp .LBB0_3
.LBB0_2:
mov byte ptr [rsp + 14], 0
.LBB0_3:
mov al, byte ptr [rsp + 14]
and al, 1
add rsp, 40
ret is silly. @bors r+ rollup |
Rollup of 11 pull requests Successful merges: - rust-lang#138128 (Stabilize `#![feature(precise_capturing_in_traits)]`) - rust-lang#138834 (Group test diffs by stage in post-merge analysis) - rust-lang#138867 (linker: Fix staticlib naming for UEFI) - rust-lang#138874 (Batch mark waiters as unblocked when resuming in the deadlock handler) - rust-lang#138875 (Trusty: Fix build for anonymous pipes and std::sys::process) - rust-lang#138877 (Ignore doctests only in specified targets) - rust-lang#138885 (Fix ui pattern_types test for big-endian platforms) - rust-lang#138905 (Add target maintainer information for powerpc64-unknown-linux-musl) - rust-lang#138911 (Allow defining opaques in statics and consts) - rust-lang#138917 (rustdoc: remove useless `Symbol::is_empty` checks.) - rust-lang#138945 (Override PartialOrd methods for bool) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#138945 - DaniPopes:override-partialord-bool, r=scottmcm 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. CC `@scottmcm` for our recent adventures in `PartialOrd` land
…, r=scottmcm 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. CC `@scottmcm` for our recent adventures in `PartialOrd` land
Rollup of 11 pull requests Successful merges: - rust-lang#138128 (Stabilize `#![feature(precise_capturing_in_traits)]`) - rust-lang#138834 (Group test diffs by stage in post-merge analysis) - rust-lang#138867 (linker: Fix staticlib naming for UEFI) - rust-lang#138874 (Batch mark waiters as unblocked when resuming in the deadlock handler) - rust-lang#138875 (Trusty: Fix build for anonymous pipes and std::sys::process) - rust-lang#138877 (Ignore doctests only in specified targets) - rust-lang#138885 (Fix ui pattern_types test for big-endian platforms) - rust-lang#138905 (Add target maintainer information for powerpc64-unknown-linux-musl) - rust-lang#138911 (Allow defining opaques in statics and consts) - rust-lang#138917 (rustdoc: remove useless `Symbol::is_empty` checks.) - rust-lang#138945 (Override PartialOrd methods for bool) r? `@ghost` `@rustbot` modify labels: rollup
I noticed that
PartialOrd
implementation forbool
does not override the individual operator methods, unlike the other primitive types likechar
and integers.This commit extracts these
PartialOrd
overrides shared by the other primitive types into a macro and calls it onbool
too.CC @scottmcm for our recent adventures in
PartialOrd
land