Skip to content

shadowed label false positive in closure #31754

New issue

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

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

Already on GitHub? # to your account

Closed
durka opened this issue Feb 18, 2016 · 0 comments · Fixed by #33345
Closed

shadowed label false positive in closure #31754

durka opened this issue Feb 18, 2016 · 0 comments · Fixed by #33345
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@durka
Copy link
Contributor

durka commented Feb 18, 2016

It seems that #27093 did not fully fix #25343. The following code reports a spurious warning on 'b:

'a: loop { break; }
'b: loop { break; }

// no warning
fn does_not_shadow() {
    'a: loop {}
}

// false positive
let also_does_not_shadow = || {
    'b: loop {}
};

Stable, beta, nightly.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Mar 11, 2016
birkenfeld added a commit to birkenfeld/rust that referenced this issue May 2, 2016
This should fix rust-lang#31754 and follow-up rust-lang#25343.  Before the latter, the
closure was visited twice in the context of the enclosing fn, which
made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context
of the main fn (which is intended, since it is not a separate item)
but resets the found loop labels while being visited.

Fixes: rust-lang#31754
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 10, 2016
middle: reset loop labels while visiting closure

This should fix rust-lang#31754 and follow-up rust-lang#25343.  Before the latter, the closure was visited twice in the context of the enclosing fn, which made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context of the main fn (which is intended, since it is not a separate item) but resets the found loop labels while being visited.

Fixes: rust-lang#31754

Note: I amended the test file from rust-lang#25343, but I don't know if the original or amended test are effective, since as far as I could see, compiletest's run-pass tests do not check for zero warnings emitted?

/cc @Manishearth
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 10, 2016
middle: reset loop labels while visiting closure

This should fix rust-lang#31754 and follow-up rust-lang#25343.  Before the latter, the closure was visited twice in the context of the enclosing fn, which made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context of the main fn (which is intended, since it is not a separate item) but resets the found loop labels while being visited.

Fixes: rust-lang#31754

Note: I amended the test file from rust-lang#25343, but I don't know if the original or amended test are effective, since as far as I could see, compiletest's run-pass tests do not check for zero warnings emitted?

/cc @Manishearth
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 11, 2016
middle: reset loop labels while visiting closure

This should fix rust-lang#31754 and follow-up rust-lang#25343.  Before the latter, the closure was visited twice in the context of the enclosing fn, which made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context of the main fn (which is intended, since it is not a separate item) but resets the found loop labels while being visited.

Fixes: rust-lang#31754

Note: I amended the test file from rust-lang#25343, but I don't know if the original or amended test are effective, since as far as I could see, compiletest's run-pass tests do not check for zero warnings emitted?

/cc @Manishearth
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants