Skip to content

Commit 11c1baa

Browse files
author
alexrp
committed
Remove remaining references to typestate in the manual.
1 parent 81aef34 commit 11c1baa

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

doc/rust.md

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,8 @@ looks like:
11291129

11301130
The only exception is that the body of the class constructor begins
11311131
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.
11341134

11351135
Usually, the class constructor stores its argument or arguments in the
11361136
class's named fields. In this case, the `file_descriptor`'s data field
@@ -2067,31 +2067,6 @@ A `loop` expression denotes an infinite loop:
20672067
loop_expr : "loop" '{' block '}';
20682068
~~~~~~~~
20692069

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-
20952070
### Break expressions
20962071

20972072
~~~~~~~~{.ebnf .gram}
@@ -2533,7 +2508,7 @@ macro-generated and user-written code can cause unintentional capture.
25332508
Future versions of Rust will address these issues.
25342509

25352510

2536-
# Types and typestates
2511+
# Type system
25372512

25382513
## Types
25392514

@@ -2959,7 +2934,7 @@ Local variables are not initialized when allocated; the entire frame worth of
29592934
local variables are allocated at once, on frame-entry, in an uninitialized
29602935
state. Subsequent statements within a function may or may not initialize the
29612936
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.
29632938

29642939
References are created for function arguments. If the compiler can not prove
29652940
that the referred-to value will outlive the reference, it will try to set

0 commit comments

Comments
 (0)