rust/src/libsyntax
bors 1cabe21512 Auto merge of #37487 - goffrie:break, r=nikomatsakis
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 ^_^
2016-11-22 17:51:59 -06:00
..
diagnostics Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
ext Auto merge of #37487 - goffrie:break, r=nikomatsakis 2016-11-22 17:51:59 -06:00
parse Auto merge of #37487 - goffrie:break, r=nikomatsakis 2016-11-22 17:51:59 -06:00
print Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
util Fix fallout in rustdoc and tests. 2016-11-21 12:16:46 +00:00
abi.rs check target abi support 2016-10-24 15:59:53 +02:00
ast.rs Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
attr.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Cargo.toml Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
codemap.rs Fix fallout in rustdoc and tests. 2016-11-21 12:16:46 +00:00
config.rs Move MetaItemKind's Name to a field of MetaItem. 2016-11-20 12:36:30 +00:00
diagnostic_list.rs Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
entry.rs Cleanup InternedString. 2016-11-21 09:00:56 +00:00
feature_gate.rs Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
fold.rs Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00
json.rs Allow supplying an error destination via the compiler driver 2016-09-28 16:20:30 +13:00
lib.rs Remove Rc from the interner. 2016-11-21 09:00:56 +00:00
ptr.rs Documentation for default types modified 2016-09-11 22:58:01 +05:30
show_span.rs Remove the type parameter from syntax::visit::Visitor 2016-06-14 07:40:32 +00:00
std_inject.rs Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00
str.rs syntax: Copy unstable str::char_at into libsyntax 2015-04-21 10:23:53 -07:00
symbol.rs Remove Rc from the interner. 2016-11-21 09:00:56 +00:00
test.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
tokenstream.rs Fix fallout in rustdoc and tests. 2016-11-21 12:16:46 +00:00
visit.rs Implement the loop_break_value feature. 2016-11-21 20:20:42 -08:00