Skip to content

Commit 52b889c

Browse files
committed
document guarantee about evaluation of associated consts
1 parent 5e8b3f6 commit 52b889c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/expressions/path-expr.md

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ let push_integer = Vec::<i32>::push;
2323
let slice_reverse = <[i32]>::reverse;
2424
```
2525

26+
If the path denotes an associated constant, and if the function containing the expression is executed at runtime,
27+
then the associated constant is guaranteed to be evaluated. This is true even if the path expression occurs in dead code.
28+
In particular, unsafe code inside a function can rely on the fact that all associated constants syntactically
29+
occurring in the function have successfully evaluated (and not panicked).
30+
Note that this is only guaranteed for all currently existing syntactic constructs; in the future, a new
31+
kind of block may be introduced such that constants inside that block are *not* unconditionally guaranteed to be evaluated.
32+
If the function is not executed at runtime, associated constants inside of it may or may not be evaluated.
33+
2634
[_PathInExpression_]: ../paths.md#paths-in-expressions
2735
[_QualifiedPathInExpression_]: ../paths.md#qualified-paths
2836
[place expressions]: ../expressions.md#place-expressions-and-value-expressions

0 commit comments

Comments
 (0)