Skip to content

Commit 8a382a7

Browse files
committed
---
yaml --- r: 34936 b: refs/heads/master c: 2ab614f h: refs/heads/master v: v3
1 parent f1dba7b commit 8a382a7

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c7ec183b34805ba6af0c49581639b16dbd33e47a
2+
refs/heads/master: 2ab614f3569f34eee2fd70862e8f35548282fb11
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/doc/rust.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,32 +1951,48 @@ while i < 10 {
19511951

19521952
### Infinite loops
19531953

1954-
A `loop` expression denotes an infinite loop:
1954+
The keyword `loop` in Rust appears both in _loop expressions_ and in _continue expressions_.
1955+
A loop expression denotes an infinite loop;
1956+
see [Continue expressions](#continue-expressions) for continue expressions.
19551957

19561958
~~~~~~~~{.ebnf .gram}
1957-
loop_expr : "loop" '{' block '}';
1959+
loop_expr : "loop" [ ident ':' ] '{' block '}';
19581960
~~~~~~~~
19591961

1962+
A `loop` expression may optionally have a _label_.
1963+
If a label is present,
1964+
then labeled `break` and `loop` expressions nested within this loop may exit out of this loop or return control to its head.
1965+
See [Break expressions](#break-expressions).
1966+
19601967
### Break expressions
19611968

19621969
~~~~~~~~{.ebnf .gram}
1963-
break_expr : "break" ;
1970+
break_expr : "break" [ ident ];
19641971
~~~~~~~~
19651972

1966-
Executing a `break` expression immediately terminates the innermost loop
1967-
enclosing it. It is only permitted in the body of a loop.
1973+
A `break` expression has an optional `label`.
1974+
If the label is absent, then executing a `break` expression immediately terminates the innermost loop enclosing it.
1975+
It is only permitted in the body of a loop.
1976+
If the label is present, then `break foo` terminates the loop with label `foo`,
1977+
which need not be the innermost label enclosing the `break` expression,
1978+
but must enclose it.
19681979

1969-
### Loop expressions
1980+
### Continue expressions
19701981

19711982
~~~~~~~~{.ebnf .gram}
1972-
loop_expr : "loop" ;
1973-
~~~~~~~~
1974-
1975-
Evaluating a `loop` expression immediately terminates the current iteration of
1976-
the innermost loop enclosing it, returning control to the loop *head*. In the
1977-
case of a `while` loop, the head is the conditional expression controlling the
1978-
loop. In the case of a `for` loop, the head is the call-expression controlling
1979-
the loop.
1983+
continue_expr : "loop" [ ident ];
1984+
~~~~~~~~
1985+
1986+
A continue expression, written `loop`, also has an optional `label`.
1987+
If the label is absent,
1988+
then executing a `loop` expression immediately terminates the current iteration of the innermost loop enclosing it,
1989+
returning control to the loop *head*.
1990+
In the case of a `while` loop,
1991+
the head is the conditional expression controlling the loop.
1992+
In the case of a `for` loop, the head is the call-expression controlling the loop.
1993+
If the label is present, then `loop foo` returns control to the head of the loop with label `foo`,
1994+
which need not be the innermost label enclosing the `break` expression,
1995+
but must enclose it.
19801996

19811997
A `loop` expression is only permitted in the body of a loop.
19821998

0 commit comments

Comments
 (0)