@@ -651,9 +651,11 @@ trait UnusedDelimLint {
651651
652652 fn is_expr_delims_necessary (
653653 inner : & ast:: Expr ,
654+ ctx : UnusedDelimsCtx ,
654655 followed_by_block : bool ,
655- followed_by_else : bool ,
656656 ) -> bool {
657+ let followed_by_else = ctx == UnusedDelimsCtx :: AssignedValueLetElse ;
658+
657659 if followed_by_else {
658660 match inner. kind {
659661 ast:: ExprKind :: Binary ( op, ..) if op. node . is_lazy ( ) => return true ,
@@ -662,6 +664,13 @@ trait UnusedDelimLint {
662664 }
663665 }
664666
667+ // Check it's range in LetScrutineeExpr
668+ if let ast:: ExprKind :: Range ( ..) = inner. kind
669+ && matches ! ( ctx, UnusedDelimsCtx :: LetScrutineeExpr )
670+ {
671+ return true ;
672+ }
673+
665674 // Check if LHS needs parens to prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }`.
666675 {
667676 let mut innermost = inner;
@@ -1007,8 +1016,7 @@ impl UnusedDelimLint for UnusedParens {
10071016 ) {
10081017 match value. kind {
10091018 ast:: ExprKind :: Paren ( ref inner) => {
1010- let followed_by_else = ctx == UnusedDelimsCtx :: AssignedValueLetElse ;
1011- if !Self :: is_expr_delims_necessary ( inner, followed_by_block, followed_by_else)
1019+ if !Self :: is_expr_delims_necessary ( inner, ctx, followed_by_block)
10121020 && value. attrs . is_empty ( )
10131021 && !value. span . from_expansion ( )
10141022 && ( ctx != UnusedDelimsCtx :: LetScrutineeExpr
@@ -1334,7 +1342,7 @@ impl UnusedDelimLint for UnusedBraces {
13341342 // FIXME(const_generics): handle paths when #67075 is fixed.
13351343 if let [ stmt] = inner. stmts . as_slice ( ) {
13361344 if let ast:: StmtKind :: Expr ( ref expr) = stmt. kind {
1337- if !Self :: is_expr_delims_necessary ( expr, followed_by_block , false )
1345+ if !Self :: is_expr_delims_necessary ( expr, ctx , followed_by_block )
13381346 && ( ctx != UnusedDelimsCtx :: AnonConst
13391347 || ( matches ! ( expr. kind, ast:: ExprKind :: Lit ( _) )
13401348 && !expr. span . from_expansion ( ) ) )
0 commit comments