Skip to content

Commit b8574f7

Browse files
committed
Couple of clippy fixes
1 parent 3ac863c commit b8574f7

6 files changed

Lines changed: 30 additions & 44 deletions

File tree

src/abi/mod.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,22 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
322322
// not mutated by the current function, this is necessary to support unsized arguments.
323323
if let ArgKind::Normal(Some(ArgValue { value: val, is_underaligned_pointee: false })) =
324324
arg_kind
325+
&& let Some((addr, meta)) = val.try_to_ptr()
325326
{
326-
if let Some((addr, meta)) = val.try_to_ptr() {
327-
// Ownership of the value at the backing storage for an argument is passed to the
328-
// callee per the ABI, so it is fine to borrow the backing storage of this argument
329-
// to prevent a copy.
327+
// Ownership of the value at the backing storage for an argument is passed to the
328+
// callee per the ABI, so it is fine to borrow the backing storage of this argument
329+
// to prevent a copy.
330330

331-
let place = if let Some(meta) = meta {
332-
CPlace::for_ptr_with_extra(addr, meta, val.layout())
333-
} else {
334-
CPlace::for_ptr(addr, val.layout())
335-
};
331+
let place = if let Some(meta) = meta {
332+
CPlace::for_ptr_with_extra(addr, meta, val.layout())
333+
} else {
334+
CPlace::for_ptr(addr, val.layout())
335+
};
336336

337-
self::comments::add_local_place_comments(fx, place, local);
337+
self::comments::add_local_place_comments(fx, place, local);
338338

339-
assert_eq!(fx.local_map.push(place), local);
340-
continue;
341-
}
339+
assert_eq!(fx.local_map.push(place), local);
340+
continue;
342341
}
343342

344343
let layout = fx.layout_of(ty);

src/analyze.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> {
2323

2424
for bb in fx.mir.basic_blocks.iter() {
2525
for stmt in bb.statements.iter() {
26-
match &stmt.kind {
27-
Assign(place_and_rval) => match &place_and_rval.1 {
28-
Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => {
29-
flag_map[place.local] = SsaKind::NotSsa;
30-
}
31-
_ => {}
32-
},
33-
_ => {}
26+
if let Assign(place_and_rval) = &stmt.kind
27+
&& let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = &place_and_rval.1
28+
{
29+
flag_map[place.local] = SsaKind::NotSsa;
3430
}
3531
}
3632
}

src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ pub(crate) fn codegen_operand<'tcx>(
10471047
Operand::RuntimeChecks(checks) => {
10481048
let val = checks.value(fx.tcx.sess);
10491049
let layout = fx.layout_of(fx.tcx.types.bool);
1050-
return CValue::const_val(fx, layout, val.into());
1050+
CValue::const_val(fx, layout, val.into())
10511051
}
10521052
}
10531053
}

src/inline_asm.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,10 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
424424

425425
// Allocate stack slots for inout
426426
for (i, operand) in self.operands.iter().enumerate() {
427-
match *operand {
428-
CInlineAsmOperand::InOut { reg, out_place: Some(_), .. } => {
429-
let slot = new_slot(reg.reg_class());
430-
slots_input[i] = Some(slot);
431-
slots_output[i] = Some(slot);
432-
}
433-
_ => (),
427+
if let CInlineAsmOperand::InOut { reg, out_place: Some(_), .. } = *operand {
428+
let slot = new_slot(reg.reg_class());
429+
slots_input[i] = Some(slot);
430+
slots_output[i] = Some(slot);
434431
}
435432
}
436433

@@ -456,11 +453,8 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
456453

457454
// Allocate stack slots for output
458455
for (i, operand) in self.operands.iter().enumerate() {
459-
match *operand {
460-
CInlineAsmOperand::Out { reg, place: Some(_), .. } => {
461-
slots_output[i] = Some(new_slot(reg.reg_class()));
462-
}
463-
_ => (),
456+
if let CInlineAsmOperand::Out { reg, place: Some(_), .. } = *operand {
457+
slots_output[i] = Some(new_slot(reg.reg_class()));
464458
}
465459
}
466460

src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
371371
}
372372

373373
for i in 0..lane_count {
374-
let ret_lane = ret.place_lane(fx, i.into());
374+
let ret_lane = ret.place_lane(fx, i);
375375
ret_lane.write_cvalue(fx, value);
376376
}
377377
}

src/value_and_place.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,17 +686,14 @@ impl<'tcx> CPlace<'tcx> {
686686
) -> CPlace<'tcx> {
687687
let layout = self.layout();
688688

689-
match self.inner {
690-
CPlaceInner::VarPair(local, var1, var2) => {
691-
let layout = layout.field(&*fx, field.index());
689+
if let CPlaceInner::VarPair(local, var1, var2) = self.inner {
690+
let layout = layout.field(&*fx, field.index());
692691

693-
match field.as_u32() {
694-
0 => return CPlace { inner: CPlaceInner::Var(local, var1), layout },
695-
1 => return CPlace { inner: CPlaceInner::Var(local, var2), layout },
696-
_ => unreachable!("field should be 0 or 1"),
697-
}
692+
match field.as_u32() {
693+
0 => return CPlace { inner: CPlaceInner::Var(local, var1), layout },
694+
1 => return CPlace { inner: CPlaceInner::Var(local, var2), layout },
695+
_ => unreachable!("field should be 0 or 1"),
698696
}
699-
_ => {}
700697
}
701698

702699
let (base, extra) = match self.inner {

0 commit comments

Comments
 (0)