You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/block-expr.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,43 +66,49 @@ assert_eq!(5, five);
66
66
r[expr.block.type.diverging]
67
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.
68
68
69
-
```rust
70
-
# #![ feature(never_type) ]
69
+
```rust,no_run
71
70
# fn make<T>() -> T { loop {} }
72
-
letno_control_flow:!= {
71
+
fn no_control_flow() -> ! {
73
72
// There are no conditional statements, so this entire block is diverging.
74
73
loop {}
75
-
};
74
+
}
76
75
77
-
letcontrol_flow_diverging:!= {
76
+
fn control_flow_diverging() -> ! {
78
77
// All paths are diverging, so this entire block is diverging.
79
78
if true {
80
79
loop {}
81
80
} else {
82
81
loop {}
83
82
}
84
-
};
83
+
}
85
84
86
-
letcontrol_flow_not_diverging:() = {
85
+
fn control_flow_not_diverging() -> () {
87
86
// Some paths are not diverging, so this entire block is not diverging.
88
87
if true {
89
88
()
90
89
} else {
91
90
loop {}
92
91
}
93
-
};
92
+
}
94
93
95
94
struct Foo {
96
95
x: !,
97
96
}
98
97
99
-
letfoo=Foo { x:make() };
100
-
letdiverging_place_not_read: () = {
98
+
fn diverging_place_read() -> () {
99
+
let foo = Foo { x: make() };
100
+
let _: ! = {
101
+
// A read of a place expression produces a diverging block
0 commit comments