Skip to content

Commit 7b83e03

Browse files
committed
[clippy] fix clippy issues
1 parent 104a6b3 commit 7b83e03

File tree

16 files changed

+85
-64
lines changed

16 files changed

+85
-64
lines changed

.appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ install:
1515
- if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET%
1616
- rustc -vV
1717
- cargo -vV
18-
- cargo install clippy
1918

2019
build: false
2120

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@ matrix:
1717
- install: true
1818
script: ci/dox.sh
1919
- env: CLIPPY=On TARGET=x86_64-unknown-linux-gnu NO_ADD=1
20+
script: |
21+
cargo install clippy
22+
cargo clippy --all -- -D clippy-pedantic
2023
allow_failures:
2124
- env: CLIPPY=On TARGET=x86_64-unknown-linux-gnu NO_ADD=1
2225
install:
2326
- if [ "$NO_ADD" == "" ]; then rustup target add $TARGET; fi
2427

2528
script:
2629
- cargo generate-lockfile
27-
- if [[ "${CLIPPY}" == "" ]]; then ci/run-docker.sh $TARGET; fi
28-
- |
29-
if [[ "${CLIPPY}" == "On" ]]; then
30-
cargo install clippy
31-
cargo clippy --all -- -D clippy-pedantic
32-
fi
30+
- ci/run-docker.sh $TARGET
3331

3432
notifications:
3533
email:

ci/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ set -ex
44

55
cargo test --target $TARGET
66
cargo test --release --target $TARGET
7-
cargo clippy --all -- -D clippy-pedantic

examples/play.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#![feature(target_feature)]
22

3+
#![cfg_attr(feature = "cargo-clippy",
4+
allow(similar_names, missing_docs_in_private_items, cast_sign_loss,
5+
cast_possible_truncation, cast_possible_wrap, option_unwrap_used,
6+
use_debug, print_stdout,
7+
)
8+
)]
9+
310
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
411
mod example {
512

examples/types.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![feature(target_feature)]
22

3+
#![cfg_attr(feature = "cargo-clippy",
4+
allow(missing_docs_in_private_items, result_unwrap_used,
5+
option_unwrap_used, print_stdout, use_debug
6+
)
7+
)]
8+
39
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
410
mod example {
511
extern crate stdsimd;

examples/wat.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![feature(target_feature)]
22

3+
#![cfg_attr(feature = "cargo-clippy",
4+
allow(missing_docs_in_private_items, result_unwrap_used,
5+
option_unwrap_used, print_stdout, use_debug
6+
)
7+
)]
8+
39
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
410
mod example {
511
extern crate stdsimd;

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! others at:
2727
//!
2828
//! * [i686](https://rust-lang-nursery.github.io/stdsimd/i686/stdsimd/)
29-
//! * [x86_64](https://rust-lang-nursery.github.io/stdsimd/x86_64/stdsimd/)
29+
//! * [`x86_64`](https://rust-lang-nursery.github.io/stdsimd/x86_64/stdsimd/)
3030
//! * [arm](https://rust-lang-nursery.github.io/stdsimd/arm/stdsimd/)
3131
//! * [aarch64](https://rust-lang-nursery.github.io/stdsimd/aarch64/stdsimd/)
3232
//!
@@ -117,6 +117,13 @@
117117
)]
118118
#![cfg_attr(test, feature(proc_macro, test))]
119119

120+
#![cfg_attr(feature = "cargo-clippy",
121+
allow(inline_always, too_many_arguments, missing_docs_in_private_items,
122+
cast_sign_loss, cast_lossless, cast_possible_wrap,
123+
cast_possible_truncation, cast_precision_loss, shadow_reuse,
124+
cyclomatic_complexity, similar_names
125+
))]
126+
120127
#[cfg(test)]
121128
extern crate stdsimd_test;
122129

src/x86/avx.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub unsafe fn _mm256_shuffle_pd(a: f64x4, b: f64x4, imm8: i32) -> f64x4 {
106106
}
107107
}
108108
}
109-
match (imm8 >> 0) & 0x1 {
109+
match imm8 & 0x1 {
110110
0 => shuffle1!(0),
111111
_ => shuffle1!(1),
112112
}
@@ -806,8 +806,8 @@ pub unsafe fn _mm_permutevar_ps(a: f32x4, b: i32x4) -> f32x4 {
806806
#[target_feature = "+avx"]
807807
#[cfg_attr(test, assert_instr(vpermilps, imm8 = 9))]
808808
pub unsafe fn _mm256_permute_ps(a: f32x8, imm8: i32) -> f32x8 {
809-
let imm8 = (imm8 & 0xFF) as u8;
810809
const fn add4(x: u32) -> u32 { x + 4 }
810+
let imm8 = (imm8 & 0xFF) as u8;
811811
macro_rules! shuffle4 {
812812
($a:expr, $b:expr, $c:expr, $d:expr) => {
813813
simd_shuffle8(a, _mm256_undefined_ps(), [
@@ -845,7 +845,7 @@ pub unsafe fn _mm256_permute_ps(a: f32x8, imm8: i32) -> f32x8 {
845845
}
846846
}
847847
}
848-
match (imm8 >> 0) & 0b11 {
848+
match imm8 & 0b11 {
849849
0b00 => shuffle1!(0),
850850
0b01 => shuffle1!(1),
851851
0b10 => shuffle1!(2),
@@ -899,7 +899,7 @@ pub unsafe fn _mm_permute_ps(a: f32x4, imm8: i32) -> f32x4 {
899899
}
900900
}
901901
}
902-
match (imm8 >> 0) & 0b11 {
902+
match imm8 & 0b11 {
903903
0b00 => shuffle1!(0),
904904
0b01 => shuffle1!(1),
905905
0b10 => shuffle1!(2),
@@ -959,7 +959,7 @@ pub unsafe fn _mm256_permute_pd(a: f64x4, imm8: i32) -> f64x4 {
959959
}
960960
}
961961
}
962-
match (imm8 >> 0) & 0x1 {
962+
match imm8 & 0x1 {
963963
0 => shuffle1!(0),
964964
_ => shuffle1!(1),
965965
}
@@ -987,7 +987,7 @@ pub unsafe fn _mm_permute_pd(a: f64x2, imm8: i32) -> f64x2 {
987987
}
988988
}
989989
}
990-
match (imm8 >> 0) & 0x1 {
990+
match imm8 & 0x1 {
991991
0 => shuffle1!(0),
992992
_ => shuffle1!(1),
993993
}

src/x86/avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub unsafe fn _mm256_adds_epu16(a: u16x16, b: u16x16) -> u16x16 {
100100
#[target_feature = "+avx2"]
101101
#[cfg_attr(test, assert_instr(vpalignr, n = 15))]
102102
pub unsafe fn _mm256_alignr_epi8(a: i8x32, b: i8x32, n: i32) -> i8x32 {
103+
const fn add(a: u32, b: u32) -> u32 { a + b }
103104
let n = n as u32;
104105
// If palignr is shifting the pair of vectors more than the size of two
105106
// lanes, emit zero.
@@ -114,7 +115,6 @@ pub unsafe fn _mm256_alignr_epi8(a: i8x32, b: i8x32, n: i32) -> i8x32 {
114115
(a, b, n)
115116
};
116117

117-
const fn add(a: u32, b: u32) -> u32 { a + b }
118118
macro_rules! shuffle {
119119
($shift:expr) => {
120120
simd_shuffle32(b, a, [

src/x86/bmi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use stdsimd_test::assert_instr;
1616
#[target_feature = "+bmi"]
1717
#[cfg_attr(test, assert_instr(bextr))]
1818
pub unsafe fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
19-
_bextr2_u32(a, (start & 0xffu32) | ((len & 0xffu32) << 8u32))
19+
_bextr2_u32(a, (start & 0xff_u32) | ((len & 0xff_u32) << 8_u32))
2020
}
2121

2222
/// Extracts bits in range [`start`, `start` + `length`) from `a` into
@@ -26,7 +26,7 @@ pub unsafe fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
2626
#[cfg_attr(test, assert_instr(bextr))]
2727
#[cfg(not(target_arch = "x86"))]
2828
pub unsafe fn _bextr_u64(a: u64, start: u64, len: u64) -> u64 {
29-
_bextr2_u64(a, (start & 0xffu64) | ((len & 0xffu64) << 8u64))
29+
_bextr2_u64(a, (start & 0xff_u64) | ((len & 0xff_u64) << 8_u64))
3030
}
3131

3232
/// Extracts bits of `a` specified by `control` into
@@ -92,7 +92,7 @@ pub unsafe fn _blsi_u64(x: u64) -> u64 {
9292
#[target_feature = "+bmi"]
9393
#[cfg_attr(test, assert_instr(blsmsk))]
9494
pub unsafe fn _blsmsk_u32(x: u32) -> u32 {
95-
x ^ (x.wrapping_sub(1u32))
95+
x ^ (x.wrapping_sub(1_u32))
9696
}
9797

9898
/// Get mask up to lowest set bit.
@@ -101,7 +101,7 @@ pub unsafe fn _blsmsk_u32(x: u32) -> u32 {
101101
#[cfg_attr(test, assert_instr(blsmsk))]
102102
#[cfg(not(target_arch = "x86"))] // generates lots of instructions
103103
pub unsafe fn _blsmsk_u64(x: u64) -> u64 {
104-
x ^ (x.wrapping_sub(1u64))
104+
x ^ (x.wrapping_sub(1_u64))
105105
}
106106

107107
/// Resets the lowest set bit of `x`.

0 commit comments

Comments
 (0)