Skip to content

Commit d0f8d1f

Browse files
committed
---
yaml --- r: 33517 b: refs/heads/snap-stage3 c: 2ab614f h: refs/heads/master i: 33515: f3b8e26 v: v3
1 parent cab8b8f commit d0f8d1f

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,7 +1,7 @@
11
---
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c7ec183b34805ba6af0c49581639b16dbd33e47a
4+
refs/heads/snap-stage3: 2ab614f3569f34eee2fd70862e8f35548282fb11
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)