@@ -2,7 +2,7 @@ use std::iter;
22
33use rustc_ast as ast;
44use rustc_ast:: util:: { classify, parser} ;
5- use rustc_ast:: { ExprKind , StmtKind } ;
5+ use rustc_ast:: { ExprKind , FnRetTy , StmtKind } ;
66use rustc_errors:: { MultiSpan , pluralize} ;
77use rustc_hir:: def:: { DefKind , Res } ;
88use rustc_hir:: def_id:: DefId ;
@@ -593,6 +593,7 @@ enum UnusedDelimsCtx {
593593 AnonConst ,
594594 MatchArmExpr ,
595595 IndexExpr ,
596+ ClosureBody ,
596597}
597598
598599impl From < UnusedDelimsCtx > for & ' static str {
@@ -614,6 +615,7 @@ impl From<UnusedDelimsCtx> for &'static str {
614615 UnusedDelimsCtx :: ArrayLenExpr | UnusedDelimsCtx :: AnonConst => "const expression" ,
615616 UnusedDelimsCtx :: MatchArmExpr => "match arm expression" ,
616617 UnusedDelimsCtx :: IndexExpr => "index expression" ,
618+ UnusedDelimsCtx :: ClosureBody => "closure body" ,
617619 }
618620 }
619621}
@@ -909,6 +911,11 @@ trait UnusedDelimLint {
909911 let ( args_to_check, ctx) = match * call_or_other {
910912 Call ( _, ref args) => ( & args[ ..] , UnusedDelimsCtx :: FunctionArg ) ,
911913 MethodCall ( ref call) => ( & call. args [ ..] , UnusedDelimsCtx :: MethodArg ) ,
914+ Closure ( ref closure)
915+ if matches ! ( closure. fn_decl. output, FnRetTy :: Default ( _) ) =>
916+ {
917+ ( & [ closure. body . clone ( ) ] [ ..] , UnusedDelimsCtx :: ClosureBody )
918+ }
912919 // actual catch-all arm
913920 _ => {
914921 return ;
@@ -1392,6 +1399,7 @@ impl UnusedDelimLint for UnusedBraces {
13921399 && ( ctx != UnusedDelimsCtx :: AnonConst
13931400 || ( matches ! ( expr. kind, ast:: ExprKind :: Lit ( _) )
13941401 && !expr. span . from_expansion ( ) ) )
1402+ && ctx != UnusedDelimsCtx :: ClosureBody
13951403 && !cx. sess ( ) . source_map ( ) . is_multiline ( value. span )
13961404 && value. attrs . is_empty ( )
13971405 && !value. span . from_expansion ( )
0 commit comments