rust/src/librustc_mir
Geoffry Song 9d42549df4
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 ^_^
2016-11-21 20:20:42 -08:00
..
build Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
hair Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
transform Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddyb 2016-11-17 17:31:01 -08:00
Cargo.toml Fix Cargo.tomls 2016-06-27 18:30:46 +00:00
def_use.rs rustc: move mir::repr::* to mir. 2016-10-28 10:37:24 +03:00
diagnostics.rs Add error code test checkup 2016-08-24 11:28:09 +02:00
graphviz.rs rustc: move the MIR map into TyCtxt. 2016-10-28 13:55:49 +03:00
lib.rs Stabilize RFC 1560. 2016-11-21 09:10:16 +00:00
mir_map.rs refactor Visitor into ItemLikeVisitor and intravisit::Visitor 2016-11-16 13:51:36 -05:00
pretty.rs Remove scope_auxiliary. 2016-11-14 17:04:05 +11:00