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

resolve: disallow labelled breaks/continues through closures/async blocks #73726

Conversation

davidtwco
Copy link
Member

Fixes #73541.

This PR modifies name resolution to prohibit labelled breaks/continues through closures or async blocks, fixing an ICE. In addition, it improves the diagnostics surrounding labelled breaks/continues through closures or async blocks by informing the user if the label exists in an parent scope and telling them that won't work.

r? @petrochenkov (resolve)
cc @estebank (diagnostic changes) @tmandry (issue is from wg-async-foundations)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 25, 2020
src/librustc_resolve/late.rs Show resolved Hide resolved
src/librustc_resolve/diagnostics.rs Outdated Show resolved Hide resolved
src/librustc_resolve/late.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 26, 2020
@davidtwco davidtwco added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2020
@davidtwco davidtwco force-pushed the issue-73541-labelled-break-through-closure-async branch from e284e61 to 701df52 Compare June 27, 2020 18:05
@petrochenkov
Copy link
Contributor

(I'm no longer on remote work, so I'll review with delays now.)

src/librustc_resolve/late.rs Outdated Show resolved Hide resolved
src/librustc_resolve/diagnostics.rs Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

Also the commits need squashing.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2020
This commit modifies resolve to disallow `break`/`continue` to labels
through closures or async blocks. This doesn't make sense and should
have been prohibited anyway.

Signed-off-by: David Wood <[email protected]>
@davidtwco davidtwco force-pushed the issue-73541-labelled-break-through-closure-async branch from 701df52 to cb541dc Compare July 2, 2020 12:52
@davidtwco
Copy link
Member Author

Also the commits need squashing.

Fixed!

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 2, 2020

📌 Commit cb541dc has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 2, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 2, 2020
…k-through-closure-async, r=petrochenkov

resolve: disallow labelled breaks/continues through closures/async blocks

Fixes rust-lang#73541.

This PR modifies name resolution to prohibit labelled breaks/continues through closures or async blocks, fixing an ICE. In addition, it improves the diagnostics surrounding labelled breaks/continues through closures or async blocks by informing the user if the label exists in an parent scope and telling them that won't work.

r? @petrochenkov (resolve)
cc @estebank (diagnostic changes) @tmandry (issue is from `wg-async-foundations`)
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2020
…arth

Rollup of 8 pull requests

Successful merges:

 - rust-lang#73454 (Move contributing.md to rustc-dev-guide and point at getting started)
 - rust-lang#73724 (Use WASM's saturating casts if they are available)
 - rust-lang#73726 (resolve: disallow labelled breaks/continues through closures/async blocks)
 - rust-lang#73753 (Use 'tcx for references to AccessLevels wherever possible.)
 - rust-lang#73781 (Update psm version)
 - rust-lang#73952 (Add option for local docker testing.)
 - rust-lang#73957 (disable BTree min_max test in Miri for now)
 - rust-lang#73975 (Document rustc_ast::ast::Pat)

Failed merges:

r? @ghost
@bors bors merged commit 2d83cbb into rust-lang:master Jul 3, 2020
@davidtwco davidtwco deleted the issue-73541-labelled-break-through-closure-async branch July 11, 2020 16:58
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
6 participants