about summary refs log tree commit diff
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorGeoffry Song <goffrie@gmail.com>2016-10-29 15:15:06 -0700
committerGeoffry Song <goffrie@gmail.com>2016-11-21 20:20:42 -0800
commit9d42549df40464899dda11fc9509f511046fb4c6 (patch)
treee240f7d0a7c1ebeaa46b6b30459ee11405eeeb80 /src/test/incremental/thinlto
parent82d8833a456a408fe8b761a3b5e88475b65066c8 (diff)
downloadrust-9d42549df40464899dda11fc9509f511046fb4c6.tar.gz
rust-9d42549df40464899dda11fc9509f511046fb4c6.zip
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, `loop` loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
  blocks. That is, `while break { break-value } { while-body }` is
  illegal; this preserves backwards compatibility.
- 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 ^_^
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions