Skip to content

Commit b4edda9

Browse files
committed
Remove usage of DUMMY_HIR_ID in CheckLoopVisitor
1 parent 812854c commit b4edda9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc_passes/loops.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,31 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
7777
}
7878

7979
let loop_id = match label.target_id {
80-
Ok(loop_id) => loop_id,
81-
Err(hir::LoopIdError::OutsideLoopScope) => hir::DUMMY_HIR_ID,
80+
Ok(loop_id) => Some(loop_id),
81+
Err(hir::LoopIdError::OutsideLoopScope) => None,
8282
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
8383
self.emit_unlabled_cf_in_while_condition(e.span, "break");
84-
hir::DUMMY_HIR_ID
84+
None
8585
}
86-
Err(hir::LoopIdError::UnresolvedLabel) => hir::DUMMY_HIR_ID,
86+
Err(hir::LoopIdError::UnresolvedLabel) => None,
8787
};
8888

89-
if loop_id != hir::DUMMY_HIR_ID {
89+
if let Some(loop_id) = loop_id {
9090
if let Node::Block(_) = self.hir_map.find(loop_id).unwrap() {
9191
return;
9292
}
9393
}
9494

9595
if opt_expr.is_some() {
96-
let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
97-
None
98-
} else {
96+
let loop_kind = if let Some(loop_id) = loop_id {
9997
Some(match self.hir_map.expect_expr(loop_id).kind {
10098
hir::ExprKind::Loop(_, _, source) => source,
10199
ref r => {
102100
span_bug!(e.span, "break label resolved to a non-loop: {:?}", r)
103101
}
104102
})
103+
} else {
104+
None
105105
};
106106
match loop_kind {
107107
None | Some(hir::LoopSource::Loop) => (),

0 commit comments

Comments
 (0)