@@ -294,20 +294,28 @@ impl UnusedParens {
294
294
value : & ast:: Expr ,
295
295
msg : & str ,
296
296
followed_by_block : bool ) {
297
- if let ast:: ExprKind :: Paren ( ref inner) = value. node {
298
- let necessary = followed_by_block && match inner. node {
299
- ast:: ExprKind :: Ret ( _) | ast:: ExprKind :: Break ( ..) => true ,
300
- _ => parser:: contains_exterior_struct_lit ( & inner) ,
301
- } ;
302
- if !necessary {
303
- let expr_text = if let Ok ( snippet) = cx. sess ( ) . source_map ( )
304
- . span_to_snippet ( value. span ) {
305
- snippet
306
- } else {
307
- pprust:: expr_to_string ( value)
308
- } ;
309
- Self :: remove_outer_parens ( cx, value. span , & expr_text, msg) ;
297
+ match value. node {
298
+ ast:: ExprKind :: Paren ( ref inner) => {
299
+ let necessary = followed_by_block && match inner. node {
300
+ ast:: ExprKind :: Ret ( _) | ast:: ExprKind :: Break ( ..) => true ,
301
+ _ => parser:: contains_exterior_struct_lit ( & inner) ,
302
+ } ;
303
+ if !necessary {
304
+ let expr_text = if let Ok ( snippet) = cx. sess ( ) . source_map ( )
305
+ . span_to_snippet ( value. span ) {
306
+ snippet
307
+ } else {
308
+ pprust:: expr_to_string ( value)
309
+ } ;
310
+ Self :: remove_outer_parens ( cx, value. span , & expr_text, msg) ;
311
+ }
312
+ }
313
+ ast:: ExprKind :: Let ( _, ref expr) => {
314
+ // FIXME(#60336): Properly handle `let true = (false && true)`
315
+ // actually needing the parenthesis.
316
+ self . check_unused_parens_expr ( cx, expr, "`let` scrutinee" , followed_by_block) ;
310
317
}
318
+ _ => { }
311
319
}
312
320
}
313
321
@@ -369,8 +377,6 @@ impl EarlyLintPass for UnusedParens {
369
377
let ( value, msg, followed_by_block) = match e. node {
370
378
If ( ref cond, ..) => ( cond, "`if` condition" , true ) ,
371
379
While ( ref cond, ..) => ( cond, "`while` condition" , true ) ,
372
- IfLet ( _, ref cond, ..) => ( cond, "`if let` head expression" , true ) ,
373
- WhileLet ( _, ref cond, ..) => ( cond, "`while let` head expression" , true ) ,
374
380
ForLoop ( _, ref cond, ..) => ( cond, "`for` head expression" , true ) ,
375
381
Match ( ref head, _) => ( head, "`match` head expression" , true ) ,
376
382
Ret ( Some ( ref value) ) => ( value, "`return` value" , false ) ,
0 commit comments