Skip to content

lint unused labels #708

Closed
Closed
@llogiq

Description

@llogiq

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 LintPasses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-ASTType: Requires working with the AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions