@@ -1129,8 +1129,8 @@ looks like:
1129
1129
1130
1130
The only exception is that the body of the class constructor begins
1131
1131
with all the class's fields uninitialized, and is allowed to -- in
1132
- fact, must -- initialize all the fields. A special case in the
1133
- typestate pass enforces this invariant.
1132
+ fact, must -- initialize all the fields. The compiler enforces this
1133
+ invariant.
1134
1134
1135
1135
Usually, the class constructor stores its argument or arguments in the
1136
1136
class's named fields. In this case, the ` file_descriptor ` 's data field
@@ -2067,31 +2067,6 @@ A `loop` expression denotes an infinite loop:
2067
2067
loop_expr : "loop" '{' block '}';
2068
2068
~~~~~~~~
2069
2069
2070
- For a block ` b ` , the expression ` loop b ` is semantically equivalent to
2071
- ` while true b ` . However, ` loop ` s differ from ` while ` loops in that the
2072
- typestate analysis pass takes into account that ` loop ` s are infinite.
2073
-
2074
- For example, the following (contrived) function uses a ` loop ` with a
2075
- ` return ` expression:
2076
-
2077
- ~~~~
2078
- fn count() -> bool {
2079
- let mut i = 0;
2080
- loop {
2081
- i += 1;
2082
- if i == 20 { return true; }
2083
- }
2084
- }
2085
- ~~~~
2086
-
2087
- This function compiles, because typestate recognizes that the ` loop `
2088
- never terminates (except non-locally, with ` return ` ), thus there is no
2089
- need to insert a spurious ` fail ` or ` return ` after the ` loop ` . If ` loop `
2090
- were replaced with ` while true ` , the function would be rejected
2091
- because from the compiler's perspective, there would be a control path
2092
- along which ` count ` does not return a value (that is, if the loop
2093
- condition is always false).
2094
-
2095
2070
### Break expressions
2096
2071
2097
2072
~~~~~~~~ {.ebnf .gram}
@@ -2533,7 +2508,7 @@ macro-generated and user-written code can cause unintentional capture.
2533
2508
Future versions of Rust will address these issues.
2534
2509
2535
2510
2536
- # Types and typestates
2511
+ # Type system
2537
2512
2538
2513
## Types
2539
2514
@@ -2959,7 +2934,7 @@ Local variables are not initialized when allocated; the entire frame worth of
2959
2934
local variables are allocated at once, on frame-entry, in an uninitialized
2960
2935
state. Subsequent statements within a function may or may not initialize the
2961
2936
local variables. Local variables can be used only after they have been
2962
- initialized; this condition is guaranteed by the typestate system .
2937
+ initialized; this is enforced by the compiler .
2963
2938
2964
2939
References are created for function arguments. If the compiler can not prove
2965
2940
that the referred-to value will outlive the reference, it will try to set
0 commit comments