@@ -176,12 +176,11 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
176
176
if let ExprKind :: Let ( lt) = expr. kind
177
177
&& match lt. pat . kind {
178
178
PatKind :: Slice ( [ ] , None , [ ] ) => true ,
179
- PatKind :: Expr ( lit) => match lit. kind {
180
- PatExprKind :: Lit { lit, .. } => match lit. node {
181
- LitKind :: Str ( lit, _) => lit. as_str ( ) . is_empty ( ) ,
182
- _ => false ,
183
- } ,
184
- _ => false ,
179
+ PatKind :: Expr ( lit)
180
+ if let PatExprKind :: Lit { lit, .. } = lit. kind
181
+ && let LitKind :: Str ( lit, _) = lit. node =>
182
+ {
183
+ lit. as_str ( ) . is_empty ( )
185
184
} ,
186
185
_ => false ,
187
186
}
@@ -336,33 +335,23 @@ fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&
336
335
}
337
336
338
337
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 ( _) ) ) || matches ! ( res, Res :: PrimTy ( PrimTy :: Int ( _) ) ) {
353
- return true ;
354
- }
355
- }
338
+ if let Some ( generic_args) = segment. args
339
+ && let [ GenericArg :: Type ( ty) , ..] = & generic_args. args
340
+ && let TyKind :: Path ( QPath :: Resolved ( _, path) ) = ty. kind
341
+ && let [ segment, ..] = & path. segments
342
+ && matches ! ( segment. res, Res :: PrimTy ( PrimTy :: Uint ( _) | PrimTy :: Int ( _) ) )
343
+ {
344
+ true
345
+ } else {
346
+ false
356
347
}
357
-
358
- false
359
348
}
360
349
361
350
fn parse_len_output < ' tcx > ( cx : & LateContext < ' tcx > , sig : FnSig < ' tcx > ) -> Option < LenOutput > {
362
351
if let Some ( segment) = extract_future_output ( cx, sig. output ( ) ) {
363
352
let res = segment. res ;
364
353
365
- if matches ! ( res, Res :: PrimTy ( PrimTy :: Uint ( _) ) ) || matches ! ( res , Res :: PrimTy ( PrimTy :: Int ( _) ) ) {
354
+ if matches ! ( res, Res :: PrimTy ( PrimTy :: Uint ( _) | PrimTy :: Int ( _) ) ) {
366
355
return Some ( LenOutput :: Integral ) ;
367
356
}
368
357
0 commit comments