Skip to content

Commit 1d37118

Browse files
committed
Update docs for claim
1 parent 9f1444c commit 1d37118

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/rust.texi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,7 @@ effects of the expression's evaluation.
29652965
* Ref.Expr.Alt:: Expression for complex conditional branching.
29662966
* Ref.Expr.Prove:: Expression for static assertion of typestate.
29672967
* Ref.Expr.Check:: Expression for dynamic assertion of typestate.
2968+
* Ref.Expr.Claim:: Expression for static (unsafe) or dynamic assertion of typestate.
29682969
* Ref.Expr.Assert:: Expression for halting the program if a
29692970
boolean condition fails to hold.
29702971
* Ref.Expr.IfCheck:: Expression for dynamic testing of typestate.
@@ -3629,6 +3630,26 @@ fn test() @{
36293630
@}
36303631
@end example
36313632

3633+
@node Ref.Expr.Claim
3634+
@subsection Ref.Expr.Claim
3635+
@c * Ref.Expr.Claim:: Expression for static (unsafe) or dynamic assertion of typestate.
3636+
@cindex Claim expression
3637+
@cindex Typestate system
3638+
3639+
A @code{claim} expression is an unsafe variant on a @code{check} expression
3640+
that is not actually checked at runtime. Thus, using a @code{claim} implies a
3641+
proof obligation to ensure---without compiler assistance---that an assertion
3642+
always holds.
3643+
3644+
With a command-line flag, the compiler can turn all @code{claim} expressions
3645+
into @code{check} expressions, but the default is to not check the assertion
3646+
contained in a @code{claim}.
3647+
3648+
The idea is to use @code{check} during development, with @code{claim}
3649+
providing the freedom to disable a few runtime checks in performance-critical
3650+
locations once code is debugged, while leaving the @code{claim} expressions in
3651+
the code as documentation.
3652+
36323653
@node Ref.Expr.IfCheck
36333654
@subsection Ref.Expr.IfCheck
36343655
@c * Ref.Expr.IfCheck:: Expression for dynamic testing of typestate.

0 commit comments

Comments
 (0)