@@ -1281,46 +1281,37 @@ fn lint_or_fun_call<'a, 'tcx>(
1281
1281
( & paths:: RESULT , true , & [ "or" , "unwrap_or" ] , "else" ) ,
1282
1282
] ;
1283
1283
1284
- // early check if the name is one we care about
1285
- if know_types. iter ( ) . all ( |k| !k. 2 . contains ( & name) ) {
1286
- return ;
1287
- }
1284
+ if_chain ! {
1285
+ if know_types. iter( ) . any( |k| k. 2 . contains( & name) ) ;
1288
1286
1289
- let mut finder = FunCallFinder { cx : & cx, found : false } ;
1290
- finder. visit_expr ( & arg) ;
1291
- if !finder. found {
1292
- return ;
1293
- }
1287
+ let mut finder = FunCallFinder { cx: & cx, found: false } ;
1288
+ if { finder. visit_expr( & arg) ; finder. found } ;
1294
1289
1295
- let self_ty = cx. tables . expr_ty ( self_expr) ;
1290
+ let self_ty = cx. tables. expr_ty( self_expr) ;
1296
1291
1297
- let ( fn_has_arguments, poss, suffix) = if let Some ( & ( _, fn_has_arguments, poss, suffix) ) =
1298
- know_types. iter ( ) . find ( |& & i| match_type ( cx, self_ty, i. 0 ) )
1299
- {
1300
- ( fn_has_arguments, poss, suffix)
1301
- } else {
1302
- return ;
1303
- } ;
1292
+ if let Some ( & ( _, fn_has_arguments, poss, suffix) ) =
1293
+ know_types. iter( ) . find( |&&i| match_type( cx, self_ty, i. 0 ) ) ;
1304
1294
1305
- if !poss. contains ( & name) {
1306
- return ;
1307
- }
1295
+ if poss. contains( & name) ;
1308
1296
1309
- let sugg: Cow < ' _ , _ > = match ( fn_has_arguments, !or_has_args) {
1310
- ( true , _) => format ! ( "|_| {}" , snippet_with_macro_callsite( cx, arg. span, ".." ) ) . into ( ) ,
1311
- ( false , false ) => format ! ( "|| {}" , snippet_with_macro_callsite( cx, arg. span, ".." ) ) . into ( ) ,
1312
- ( false , true ) => snippet_with_macro_callsite ( cx, fun_span, ".." ) ,
1313
- } ;
1314
- let span_replace_word = method_span. with_hi ( span. hi ( ) ) ;
1315
- span_lint_and_sugg (
1316
- cx,
1317
- OR_FUN_CALL ,
1318
- span_replace_word,
1319
- & format ! ( "use of `{}` followed by a function call" , name) ,
1320
- "try this" ,
1321
- format ! ( "{}_{}({})" , name, suffix, sugg) ,
1322
- Applicability :: HasPlaceholders ,
1323
- ) ;
1297
+ then {
1298
+ let sugg: Cow <' _, _> = match ( fn_has_arguments, !or_has_args) {
1299
+ ( true , _) => format!( "|_| {}" , snippet_with_macro_callsite( cx, arg. span, ".." ) ) . into( ) ,
1300
+ ( false , false ) => format!( "|| {}" , snippet_with_macro_callsite( cx, arg. span, ".." ) ) . into( ) ,
1301
+ ( false , true ) => snippet_with_macro_callsite( cx, fun_span, ".." ) ,
1302
+ } ;
1303
+ let span_replace_word = method_span. with_hi( span. hi( ) ) ;
1304
+ span_lint_and_sugg(
1305
+ cx,
1306
+ OR_FUN_CALL ,
1307
+ span_replace_word,
1308
+ & format!( "use of `{}` followed by a function call" , name) ,
1309
+ "try this" ,
1310
+ format!( "{}_{}({})" , name, suffix, sugg) ,
1311
+ Applicability :: HasPlaceholders ,
1312
+ ) ;
1313
+ }
1314
+ }
1324
1315
}
1325
1316
1326
1317
if args. len ( ) == 2 {
0 commit comments