Skip to content

Commit b2e7cef

Browse files
authored
ctutils: remove target_pointer_width gating (#1389)
From #1387, via rustc itself: expected values for `target_pointer_width` are: `16`, `32`, and `64` So these impls should actually be ubiquitously available, for now. If we remove the gating in this crate, then all we need to do to handle new pointer widths is ship a fix for `cmov`.
1 parent b5d28ce commit b2e7cef

2 files changed

Lines changed: 3 additions & 37 deletions

File tree

ctutils/src/traits/ct_lookup.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ mod tests {
9999
assert!(EXAMPLE.ct_lookup(4u32).is_none().to_bool());
100100
}
101101

102-
// usize only has a `CtEq` impl on 32-bit and 64-bit targets currently
103-
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
104102
#[test]
105103
fn ct_lookup_usize() {
106104
assert_eq!(EXAMPLE.ct_lookup(0usize).unwrap(), 1);
@@ -125,8 +123,6 @@ mod tests {
125123
assert!(EXAMPLE.ct_lookup(4u32).is_none().to_bool());
126124
}
127125

128-
// usize only has a `CtEq` impl on 32-bit and 64-bit targets currently
129-
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
130126
#[test]
131127
fn ct_lookup_usize() {
132128
assert_eq!(EXAMPLE.ct_lookup(0usize).unwrap(), 1);

ctutils/src/traits/ct_select.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ macro_rules! impl_ct_select_with_ct_assign {
101101
};
102102
}
103103

104-
impl_ct_select_with_ct_assign!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128);
104+
impl_ct_select_with_ct_assign!(
105+
i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize
106+
);
105107

106108
/// Impl `CtSelect` for `NonZero<T>` by calling the `CtSelect` impl for `T`.
107109
macro_rules! impl_ct_select_for_nonzero_integer {
@@ -135,38 +137,6 @@ impl_ct_select_for_nonzero_integer!(
135137
NonZeroU128
136138
);
137139

138-
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
139-
impl CtSelect for isize {
140-
#[cfg(target_pointer_width = "32")]
141-
#[inline]
142-
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
143-
(*self as i32).ct_select(&(*other as i32), choice) as isize
144-
}
145-
146-
#[cfg(target_pointer_width = "64")]
147-
#[allow(clippy::cast_possible_truncation)]
148-
#[inline]
149-
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
150-
(*self as i64).ct_select(&(*other as i64), choice) as isize
151-
}
152-
}
153-
154-
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
155-
impl CtSelect for usize {
156-
#[cfg(target_pointer_width = "32")]
157-
#[inline]
158-
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
159-
(*self as u32).ct_select(&(*other as u32), choice) as usize
160-
}
161-
162-
#[cfg(target_pointer_width = "64")]
163-
#[allow(clippy::cast_possible_truncation)]
164-
#[inline]
165-
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
166-
(*self as u64).ct_select(&(*other as u64), choice) as usize
167-
}
168-
}
169-
170140
impl CtSelect for cmp::Ordering {
171141
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
172142
// `Ordering` is `#[repr(i8)]` where:

0 commit comments

Comments
 (0)