Skip to content

Commit 01349d5

Browse files
authored
Merge pull request #1564 from ltratt/clippy_test_fixes
Clippy fixes
2 parents f02aabc + 0db0814 commit 01349d5

File tree

7 files changed

+57
-55
lines changed

7 files changed

+57
-55
lines changed

.buildbot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ for tracer in ${TRACERS}; do
137137
echo "$WARNING_DEFINES" | xargs cargo rustc -p xtask --profile check --bin xtask --
138138

139139
# Error if Clippy detects any warnings introduced in lines changed in this PR.
140-
cargo-clippy-diff origin/master -- --all-features -- -D warnings
140+
cargo-clippy-diff origin/master -- --all-features --tests -- -D warnings
141141
done
142142

143143
# Run the tests multiple times on hwt to try and catch non-deterministic

ykrt/src/compile/jitc_yk/aot_ir.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,9 @@ mod tests {
20732073
bytes,
20742074
};
20752075

2076-
let expect_bytes = rng.rev().map(|i| format!("{:02x}", i)).collect::<String>();
2076+
let expect_bytes = rng
2077+
.rev()
2078+
.fold("".to_string(), |acc, i| format!("{acc}{i:02x}"));
20772079
let expect_usize = usize::from_str_radix(&expect_bytes, 16).unwrap();
20782080
assert_eq!(
20792081
format!("{}", cp.display(&m)),

ykrt/src/compile/jitc_yk/arbbitint.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -265,82 +265,82 @@ mod tests {
265265
assert_eq!(
266266
ArbBitInt::from_i64(8, x as i64)
267267
.wrapping_add(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
268-
i8::try_from(x.wrapping_add(y)).ok()
268+
Some(x.wrapping_add(y))
269269
);
270270
// i16
271271
assert_eq!(
272272
ArbBitInt::from_i64(8, x as i64)
273273
.wrapping_add(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
274-
i16::try_from(x.wrapping_add(y)).ok()
274+
Some(i16::from(x.wrapping_add(y)))
275275
);
276276

277277
// wrapping_sub
278278
// i8
279279
assert_eq!(
280280
ArbBitInt::from_i64(8, x as i64)
281281
.wrapping_sub(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
282-
i8::try_from(x.wrapping_sub(y)).ok()
282+
Some(x.wrapping_sub(y))
283283
);
284284
// i16
285285
assert_eq!(
286286
ArbBitInt::from_i64(8, x as i64)
287287
.wrapping_sub(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
288-
i16::try_from(x.wrapping_sub(y)).ok()
288+
Some(i16::from(x.wrapping_sub(y)))
289289
);
290290

291291
// wrapping_mul
292292
// i8
293293
assert_eq!(
294294
ArbBitInt::from_i64(8, x as i64)
295295
.wrapping_mul(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
296-
i8::try_from(x.wrapping_mul(y)).ok()
296+
Some(x.wrapping_mul(y))
297297
);
298298
// i16
299299
assert_eq!(
300300
ArbBitInt::from_i64(8, x as i64)
301301
.wrapping_mul(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
302-
i16::try_from(x.wrapping_mul(y)).ok()
302+
Some(i16::from(x.wrapping_mul(y)))
303303
);
304304

305305
// bitadd
306306
assert_eq!(
307307
ArbBitInt::from_i64(8, x as i64)
308308
.bitand(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
309-
i8::try_from(x.bitand(y)).ok()
309+
Some(x.bitand(y))
310310
);
311311
// i16
312312
assert_eq!(
313313
ArbBitInt::from_i64(8, x as i64)
314314
.bitand(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
315-
i16::try_from(x.bitand(y)).ok()
315+
Some(i16::from(x.bitand(y)))
316316
);
317317

318318
// bitor
319319
// i16
320320
assert_eq!(
321321
ArbBitInt::from_i64(8, x as i64)
322322
.bitor(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
323-
i8::try_from(x.bitor(y)).ok()
323+
Some(x.bitor(y))
324324
);
325325
// i16
326326
assert_eq!(
327327
ArbBitInt::from_i64(8, x as i64)
328328
.bitor(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
329-
i16::try_from(x.bitor(y)).ok()
329+
Some(i16::from(x.bitor(y)))
330330
);
331331

332332
// bitxor
333333
// i8
334334
assert_eq!(
335335
ArbBitInt::from_i64(8, x as i64)
336336
.bitxor(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i8(),
337-
i8::try_from(x.bitxor(y)).ok()
337+
Some(x.bitxor(y))
338338
);
339339
// i16
340340
assert_eq!(
341341
ArbBitInt::from_i64(8, x as i64)
342342
.bitxor(&ArbBitInt::from_i64(8, y as i64)).to_sign_ext_i16(),
343-
i16::try_from(x.bitxor(y)).ok()
343+
Some(i16::from(x.bitxor(y)))
344344
);
345345
}
346346

@@ -364,7 +364,7 @@ mod tests {
364364
assert_eq!(
365365
ArbBitInt::from_i64(16, x as i64)
366366
.wrapping_add(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
367-
i16::try_from(x.wrapping_add(y)).ok()
367+
Some(x.wrapping_add(y))
368368
);
369369

370370
// wrapping_sub
@@ -378,7 +378,7 @@ mod tests {
378378
assert_eq!(
379379
ArbBitInt::from_i64(16, x as i64)
380380
.wrapping_sub(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
381-
i16::try_from(x.wrapping_sub(y)).ok()
381+
Some(x.wrapping_sub(y))
382382
);
383383

384384
// wrapping_mul
@@ -392,7 +392,7 @@ mod tests {
392392
assert_eq!(
393393
ArbBitInt::from_i64(16, x as i64)
394394
.wrapping_mul(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
395-
i16::try_from(x.wrapping_mul(y)).ok()
395+
Some(x.wrapping_mul(y))
396396
);
397397

398398
// bitand
@@ -406,7 +406,7 @@ mod tests {
406406
assert_eq!(
407407
ArbBitInt::from_i64(16, x as i64)
408408
.bitand(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
409-
i16::try_from(x.bitand(y)).ok()
409+
Some(x.bitand(y))
410410
);
411411

412412
// bitor
@@ -420,7 +420,7 @@ mod tests {
420420
assert_eq!(
421421
ArbBitInt::from_i64(16, x as i64)
422422
.bitor(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
423-
i16::try_from(x.bitor(y)).ok()
423+
Some(x.bitor(y))
424424
);
425425

426426
// bitxor
@@ -434,7 +434,7 @@ mod tests {
434434
assert_eq!(
435435
ArbBitInt::from_i64(16, x as i64)
436436
.bitxor(&ArbBitInt::from_i64(16, y as i64)).to_sign_ext_i16(),
437-
i16::try_from(x.bitxor(y)).ok()
437+
Some(x.bitxor(y))
438438
);
439439
}
440440

@@ -469,7 +469,7 @@ mod tests {
469469
assert_eq!(
470470
ArbBitInt::from_i64(32, x as i64)
471471
.wrapping_add(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
472-
i32::try_from(x.wrapping_add(y)).ok()
472+
Some(x.wrapping_add(y))
473473
);
474474

475475
// wrapping_sub
@@ -489,7 +489,7 @@ mod tests {
489489
assert_eq!(
490490
ArbBitInt::from_i64(32, x as i64)
491491
.wrapping_sub(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
492-
i32::try_from(x.wrapping_sub(y)).ok()
492+
Some(x.wrapping_sub(y))
493493
);
494494

495495
// wrapping_mul
@@ -509,7 +509,7 @@ mod tests {
509509
assert_eq!(
510510
ArbBitInt::from_i64(32, x as i64)
511511
.wrapping_mul(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
512-
i32::try_from(x.wrapping_mul(y)).ok()
512+
Some(x.wrapping_mul(y))
513513
);
514514

515515
// bitand
@@ -529,7 +529,7 @@ mod tests {
529529
assert_eq!(
530530
ArbBitInt::from_i64(32, x as i64)
531531
.bitand(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
532-
i32::try_from(x.bitand(y)).ok()
532+
Some(x.bitand(y))
533533
);
534534

535535
// bitor
@@ -549,7 +549,7 @@ mod tests {
549549
assert_eq!(
550550
ArbBitInt::from_i64(32, x as i64)
551551
.bitor(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
552-
i32::try_from(x.bitor(y)).ok()
552+
Some(x.bitor(y))
553553
);
554554

555555
// bitxor
@@ -569,7 +569,7 @@ mod tests {
569569
assert_eq!(
570570
ArbBitInt::from_i64(32, x as i64)
571571
.bitxor(&ArbBitInt::from_i64(32, y as i64)).to_sign_ext_i32(),
572-
i32::try_from(x.bitxor(y)).ok()
572+
Some(x.bitxor(y))
573573
);
574574
}
575575

@@ -615,7 +615,7 @@ mod tests {
615615
assert_eq!(
616616
ArbBitInt::from_i64(64, x)
617617
.wrapping_add(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
618-
i64::try_from(x.wrapping_add(y)).ok()
618+
Some(x.wrapping_add(y))
619619
);
620620

621621
// wrapping_sub
@@ -641,7 +641,7 @@ mod tests {
641641
assert_eq!(
642642
ArbBitInt::from_i64(64, x)
643643
.wrapping_sub(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
644-
i64::try_from(x.wrapping_sub(y)).ok()
644+
Some(x.wrapping_sub(y))
645645
);
646646

647647
// wrapping_mul
@@ -667,7 +667,7 @@ mod tests {
667667
assert_eq!(
668668
ArbBitInt::from_i64(64, x)
669669
.wrapping_mul(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
670-
i64::try_from(x.wrapping_mul(y)).ok()
670+
Some(x.wrapping_mul(y))
671671
);
672672

673673
// bitand
@@ -693,7 +693,7 @@ mod tests {
693693
assert_eq!(
694694
ArbBitInt::from_i64(64, x)
695695
.bitand(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
696-
i64::try_from(x.bitand(y)).ok()
696+
Some(x.bitand(y))
697697
);
698698

699699
// bitor
@@ -719,7 +719,7 @@ mod tests {
719719
assert_eq!(
720720
ArbBitInt::from_i64(64, x)
721721
.bitor(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
722-
i64::try_from(x.bitor(y)).ok()
722+
Some(x.bitor(y))
723723
);
724724

725725
// bitxor
@@ -745,7 +745,7 @@ mod tests {
745745
assert_eq!(
746746
ArbBitInt::from_i64(64, x)
747747
.bitxor(&ArbBitInt::from_i64(64, y)).to_sign_ext_i64(),
748-
i64::try_from(x.bitxor(y)).ok()
748+
Some(x.bitxor(y))
749749
);
750750
}
751751

@@ -756,7 +756,7 @@ mod tests {
756756
// "failure cases only".
757757
assert_eq!(
758758
ArbBitInt::from_u64(8, x as u64).checked_shl(y).map(|x| x.to_zero_ext_u8()),
759-
x.checked_shl(y).map(|x| u8::try_from(x).ok())
759+
x.checked_shl(y).map(Some)
760760
);
761761
}
762762

@@ -767,7 +767,7 @@ mod tests {
767767
// "failure cases only".
768768
assert_eq!(
769769
ArbBitInt::from_u64(16, x as u64).checked_shl(y).map(|x| x.to_zero_ext_u16()),
770-
x.checked_shl(y).map(|x| u16::try_from(x).ok())
770+
x.checked_shl(y).map(Some)
771771
);
772772
}
773773

@@ -778,7 +778,7 @@ mod tests {
778778
// "failure cases only".
779779
assert_eq!(
780780
ArbBitInt::from_u64(32, x as u64).checked_shl(y).map(|x| x.to_zero_ext_u32()),
781-
x.checked_shl(y).map(|x| u32::try_from(x).ok())
781+
x.checked_shl(y).map(Some)
782782
);
783783
}
784784

@@ -789,7 +789,7 @@ mod tests {
789789
// "failure cases only".
790790
assert_eq!(
791791
ArbBitInt::from_u64(64, x).checked_shl(y).map(|x| x.to_zero_ext_u64()),
792-
x.checked_shl(y).map(|x| u64::try_from(x).ok())
792+
x.checked_shl(y).map(Some)
793793
);
794794
}
795795

@@ -800,7 +800,7 @@ mod tests {
800800
// "failure cases only".
801801
assert_eq!(
802802
ArbBitInt::from_u64(8, x as u64).checked_shr(y).map(|x| x.to_zero_ext_u8()),
803-
x.checked_shr(y).map(|x| u8::try_from(x).ok())
803+
x.checked_shr(y).map(Some)
804804
);
805805
}
806806

@@ -811,7 +811,7 @@ mod tests {
811811
// "failure cases only".
812812
assert_eq!(
813813
ArbBitInt::from_u64(16, x as u64).checked_shr(y).map(|x| x.to_zero_ext_u16()),
814-
x.checked_shr(y).map(|x| u16::try_from(x).ok())
814+
x.checked_shr(y).map(Some)
815815
);
816816
}
817817

@@ -822,7 +822,7 @@ mod tests {
822822
// "failure cases only".
823823
assert_eq!(
824824
ArbBitInt::from_u64(32, x as u64).checked_shr(y).map(|x| x.to_zero_ext_u32()),
825-
x.checked_shr(y).map(|x| u32::try_from(x).ok())
825+
x.checked_shr(y).map(Some)
826826
);
827827
}
828828

@@ -833,7 +833,7 @@ mod tests {
833833
// "failure cases only".
834834
assert_eq!(
835835
ArbBitInt::from_u64(64, x).checked_shr(y).map(|x| x.to_zero_ext_u64()),
836-
x.checked_shr(y).map(|x| u64::try_from(x).ok())
836+
x.checked_shr(y).map(Some)
837837
);
838838
}
839839
}

ykrt/src/compile/jitc_yk/codegen/x64/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,7 @@ mod tests {
28032803
let mut map = HashMap::new();
28042804
for (i, regs) in X64_RAW_REGS_MAP.iter().enumerate() {
28052805
for r in regs.iter() {
2806-
if *r != "" {
2806+
if !r.is_empty() {
28072807
map.insert(*r, i);
28082808
}
28092809
}
@@ -2833,7 +2833,7 @@ mod tests {
28332833
};
28342834
}
28352835

2836-
fn fmatcher<'a>(ptn: &'a str) -> FMatcher<'a> {
2836+
fn fmatcher(ptn: &str) -> FMatcher<'_> {
28372837
let mut fmb = FMBuilder::new(ptn)
28382838
.unwrap()
28392839
.name_matching_validator(|names| {
@@ -4714,11 +4714,11 @@ mod tests {
47144714
m.push_param(loc.clone());
47154715
let pinst1: Inst =
47164716
jit_ir::ParamInst::new(ParamIdx::try_from(0).unwrap(), m.int8_tyidx()).into();
4717-
m.push(pinst1.clone()).unwrap();
4717+
m.push(pinst1).unwrap();
47184718
m.push_param(loc);
47194719
let pinst2: Inst =
47204720
jit_ir::ParamInst::new(ParamIdx::try_from(1).unwrap(), m.int8_tyidx()).into();
4721-
m.push(pinst2.clone()).unwrap();
4721+
m.push(pinst2).unwrap();
47224722
let op1 = m.push_and_make_operand(pinst1).unwrap();
47234723
let op2 = m.push_and_make_operand(pinst2).unwrap();
47244724

0 commit comments

Comments
 (0)