Skip to content

Commit 244b3c8

Browse files
committed
Remove use of Self() tuple struct constructors which are unstable in Rust 1.31
1 parent 3805c65 commit 244b3c8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/raw/bitmask.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ use core::intrinsics;
1616
#[derive(Copy, Clone)]
1717
pub struct BitMask(pub BitMaskWord);
1818

19+
#[allow(clippy::use_self)]
1920
impl BitMask {
2021
/// Returns a new `BitMask` with all bits inverted.
2122
#[inline]
2223
#[must_use]
2324
pub fn invert(self) -> Self {
24-
Self(self.0 ^ BITMASK_MASK)
25+
BitMask(self.0 ^ BITMASK_MASK)
2526
}
2627

2728
/// Returns a new `BitMask` with the lowest bit removed.
2829
#[inline]
2930
#[must_use]
3031
pub fn remove_lowest_bit(self) -> Self {
31-
Self(self.0 & (self.0 - 1))
32+
BitMask(self.0 & (self.0 - 1))
3233
}
3334
/// Returns whether the `BitMask` has at least one set bit.
3435
#[inline]

src/raw/generic.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ type GroupWord = u32;
2121
pub type BitMaskWord = GroupWord;
2222
pub const BITMASK_STRIDE: usize = 8;
2323
// We only care about the highest bit of each byte for the mask.
24-
#[allow(clippy::cast_possible_truncation)]
24+
#[allow(
25+
clippy::cast_possible_truncation,
26+
clippy::unnecessary_cast,
27+
)]
2528
pub const BITMASK_MASK: BitMaskWord = 0x8080_8080_8080_8080_u64 as GroupWord;
2629

2730
/// Helper function to replicate a byte across a `GroupWord`.
@@ -70,7 +73,7 @@ impl Group {
7073
#[inline]
7174
#[allow(clippy::cast_ptr_alignment)] // unaligned load
7275
pub unsafe fn load(ptr: *const u8) -> Self {
73-
Self(ptr::read_unaligned(ptr as *const _))
76+
Group(ptr::read_unaligned(ptr as *const _))
7477
}
7578

7679
/// Loads a group of bytes starting at the given address, which must be
@@ -80,7 +83,7 @@ impl Group {
8083
pub unsafe fn load_aligned(ptr: *const u8) -> Self {
8184
// FIXME: use align_offset once it stabilizes
8285
debug_assert_eq!(ptr as usize & (mem::align_of::<Self>() - 1), 0);
83-
Self(ptr::read(ptr as *const _))
86+
Group(ptr::read(ptr as *const _))
8487
}
8588

8689
/// Stores the group of bytes to the given address, which must be
@@ -143,6 +146,6 @@ impl Group {
143146
// !1000_0000 + 1 = 0111_1111 + 1 = 1000_0000 (no carry)
144147
// !0000_0000 + 0 = 1111_1111 + 0 = 1111_1111 (no carry)
145148
let full = !self.0 & repeat(0x80);
146-
Self(!full + (full >> 7))
149+
Group(!full + (full >> 7))
147150
}
148151
}

src/raw/sse2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Group {
4444
#[inline]
4545
#[allow(clippy::cast_ptr_alignment)] // unaligned load
4646
pub unsafe fn load(ptr: *const u8) -> Self {
47-
Self(x86::_mm_loadu_si128(ptr as *const _))
47+
Group(x86::_mm_loadu_si128(ptr as *const _))
4848
}
4949

5050
/// Loads a group of bytes starting at the given address, which must be
@@ -54,7 +54,7 @@ impl Group {
5454
pub unsafe fn load_aligned(ptr: *const u8) -> Self {
5555
// FIXME: use align_offset once it stabilizes
5656
debug_assert_eq!(ptr as usize & (mem::align_of::<Self>() - 1), 0);
57-
Self(x86::_mm_load_si128(ptr as *const _))
57+
Group(x86::_mm_load_si128(ptr as *const _))
5858
}
5959

6060
/// Stores the group of bytes to the given address, which must be
@@ -128,7 +128,7 @@ impl Group {
128128
unsafe {
129129
let zero = x86::_mm_setzero_si128();
130130
let special = x86::_mm_cmpgt_epi8(zero, self.0);
131-
Self(x86::_mm_or_si128(special, x86::_mm_set1_epi8(0x80_u8 as i8)))
131+
Group(x86::_mm_or_si128(special, x86::_mm_set1_epi8(0x80_u8 as i8)))
132132
}
133133
}
134134
}

0 commit comments

Comments
 (0)