From 36517812becfc395f346020f91efeab4598afe44 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Fri, 20 May 2016 20:06:51 +0100 Subject: [PATCH] Require break expr to converge --- text/0000-loop-break-value.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/text/0000-loop-break-value.md b/text/0000-loop-break-value.md index 8237c391203..33df7c2f157 100644 --- a/text/0000-loop-break-value.md +++ b/text/0000-loop-break-value.md @@ -54,7 +54,7 @@ Four forms of `break` will be supported: 3. `break EXPR;` 4. `break 'label EXPR;` -where `'label` is the name of a loop and `EXPR` is an expression. +where `'label` is the name of a loop and `EXPR` is an converging expression. ### Result type of loop @@ -88,7 +88,6 @@ This proposal changes the result type of 'loop' to `T`, where: * if a loop is "broken" via `break;` or `break 'label;`, the loop's result type must be `()` * if a loop is "broken" via `break EXPR;` or `break 'label EXPR;`, `EXPR` must evaluate to type `T` -* 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 * if external constaint on the loop's result type exist (e.g. `let x: S = loop { ... };`), then `T` must be coercible to this type It is an error if these types do not agree or if the compiler's type deduction @@ -129,11 +128,6 @@ fn g() -> u32 { // ! coerces to u32 loop {} } -fn z() -> ! { - loop { - break panic!(); - } -} ``` Example showing the equivalence of `break;` and `break ();`: