Skip to content

cmov: add support for NonZero and Ordering#1404

Merged
tarcieri merged 1 commit intomasterfrom
cmov/nonzero-and-ordering-support
Jan 19, 2026
Merged

cmov: add support for NonZero and Ordering#1404
tarcieri merged 1 commit intomasterfrom
cmov/nonzero-and-ordering-support

Conversation

@tarcieri
Copy link
Member

Adds Cmov and CmovEq impls for the following types (and slices thereof) from core::num:

  • NonZeroI8
  • NonZeroI16
  • NonZeroI32
  • NonZeroI64
  • NonZeroI128
  • NonZeroU8
  • NonZeroU16
  • NonZeroU32
  • NonZeroU64
  • NonZeroU128

Also adds support to core::cmp::Ordering.

This should be sufficient to eliminate unsafe code from ctutils, and also improve performance.

Adds `Cmov` and `CmovEq` impls for the following types (and slices
thereof) from `core::num`:

- NonZeroI8
- NonZeroI16
- NonZeroI32
- NonZeroI64
- NonZeroI128
- NonZeroU8
- NonZeroU16
- NonZeroU32
- NonZeroU64
- NonZeroU128

Also adds support to `core::cmp::Ordering`.

This should be sufficient to eliminate unsafe code from `ctutils`, and
also improve performance.
@tarcieri tarcieri merged commit 5262484 into master Jan 19, 2026
23 checks passed
@tarcieri tarcieri deleted the cmov/nonzero-and-ordering-support branch January 19, 2026 04:09
tarcieri added a commit that referenced this pull request Jan 19, 2026
In #1404 impls of `Cmov` and `CmovEq` were added to the `NonZero*` and
`Ordering` types and slices thereof, which is what the unsafe code in
`ctutils` existed to handle.

Now they can be handled like the other types `cmov` already has trait
impls for.

And with that, we can remove all of the unsafe code in this crate,
with all of it having been factored into the `cmov` crate, which makes
that the one place to look for `unsafe` auditing.

With all the `unsafe` removed, this also adds `forbid(unsafe_code)`.
tarcieri added a commit that referenced this pull request Jan 19, 2026
In #1404 impls of `Cmov` and `CmovEq` were added to the `NonZero*` and
`Ordering` types and slices thereof, which is what the unsafe code in
`ctutils` existed to handle.

Now they can be handled like the other types `cmov` already has trait
impls for.

And with that, we can remove all of the unsafe code in this crate,
with all of it having been factored into the `cmov` crate, which makes
that the one place to look for `unsafe` auditing.

With all the `unsafe` removed, this also adds `forbid(unsafe_code)`.
@tarcieri tarcieri mentioned this pull request Jan 19, 2026
tarcieri added a commit that referenced this pull request Jan 19, 2026
## Added
- `riscv32` optimised mask generation (#1396)
- `riscv64` optimised mask generation (#1397)
- Support for `core::num::NonZero*` and `core::cmp::Ordering` (#1404)
tarcieri added a commit that referenced this pull request Jan 19, 2026
In #1404 impls of `Cmov` and `CmovEq` were added to the `NonZero*` and
`Ordering` types and slices thereof, which is what the unsafe code in
`ctutils` existed to handle.

Now they can be handled like the other types `cmov` already has trait
impls for.

And with that, we can remove all of the unsafe code in this crate,
with all of it having been factored into the `cmov` crate, which makes
that the one place to look for `unsafe` auditing.

With all the `unsafe` removed, this also adds `forbid(unsafe_code)`.
tarcieri added a commit that referenced this pull request Jan 19, 2026
In #1404 impls of `Cmov` and `CmovEq` were added to the `NonZero*` and
`Ordering` types and slices thereof, which is what the unsafe code in
`ctutils` existed to handle.

Now they can be handled like the other types `cmov` already has trait
impls for.

And with that, we can remove all of the unsafe code in this crate, with
all of it having been factored into the `cmov` crate, which makes that
the one place to look for `unsafe` auditing.

With all the `unsafe` removed, this also adds `forbid(unsafe_code)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant