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: fix label scopes #37360

Merged
merged 1 commit into from
Oct 25, 2016
Merged

resolve: fix label scopes #37360

merged 1 commit into from
Oct 25, 2016

Conversation

jseyfried
Copy link
Contributor

Fixes #37353 (turns an ICE back into an error).
r? @nrc

@nrc
Copy link
Member

nrc commented Oct 25, 2016

@bors: r+

@bors
Copy link
Contributor

bors commented Oct 25, 2016

📌 Commit dcdab2d has been approved by nrc

@jseyfried jseyfried added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 25, 2016
@bors
Copy link
Contributor

bors commented Oct 25, 2016

⌛ Testing commit dcdab2d with merge 67f26f7...

bors added a commit that referenced this pull request Oct 25, 2016
resolve: fix label scopes

Fixes #37353 (turns an ICE back into an error).
r? @nrc
@nikomatsakis nikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Oct 25, 2016
@nikomatsakis
Copy link
Contributor

Marking for beta-accepted since this is a small, harmless-looking patch. It fixes an ICE (turns it back into a hard error). I could see a counter argument that such a change (since it is an error otherwise) doesn't merit a backport.

What say you, @rust-lang/compiler ?

@eddyb
Copy link
Member

eddyb commented Oct 25, 2016

SGTM.

@michaelwoerister
Copy link
Member

👍

@bors bors merged commit dcdab2d into rust-lang:master Oct 25, 2016
@brson brson mentioned this pull request Nov 3, 2016
@brson brson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 3, 2016
bors added a commit that referenced this pull request Nov 22, 2016
Implement the `loop_break_value` feature.

This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
  currently deduced type of that loop, the desired type, and a list of
  break expressions currently seen. `loop` loops get a fresh type
  variable as their initial type (this logic is stolen from that for
  arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
  `expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop.
- ~~I have also changed the loop scoping in MIR-building so that the test
  of a while loop is not considered to be part of that loop. This makes
  the rules consistent with #37360. The new loop scopes in typeck also
  follow this rule. That means that `loop { while (break) {} }` now
  terminates instead of looping forever. This is technically a breaking
  change.~~
- ~~On that note, expressions like `while break {}` and `if break {}` no
  longer parse because `{}` is interpreted as an expression argument to
  `break`. But no code except compiler test cases should do that anyway
  because it makes no sense.~~
- The RFC did not make it clear, but I chose to make `break ()` inside
  of a `while` loop illegal, just in case we wanted to do anything with
  that design space in the future.

This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants