Skip to content

Commit 3651781

Browse files
committed
Require break expr to converge
1 parent ba6b0cc commit 3651781

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

text/0000-loop-break-value.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Four forms of `break` will be supported:
5454
3. `break EXPR;`
5555
4. `break 'label EXPR;`
5656

57-
where `'label` is the name of a loop and `EXPR` is an expression.
57+
where `'label` is the name of a loop and `EXPR` is an converging expression.
5858

5959
### Result type of loop
6060

@@ -88,7 +88,6 @@ This proposal changes the result type of 'loop' to `T`, where:
8888

8989
* if a loop is "broken" via `break;` or `break 'label;`, the loop's result type must be `()`
9090
* if a loop is "broken" via `break EXPR;` or `break 'label EXPR;`, `EXPR` must evaluate to type `T`
91-
* as a special case, if a loop is "broken" via `break EXPR;` or `break 'label EXPR;` where `EXPR` evaluates to type `!` (does not return), this does not place a constraint on the type of the loop
9291
* if external constaint on the loop's result type exist (e.g. `let x: S = loop { ... };`), then `T` must be coercible to this type
9392

9493
It is an error if these types do not agree or if the compiler's type deduction
@@ -129,11 +128,6 @@ fn g() -> u32 {
129128
// ! coerces to u32
130129
loop {}
131130
}
132-
fn z() -> ! {
133-
loop {
134-
break panic!();
135-
}
136-
}
137131
```
138132

139133
Example showing the equivalence of `break;` and `break ();`:

0 commit comments

Comments
 (0)