Skip to content

Commit 3ee2eb6

Browse files
bogglegraydon
authored andcommitted
doc: added definition of trivial casts to spec
(cf @ignored Expr.Be and #1215 for intended use)
1 parent 4ba3158 commit 3ee2eb6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/rust.texi

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,9 +2954,8 @@ analogous to a @code{become} expression in Newsqueak or Alef.} destroys the
29542954
current function activation frame and replaces it with an activation frame for
29552955
the called function. In other words, @code{be} executes a tail-call. The
29562956
syntactic form of a @code{be} expression is therefore limited to @emph{tail
2957-
position}: its argument must be a @emph{call expression}, and it must be the
2958-
last expression in a block.
2959-
2957+
position}: its argument must be a @emph{call expression} or a @{trivial cast}
2958+
of a @emph{call expression}, and it must be the last expression in a block.
29602959
An example of a @code{be} expression:
29612960
@example
29622961
fn print_loop(n: int) @{
@@ -2971,6 +2970,7 @@ fn print_loop(n: int) @{
29712970
29722971
The above example executes in constant space, replacing each frame with a new
29732972
copy of itself.
2973+
29742974
@end ignore
29752975

29762976

@@ -3001,6 +3001,7 @@ execution and destroying the iterator frame.
30013001
@cindex As expression
30023002
@cindex Cast
30033003
@cindex Typecast
3004+
@cindex Trivial cast
30043005

30053006
Executing an @code{as} expression casts the value on the left-hand side to the
30063007
type on the right-hand side.
@@ -3018,6 +3019,10 @@ fn avg(v: [float]) -> float @{
30183019
@}
30193020
@end example
30203021

3022+
A cast is a @emph{trivial cast} iff the type of the casted expression and the
3023+
target type are identical after replacing all occurences of @code{int},
3024+
@code{uint}, @code{float} with their machine type equivalents of the
3025+
target architecture in both types.
30213026

30223027
@node Ref.Expr.Fail
30233028
@subsection Ref.Expr.Fail

0 commit comments

Comments
 (0)