Skip to content

Commit 2f14c59

Browse files
committed
fix: match_single_binding misses curlies for const
1 parent f39ed7a commit 2f14c59

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clippy_lints/src/matches/match_single_binding.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::Applicability;
99
use rustc_hir::def::Res;
1010
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_path, walk_stmt};
11-
use rustc_hir::{Arm, Block, Expr, ExprKind, HirId, Node, PatKind, Path, Stmt, StmtKind};
11+
use rustc_hir::{Arm, Block, Expr, ExprKind, HirId, Item, ItemKind, Node, PatKind, Path, Stmt, StmtKind};
1212
use rustc_lint::LateContext;
1313
use rustc_span::{Span, Symbol};
1414

@@ -380,6 +380,7 @@ fn sugg_with_curlies<'a>(
380380
if let Node::Stmt(stmt) = parent {
381381
parent = cx.tcx.parent_hir_node(stmt.hir_id);
382382
}
383+
dbg!(parent);
383384

384385
match parent {
385386
Node::Block(..)
@@ -391,7 +392,12 @@ fn sugg_with_curlies<'a>(
391392
add_curlies();
392393
}
393394
},
394-
Node::Expr(..) | Node::AnonConst(..) => add_curlies(),
395+
Node::Expr(..)
396+
| Node::AnonConst(..)
397+
| Node::Item(Item {
398+
kind: ItemKind::Const(..),
399+
..
400+
}) => add_curlies(),
395401
Node::Arm(arm) if let ExprKind::Match(..) = arm.body.kind => add_curlies(),
396402
_ => {},
397403
}

0 commit comments

Comments
 (0)