Skip to content

Commit 6de463c

Browse files
committed
make a big let-chain
1 parent 5ec13c9 commit 6de463c

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

clippy_lints/src/len_zero.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -336,26 +336,16 @@ fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&
336336
}
337337

338338
fn is_first_generic_integral<'tcx>(segment: &'tcx PathSegment<'tcx>) -> bool {
339-
if let Some(generic_args) = segment.args {
340-
if generic_args.args.is_empty() {
341-
return false;
342-
}
343-
let arg = &generic_args.args[0];
344-
if let GenericArg::Type(rustc_hir::Ty {
345-
kind: TyKind::Path(QPath::Resolved(_, path)),
346-
..
347-
}) = arg
348-
{
349-
let segments = &path.segments;
350-
let segment = &segments[0];
351-
let res = &segment.res;
352-
if matches!(res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_))) {
353-
return true;
354-
}
355-
}
339+
if let Some(generic_args) = segment.args
340+
&& let [GenericArg::Type(ty), ..] = &generic_args.args
341+
&& let TyKind::Path(QPath::Resolved(_, path)) = ty.kind
342+
&& let [segment, ..] = &path.segments
343+
&& matches!(segment.res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_)))
344+
{
345+
true
346+
} else {
347+
false
356348
}
357-
358-
false
359349
}
360350

361351
fn parse_len_output<'tcx>(cx: &LateContext<'tcx>, sig: FnSig<'tcx>) -> Option<LenOutput> {

0 commit comments

Comments
 (0)