Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint unused labels #708

Closed
llogiq opened this issue Feb 25, 2016 · 2 comments
Closed

lint unused labels #708

llogiq opened this issue Feb 25, 2016 · 2 comments
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST

Comments

@llogiq
Copy link
Contributor

llogiq commented Feb 25, 2016

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.

@llogiq llogiq added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST A-lint Area: New lints labels Feb 26, 2016
@ticki
Copy link

ticki commented Feb 26, 2016

I believe this is something rustc should do, since this is a relatively simple task, which will not break any consistencies in the current upstream lints.

@llogiq
Copy link
Contributor Author

llogiq commented Feb 27, 2016

Just a heads-up: We have check_fn_post(..).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST
Projects
None yet
Development

No branches or pull requests

2 participants