11use  std:: iter; 
22
33use  rustc_ast:: util:: { classify,  parser} ; 
4- use  rustc_ast:: { self  as  ast,  ExprKind ,  HasAttrs  as  _,  StmtKind } ; 
4+ use  rustc_ast:: { self  as  ast,  ExprKind ,  FnRetTy ,   HasAttrs  as  _,  StmtKind } ; 
55use  rustc_attr_data_structures:: { AttributeKind ,  find_attr} ; 
66use  rustc_data_structures:: fx:: FxHashMap ; 
77use  rustc_errors:: { MultiSpan ,  pluralize} ; 
@@ -599,6 +599,7 @@ enum UnusedDelimsCtx {
599599    AnonConst , 
600600    MatchArmExpr , 
601601    IndexExpr , 
602+     ClosureBody , 
602603} 
603604
604605impl  From < UnusedDelimsCtx >  for  & ' static  str  { 
@@ -620,6 +621,7 @@ impl From<UnusedDelimsCtx> for &'static str {
620621            UnusedDelimsCtx :: ArrayLenExpr  | UnusedDelimsCtx :: AnonConst  => "const expression" , 
621622            UnusedDelimsCtx :: MatchArmExpr  => "match arm expression" , 
622623            UnusedDelimsCtx :: IndexExpr  => "index expression" , 
624+             UnusedDelimsCtx :: ClosureBody  => "closure body" , 
623625        } 
624626    } 
625627} 
@@ -919,6 +921,11 @@ trait UnusedDelimLint {
919921                let  ( args_to_check,  ctx)  = match  * call_or_other { 
920922                    Call ( _,  ref  args)  => ( & args[ ..] ,  UnusedDelimsCtx :: FunctionArg ) , 
921923                    MethodCall ( ref  call)  => ( & call. args [ ..] ,  UnusedDelimsCtx :: MethodArg ) , 
924+                     Closure ( ref  closure) 
925+                         if  matches ! ( closure. fn_decl. output,  FnRetTy :: Default ( _) )  =>
926+                     { 
927+                         ( & [ closure. body . clone ( ) ] [ ..] ,  UnusedDelimsCtx :: ClosureBody ) 
928+                     } 
922929                    // actual catch-all arm 
923930                    _ => { 
924931                        return ; 
@@ -1508,6 +1515,7 @@ impl UnusedDelimLint for UnusedBraces {
15081515                            && ( ctx != UnusedDelimsCtx :: AnonConst 
15091516                                || ( matches ! ( expr. kind,  ast:: ExprKind :: Lit ( _) ) 
15101517                                    && !expr. span . from_expansion ( ) ) ) 
1518+                             && ctx != UnusedDelimsCtx :: ClosureBody 
15111519                            && !cx. sess ( ) . source_map ( ) . is_multiline ( value. span ) 
15121520                            && value. attrs . is_empty ( ) 
15131521                            && !value. span . from_expansion ( ) 
0 commit comments