File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -2281,15 +2281,7 @@ where
2281
2281
ast:: ExprKind :: Closure ( ..) => {
2282
2282
// If the argument consists of multiple closures, we do not overflow
2283
2283
// the last closure.
2284
- if args. len ( ) > 1
2285
- && args. iter ( )
2286
- . rev ( )
2287
- . skip ( 1 )
2288
- . filter_map ( |arg| arg. to_expr ( ) )
2289
- . any ( |expr| match expr. node {
2290
- ast:: ExprKind :: Closure ( ..) => true ,
2291
- _ => false ,
2292
- } ) {
2284
+ if args_have_many_closure ( args) {
2293
2285
None
2294
2286
} else {
2295
2287
rewrite_last_closure ( context, expr, shape)
@@ -2310,6 +2302,22 @@ where
2310
2302
}
2311
2303
}
2312
2304
2305
+ fn args_have_many_closure < T > ( args : & [ & T ] ) -> bool
2306
+ where
2307
+ T : ToExpr ,
2308
+ {
2309
+ args. iter ( )
2310
+ . filter ( |arg| {
2311
+ arg. to_expr ( )
2312
+ . map ( |e| match e. node {
2313
+ ast:: ExprKind :: Closure ( ..) => true ,
2314
+ _ => false ,
2315
+ } )
2316
+ . unwrap_or ( false )
2317
+ } )
2318
+ . count ( ) > 1
2319
+ }
2320
+
2313
2321
fn can_be_overflowed < ' a , T > ( context : & RewriteContext , args : & [ & T ] ) -> bool
2314
2322
where
2315
2323
T : Rewrite + Spanned + ToExpr + ' a ,
You can’t perform that action at this time.
0 commit comments