Skip to content

Commit bb57f6e

Browse files
committed
fix some clippy warnings
1 parent c471c5a commit bb57f6e

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

Diff for: src/int/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,14 @@ macro_rules! impl_wide_int {
429429

430430
fn wide_shift_left(&mut self, low: &mut Self, count: i32) {
431431
*self = (*self << count) | (*low >> ($bits - count));
432-
*low = *low << count;
432+
*low <<= count;
433433
}
434434

435435
fn wide_shift_right_with_sticky(&mut self, low: &mut Self, count: i32) {
436436
if count < $bits {
437437
let sticky = *low << ($bits - count);
438438
*low = *self << ($bits - count) | *low >> count | sticky;
439-
*self = *self >> count;
439+
*self >>= count;
440440
} else if count < 2 * $bits {
441441
let sticky = *self << (2 * $bits - count) | *low;
442442
*low = *self >> (count - $bits) | sticky;

Diff for: src/mem/impls.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
use super::c_int;
2-
31
#[inline(always)]
42
pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, n: usize) {
53
let mut i = 0;
64
while i < n {
7-
*dest.offset(i as isize) = *src.offset(i as isize);
5+
*dest.add(i) = *src.add(i);
86
i += 1;
97
}
108
}
@@ -15,15 +13,15 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, n: usize) {
1513
let mut i = n;
1614
while i != 0 {
1715
i -= 1;
18-
*dest.offset(i as isize) = *src.offset(i as isize);
16+
*dest.add(i) = *src.add(i);
1917
}
2018
}
2119

2220
#[inline(always)]
2321
pub unsafe fn set_bytes(s: *mut u8, c: u8, n: usize) {
2422
let mut i = 0;
2523
while i < n {
26-
*s.offset(i as isize) = c;
24+
*s.add(i) = c;
2725
i += 1;
2826
}
2927
}

Diff for: src/mem/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 {
4242
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
4343
let mut i = 0;
4444
while i < n {
45-
let a = *s1.offset(i as isize);
46-
let b = *s2.offset(i as isize);
45+
let a = *s1.add(i);
46+
let b = *s2.add(i);
4747
if a != b {
4848
return a as i32 - b as i32;
4949
}

Diff for: src/mem/x86_64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) {
5959
"cld",
6060
byte_count = in(reg) byte_count,
6161
inout("rcx") qword_count => _,
62-
inout("rdi") dest.offset(count as isize).wrapping_sub(8) => _,
63-
inout("rsi") src.offset(count as isize).wrapping_sub(8) => _,
62+
inout("rdi") dest.add(count).wrapping_sub(8) => _,
63+
inout("rsi") src.add(count).wrapping_sub(8) => _,
6464
options(nostack)
6565
);
6666
}

0 commit comments

Comments
 (0)