Closed
Description
We should lint labels that aren't used anywhere, as in
fn unused_label() {
'label: for i in 1..2 {
if i > 4 { continue }
}
}
To do this, we can use a Visitor
to walk any FnDecl, collecting all used labels in a HashSet, then for all loops lint labels whose name isn't in the set. We also probably want to store the function's Block
somewhere so we can clear the set in its check_block_post
method – or perhaps I'll add another rustc PR with a check_fn_post
method for both LintPass
es.