@@ -276,10 +276,13 @@ impl UnusedParens {
276
276
cx : & EarlyContext ,
277
277
value : & ast:: Expr ,
278
278
msg : & str ,
279
- struct_lit_needs_parens : bool ) {
279
+ followed_by_block : bool ) {
280
280
if let ast:: ExprKind :: Paren ( ref inner) = value. node {
281
- let necessary = struct_lit_needs_parens &&
282
- parser:: contains_exterior_struct_lit ( & inner) ;
281
+ let necessary = followed_by_block && if let ast:: ExprKind :: Ret ( _) = inner. node {
282
+ true
283
+ } else {
284
+ parser:: contains_exterior_struct_lit ( & inner)
285
+ } ;
283
286
if !necessary {
284
287
let pattern = pprust:: expr_to_string ( value) ;
285
288
Self :: remove_outer_parens ( cx, value. span , & pattern, msg) ;
@@ -343,7 +346,7 @@ impl LintPass for UnusedParens {
343
346
impl EarlyLintPass for UnusedParens {
344
347
fn check_expr ( & mut self , cx : & EarlyContext , e : & ast:: Expr ) {
345
348
use syntax:: ast:: ExprKind :: * ;
346
- let ( value, msg, struct_lit_needs_parens ) = match e. node {
349
+ let ( value, msg, followed_by_block ) = match e. node {
347
350
If ( ref cond, ..) => ( cond, "`if` condition" , true ) ,
348
351
While ( ref cond, ..) => ( cond, "`while` condition" , true ) ,
349
352
IfLet ( _, ref cond, ..) => ( cond, "`if let` head expression" , true ) ,
@@ -380,7 +383,7 @@ impl EarlyLintPass for UnusedParens {
380
383
return ;
381
384
}
382
385
} ;
383
- self . check_unused_parens_expr ( cx, & value, msg, struct_lit_needs_parens ) ;
386
+ self . check_unused_parens_expr ( cx, & value, msg, followed_by_block ) ;
384
387
}
385
388
386
389
fn check_pat ( & mut self , cx : & EarlyContext , p : & ast:: Pat ) {
0 commit comments