Skip to content

Commit 31f840e

Browse files
committed
Reviews from Jane
1 parent 966e4b3 commit 31f840e

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/divergence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ r[divergence]
44
r[divergence.intro]
55
Divergence is the state where a particular section of code could never be encountered at runtime. Importantly, while there are certain language constructs that immediately produce a _diverging expression_ of the type [`!`](./types/never.md), divergence can also propogate to the surrounding block.
66

7-
Any expression of type [`!`](./types/never.md) is a _diverging expression_, but there are also diverging expressions which are not of type `!` (e.g. `Some(panic!())`).
7+
Any expression of type [`!`](./types/never.md) is a _diverging expression_, but there are also diverging expressions which are not of type `!` (e.g. `Some(loop {})` produces a type of `Option<!>`).
88

99
r[divergence.fallback]
1010
## Fallback

src/expressions/block-expr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ r[expr.block.result]
4444
Then the final operand is executed, if given.
4545

4646
r[expr.block.type]
47-
Except in the case of divergence (see below), the type of a block is the type of the final operand, or `()` if the final operand is omitted.
47+
Except in the case of divergence [(see below)](block-expr.md#r-expr.block.type.diverging), the type of a block is the type of the final operand, or `()` if the final operand is omitted.
4848

4949
```rust
5050
# fn fn_call() {}
@@ -64,7 +64,7 @@ assert_eq!(5, five);
6464
> As a control flow expression, if a block expression is the outer expression of an expression statement, the expected type is `()` unless it is followed immediately by a semicolon.
6565
6666
r[expr.block.type.diverging]
67-
A block is itself considered to be [diverging](../divergence.md) if all reachable control flow paths contain a [diverging expression](../divergence.md#r-divergence.diverging-expressions), unless that expression is a place expression that is not read from.
67+
A block is itself considered to be [diverging](../divergence.md) if all reachable control flow paths contain a [diverging expression](../divergence.md#r-divergence.diverging-expressions), unless that expression is a [place expression](../expressions.md#r-expr.place-value.place-memory-location) that is not read from.
6868

6969
```rust,no_run
7070
# fn make<T>() -> T { loop {} }

src/expressions/match-expr.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ The type of the overall `match` expression is the [least upper bound](../type-co
102102
r[expr.match.empty]
103103
If there are no match arms, then the `match` expression is diverging and the type is [`!`](../types/never.md).
104104

105+
> [!EXAMPLE]
106+
```rust
107+
# fn make<T>() -> T { loop {} }
108+
enum Empty {}
109+
110+
fn diverging_match_no_arms() -> ! {
111+
let e: Empty = make();
112+
let
113+
match e {}
114+
}
115+
```
116+
117+
105118
r[expr.match.conditional]
106119
If either the scrutinee expression or all of the match arms diverge, then the entire `match` expression also diverges.
107120

0 commit comments

Comments
 (0)