Skip to content

Commit b2b734c

Browse files
committed
More HirIdfication
1 parent f3455cd commit b2b734c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

clippy_lints/src/loops.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,12 +1459,11 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(
14591459
// For each candidate, check the parent block to see if
14601460
// it's initialized to zero at the start of the loop.
14611461
let map = &cx.tcx.hir();
1462-
let expr_node_id = map.hir_to_node_id(expr.hir_id);
14631462
let parent_scope = map
1464-
.get_enclosing_scope(expr_node_id)
1463+
.get_enclosing_scope(expr.hir_id)
14651464
.and_then(|id| map.get_enclosing_scope(id));
14661465
if let Some(parent_id) = parent_scope {
1467-
if let Node::Block(block) = map.get(parent_id) {
1466+
if let Node::Block(block) = map.get(map.hir_to_node_id(parent_id)) {
14681467
for (id, _) in visitor.states.iter().filter(|&(_, v)| *v == VarState::IncrOnce) {
14691468
let mut visitor2 = InitializeVisitor {
14701469
cx,

clippy_lints/src/utils/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,9 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c
593593

594594
pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: HirId) -> Option<&'tcx Block> {
595595
let map = &cx.tcx.hir();
596-
let node_id = map.hir_to_node_id(node);
597596
let enclosing_node = map
598-
.get_enclosing_scope(node_id)
599-
.and_then(|enclosing_id| map.find(enclosing_id));
597+
.get_enclosing_scope(node)
598+
.and_then(|enclosing_id| map.find(map.hir_to_node_id(enclosing_id)));
600599
if let Some(node) = enclosing_node {
601600
match node {
602601
Node::Block(block) => Some(block),

0 commit comments

Comments
 (0)