Skip to content

Commit b4827ae

Browse files
committed
---
yaml --- r: 38794 b: refs/heads/incoming c: 2ab614f h: refs/heads/master v: v3
1 parent 6c797ba commit b4827ae

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
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: c7ec183b34805ba6af0c49581639b16dbd33e47a
9+
refs/heads/incoming: 2ab614f3569f34eee2fd70862e8f35548282fb11
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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)