Skip to content

Commit de6d3fc

Browse files
authored
Fix some clippy lints (#937)
1 parent 818fd4a commit de6d3fc

File tree

22 files changed

+80
-88
lines changed

22 files changed

+80
-88
lines changed

crates/assert-instr-macro/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
.ok()
77
.and_then(|s| s.parse().ok())
88
.unwrap_or(0);
9-
let profile = env::var("PROFILE").unwrap_or(String::new());
9+
let profile = env::var("PROFILE").unwrap_or_default();
1010
if profile == "release" || opt_level >= 2 {
1111
println!("cargo:rustc-cfg=optimized");
1212
}

crates/assert-instr-macro/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl syn::parse::Parse for Invoc {
179179
continue;
180180
}
181181
if input.parse::<Token![.]>().is_ok() {
182-
instr.push_str(".");
182+
instr.push('.');
183183
continue;
184184
}
185185
if let Ok(s) = input.parse::<syn::LitStr>() {

crates/core_arch/src/x86/avx2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4052,7 +4052,7 @@ extern "C" {
40524052

40534053
#[cfg(test)]
40544054
mod tests {
4055-
use std;
4055+
40564056
use stdarch_test::simd_test;
40574057

40584058
use crate::core_arch::x86::*;

crates/core_arch/src/x86/avx512f.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22727,7 +22727,7 @@ extern "C" {
2272722727

2272822728
#[cfg(test)]
2272922729
mod tests {
22730-
use std;
22730+
2273122731
use stdarch_test::simd_test;
2273222732

2273322733
use crate::core_arch::x86::*;

crates/core_arch/src/x86/avx512ifma.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extern "C" {
105105

106106
#[cfg(test)]
107107
mod tests {
108-
use std;
108+
109109
use stdarch_test::simd_test;
110110

111111
use crate::core_arch::x86::*;

crates/core_arch/src/x86/fma.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ extern "C" {
500500

501501
#[cfg(test)]
502502
mod tests {
503-
use std;
503+
504504
use stdarch_test::simd_test;
505505

506506
use crate::core_arch::x86::*;

crates/core_arch/src/x86/fxsr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use stdarch_test::assert_instr;
66
#[allow(improper_ctypes)]
77
extern "C" {
88
#[link_name = "llvm.x86.fxsave"]
9-
fn fxsave(p: *mut u8) -> ();
9+
fn fxsave(p: *mut u8);
1010
#[link_name = "llvm.x86.fxrstor"]
11-
fn fxrstor(p: *const u8) -> ();
11+
fn fxrstor(p: *const u8);
1212
}
1313

1414
/// Saves the `x87` FPU, `MMX` technology, `XMM`, and `MXCSR` registers to the

crates/core_arch/src/x86/rtm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ extern "C" {
2020
#[link_name = "llvm.x86.xbegin"]
2121
fn x86_xbegin() -> i32;
2222
#[link_name = "llvm.x86.xend"]
23-
fn x86_xend() -> ();
23+
fn x86_xend();
2424
#[link_name = "llvm.x86.xabort"]
25-
fn x86_xabort(imm8: i8) -> ();
25+
fn x86_xabort(imm8: i8);
2626
#[link_name = "llvm.x86.xtest"]
2727
fn x86_xtest() -> i32;
2828
}

crates/core_arch/src/x86/sse.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3106,8 +3106,8 @@ mod tests {
31063106
let mut p = vals.as_mut_ptr();
31073107

31083108
if (p as usize) & 0xf != 0 {
3109-
ofs = (16 - (p as usize) & 0xf) >> 2;
3110-
p = p.offset(ofs as isize);
3109+
ofs = ((16 - (p as usize)) & 0xf) >> 2;
3110+
p = p.add(ofs);
31113111
}
31123112

31133113
_mm_store1_ps(p, *black_box(&a));
@@ -3132,8 +3132,8 @@ mod tests {
31323132

31333133
// Align p to 16-byte boundary
31343134
if (p as usize) & 0xf != 0 {
3135-
ofs = (16 - (p as usize) & 0xf) >> 2;
3136-
p = p.offset(ofs as isize);
3135+
ofs = ((16 - (p as usize)) & 0xf) >> 2;
3136+
p = p.add(ofs);
31373137
}
31383138

31393139
_mm_store_ps(p, *black_box(&a));
@@ -3158,8 +3158,8 @@ mod tests {
31583158

31593159
// Align p to 16-byte boundary
31603160
if (p as usize) & 0xf != 0 {
3161-
ofs = (16 - (p as usize) & 0xf) >> 2;
3162-
p = p.offset(ofs as isize);
3161+
ofs = ((16 - (p as usize)) & 0xf) >> 2;
3162+
p = p.add(ofs);
31633163
}
31643164

31653165
_mm_storer_ps(p, *black_box(&a));

crates/core_arch/src/x86/xsave.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ use stdarch_test::assert_instr;
77
#[allow(improper_ctypes)]
88
extern "C" {
99
#[link_name = "llvm.x86.xsave"]
10-
fn xsave(p: *mut u8, hi: u32, lo: u32) -> ();
10+
fn xsave(p: *mut u8, hi: u32, lo: u32);
1111
#[link_name = "llvm.x86.xrstor"]
12-
fn xrstor(p: *const u8, hi: u32, lo: u32) -> ();
12+
fn xrstor(p: *const u8, hi: u32, lo: u32);
1313
#[link_name = "llvm.x86.xsetbv"]
14-
fn xsetbv(v: u32, hi: u32, lo: u32) -> ();
14+
fn xsetbv(v: u32, hi: u32, lo: u32);
1515
#[link_name = "llvm.x86.xsaveopt"]
16-
fn xsaveopt(p: *mut u8, hi: u32, lo: u32) -> ();
16+
fn xsaveopt(p: *mut u8, hi: u32, lo: u32);
1717
#[link_name = "llvm.x86.xsavec"]
18-
fn xsavec(p: *mut u8, hi: u32, lo: u32) -> ();
18+
fn xsavec(p: *mut u8, hi: u32, lo: u32);
1919
#[link_name = "llvm.x86.xsaves"]
20-
fn xsaves(p: *mut u8, hi: u32, lo: u32) -> ();
20+
fn xsaves(p: *mut u8, hi: u32, lo: u32);
2121
#[link_name = "llvm.x86.xrstors"]
22-
fn xrstors(p: *const u8, hi: u32, lo: u32) -> ();
22+
fn xrstors(p: *const u8, hi: u32, lo: u32);
2323
}
2424

2525
/// Performs a full or partial save of the enabled processor states to memory at

crates/core_arch/src/x86_64/avx512f.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//use crate::{
2+
//
23
// core_arch::{simd::*, simd_llvm::*, x86::*},
34
// mem::transmute,
45
//};
56

67
#[cfg(test)]
78
mod tests {
8-
use std;
9+
910
use stdarch_test::simd_test;
1011

1112
use crate::core_arch::x86::*;
@@ -2123,7 +2124,7 @@ mod tests {
21232124
let e = _mm512_set1_pd(0.3333333333333333);
21242125
assert_eq_m512d(r, e);
21252126
let r = _mm512_div_round_pd(a, b, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
2126-
let e = _mm512_set1_pd(0.33333333333333334);
2127+
let e = _mm512_set1_pd(0.3333333333333333);
21272128
assert_eq_m512d(r, e);
21282129
}
21292130

crates/core_arch/src/x86_64/fxsr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use stdarch_test::assert_instr;
66
#[allow(improper_ctypes)]
77
extern "C" {
88
#[link_name = "llvm.x86.fxsave64"]
9-
fn fxsave64(p: *mut u8) -> ();
9+
fn fxsave64(p: *mut u8);
1010
#[link_name = "llvm.x86.fxrstor64"]
11-
fn fxrstor64(p: *const u8) -> ();
11+
fn fxrstor64(p: *const u8);
1212
}
1313

1414
/// Saves the `x87` FPU, `MMX` technology, `XMM`, and `MXCSR` registers to the

crates/core_arch/src/x86_64/xsave.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use stdarch_test::assert_instr;
88
#[allow(improper_ctypes)]
99
extern "C" {
1010
#[link_name = "llvm.x86.xsave64"]
11-
fn xsave64(p: *mut u8, hi: u32, lo: u32) -> ();
11+
fn xsave64(p: *mut u8, hi: u32, lo: u32);
1212
#[link_name = "llvm.x86.xrstor64"]
13-
fn xrstor64(p: *const u8, hi: u32, lo: u32) -> ();
13+
fn xrstor64(p: *const u8, hi: u32, lo: u32);
1414
#[link_name = "llvm.x86.xsaveopt64"]
15-
fn xsaveopt64(p: *mut u8, hi: u32, lo: u32) -> ();
15+
fn xsaveopt64(p: *mut u8, hi: u32, lo: u32);
1616
#[link_name = "llvm.x86.xsavec64"]
17-
fn xsavec64(p: *mut u8, hi: u32, lo: u32) -> ();
17+
fn xsavec64(p: *mut u8, hi: u32, lo: u32);
1818
#[link_name = "llvm.x86.xsaves64"]
19-
fn xsaves64(p: *mut u8, hi: u32, lo: u32) -> ();
19+
fn xsaves64(p: *mut u8, hi: u32, lo: u32);
2020
#[link_name = "llvm.x86.xrstors64"]
21-
fn xrstors64(p: *const u8, hi: u32, lo: u32) -> ();
21+
fn xrstors64(p: *const u8, hi: u32, lo: u32);
2222
}
2323

2424
/// Performs a full or partial save of the enabled processor states to memory at

crates/core_arch/tests/cpu-detection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(stdsimd)]
2-
#![allow(clippy::option_unwrap_used, clippy::print_stdout, clippy::use_debug)]
2+
#![allow(clippy::unwrap_used, clippy::print_stdout, clippy::use_debug)]
33

44
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
55
#[macro_use]

crates/std_detect/tests/cpu-detection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(stdsimd)]
2-
#![allow(clippy::option_unwrap_used, clippy::use_debug, clippy::print_stdout)]
2+
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]
33
#![cfg(any(
44
target_arch = "arm",
55
target_arch = "aarch64",

crates/std_detect/tests/macro_trailing_commas.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(stdsimd)]
2-
#![allow(clippy::option_unwrap_used, clippy::use_debug, clippy::print_stdout)]
2+
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]
33

44
#[cfg(any(
55
target_arch = "arm",

crates/stdarch-gen/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub unsafe fn {}(a: {}, b: {}) -> {} {{
476476
}
477477

478478
fn expand_intrinsic(intr: &str, t: &str) -> String {
479-
if intr.ends_with(".") {
479+
if intr.ends_with('.') {
480480
let ext = match t {
481481
"int8x8_t" => "i8",
482482
"int8x16_t" => "i8",

crates/stdarch-verify/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
336336
} else if let Ok(ident) = instrs.call(syn::Ident::parse_any) {
337337
instr.push_str(&ident.to_string());
338338
} else if instrs.parse::<Token![.]>().is_ok() {
339-
instr.push_str(".");
339+
instr.push('.');
340340
} else if instrs.parse::<Token![,]>().is_ok() {
341341
// consume everything remaining
342342
drop(instrs.parse::<proc_macro2::TokenStream>());

crates/stdarch-verify/tests/arm.rs

+19-22
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn matches(rust: &Function, arm: &Intrinsic) -> Result<(), String> {
468468
}
469469
// sometimes arm says `foo` and disassemblers say `vfoo`, or
470470
// sometimes disassemblers say `vfoo` and arm says `sfoo` or `ffoo`
471-
if instr.starts_with("v")
471+
if instr.starts_with('v')
472472
&& (arm.instruction.starts_with(&instr[1..])
473473
|| arm.instruction[1..].starts_with(&instr[1..]))
474474
{
@@ -491,10 +491,10 @@ fn matches(rust: &Function, arm: &Intrinsic) -> Result<(), String> {
491491
fn find_accordion(node: &Rc<Node>) -> Option<Rc<Node>> {
492492
if let NodeData::Element { attrs, .. } = &node.data {
493493
for attr in attrs.borrow().iter() {
494-
if attr.name.local.eq_str_ignore_ascii_case("class") {
495-
if attr.value.to_string() == "intrinsic-accordion" {
496-
return Some(node.clone());
497-
}
494+
if attr.name.local.eq_str_ignore_ascii_case("class")
495+
&& attr.value.to_string() == "intrinsic-accordion"
496+
{
497+
return Some(node.clone());
498498
}
499499
}
500500
}
@@ -522,7 +522,7 @@ fn parse_intrinsics(node: &Rc<Node>) -> HashMap<String, Intrinsic> {
522522
ret.insert(f.name.clone(), f);
523523
}
524524
}
525-
return ret;
525+
ret
526526
}
527527

528528
fn parse_intrinsic(node: &Rc<Node>) -> Intrinsic {
@@ -535,10 +535,9 @@ fn parse_intrinsic(node: &Rc<Node>) -> Intrinsic {
535535
// ...
536536

537537
let children = node.children.borrow();
538-
let mut children = children.iter().filter(|node| match node.data {
539-
NodeData::Element { .. } => true,
540-
_ => false,
541-
});
538+
let mut children = children
539+
.iter()
540+
.filter(|node| matches!(node.data, NodeData::Element { .. }));
542541
let _input = children.next().expect("no <input>");
543542
let label = children.next().expect("no <label>");
544543
let article = children.next().expect("no <article>");
@@ -558,10 +557,9 @@ fn parse_intrinsic(node: &Rc<Node>) -> Intrinsic {
558557

559558
// Find contents of inner `<div>` in `<label>`
560559
let label_children = label.children.borrow();
561-
let mut label_children = label_children.iter().filter(|node| match node.data {
562-
NodeData::Element { .. } => true,
563-
_ => false,
564-
});
560+
let mut label_children = label_children
561+
.iter()
562+
.filter(|node| matches!(node.data, NodeData::Element { .. }));
565563
let label_div = label_children.next().expect("no <div> in <label>");
566564
assert!(label_children.next().is_none());
567565
let text = label_div.children.borrow();
@@ -577,10 +575,9 @@ fn parse_intrinsic(node: &Rc<Node>) -> Intrinsic {
577575

578576
// Find the instruction within the article
579577
let article_children = article.children.borrow();
580-
let mut article_children = article_children.iter().filter(|node| match node.data {
581-
NodeData::Element { .. } => true,
582-
_ => false,
583-
});
578+
let mut article_children = article_children
579+
.iter()
580+
.filter(|node| matches!(node.data, NodeData::Element { .. }));
584581
let mut instruction = None;
585582
while let Some(child) = article_children.next() {
586583
let mut header = String::new();
@@ -609,9 +606,9 @@ fn parse_intrinsic(node: &Rc<Node>) -> Intrinsic {
609606
},
610607
instruction,
611608
arguments: args // "(...)"
612-
.trim_start_matches("(") // "...)"
613-
.trim_end_matches(")") // "..."
614-
.split(",") // " Type name ", ".."
609+
.trim_start_matches('(') // "...)"
610+
.trim_end_matches(')') // "..."
611+
.split(',') // " Type name ", ".."
615612
.map(|s| s.trim()) // "Type name"
616613
.map(|s| s.rsplitn(2, ' ').nth(1).unwrap()) // "Type"
617614
.map(|s| {
@@ -775,7 +772,7 @@ fn parse_ty_base(s: &str) -> &'static Type {
775772

776773
fn collect_text(s: &mut String, node: &Node) {
777774
if let NodeData::Text { contents } = &node.data {
778-
s.push_str(" ");
775+
s.push(' ');
779776
s.push_str(&contents.borrow().to_string());
780777
}
781778
for child in node.children.borrow().iter() {

crates/stdarch-verify/tests/mips.rs

+17-20
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ fn verify_all_signatures() {
193193
}
194194

195195
use std::convert::TryFrom;
196-
let intrinsic: MsaIntrinsic =
197-
TryFrom::try_from(line).expect(&format!("failed to parse line: \"{}\"", line));
196+
let intrinsic: MsaIntrinsic = TryFrom::try_from(line)
197+
.unwrap_or_else(|_| panic!("failed to parse line: \"{}\"", line));
198198
assert!(!intrinsics.contains_key(&intrinsic.id));
199199
intrinsics.insert(intrinsic.id.clone(), intrinsic);
200200
}
@@ -293,10 +293,7 @@ fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> {
293293
| MsaTy::imm_n1024_1022
294294
| MsaTy::imm_n2048_2044
295295
| MsaTy::imm_n4096_4088
296-
if **rust_arg == I32 =>
297-
{
298-
()
299-
}
296+
if **rust_arg == I32 => {}
300297
MsaTy::i32 if **rust_arg == I32 => (),
301298
MsaTy::i64 if **rust_arg == I64 => (),
302299
MsaTy::u32 if **rust_arg == U32 => (),
@@ -310,21 +307,21 @@ fn matches(rust: &Function, mips: &MsaIntrinsic) -> Result<(), String> {
310307
),
311308
}
312309

313-
let is_const = match mips_arg {
310+
let is_const = matches!(
311+
mips_arg,
314312
MsaTy::imm0_1
315-
| MsaTy::imm0_3
316-
| MsaTy::imm0_7
317-
| MsaTy::imm0_15
318-
| MsaTy::imm0_31
319-
| MsaTy::imm0_63
320-
| MsaTy::imm0_255
321-
| MsaTy::imm_n16_15
322-
| MsaTy::imm_n512_511
323-
| MsaTy::imm_n1024_1022
324-
| MsaTy::imm_n2048_2044
325-
| MsaTy::imm_n4096_4088 => true,
326-
_ => false,
327-
};
313+
| MsaTy::imm0_3
314+
| MsaTy::imm0_7
315+
| MsaTy::imm0_15
316+
| MsaTy::imm0_31
317+
| MsaTy::imm0_63
318+
| MsaTy::imm0_255
319+
| MsaTy::imm_n16_15
320+
| MsaTy::imm_n512_511
321+
| MsaTy::imm_n1024_1022
322+
| MsaTy::imm_n2048_2044
323+
| MsaTy::imm_n4096_4088
324+
);
328325
if is_const {
329326
nconst += 1;
330327
if !rust.required_const.contains(&i) {

0 commit comments

Comments
 (0)