File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,12 @@ guaranteed to refer to the same memory address.
14
14
The constant declaration defines the constant value in the [ value namespace] of the module or block where it is located.
15
15
16
16
Constants must be explicitly typed. The type must have a ` 'static ` lifetime: any
17
- references in the initializer must have ` 'static ` lifetimes.
17
+ references in the initializer must have ` 'static ` lifetimes. References
18
+ in the type of a constant default to ` 'static ` lifetime; see [ static lifetime
19
+ elision] .
18
20
19
- Constants may refer to the address of other constants, in which case the
20
- address will have elided lifetimes where applicable, otherwise -- in most cases
21
- -- defaulting to the ` static ` lifetime. (See [ static lifetime
22
- elision] .) The compiler is, however, still at liberty to translate the constant
23
- many times, so the address referred to may not be stable.
21
+ A reference to a constant will have ` 'static ` lifetime if the constant value is eligible for
22
+ [ promotion] ; otherwise, a temporary will be created.
24
23
25
24
``` rust
26
25
const BIT1 : u32 = 1 << 0 ;
@@ -118,3 +117,4 @@ fn unused_generic_function<T>() {
118
117
[ _Expression_ ] : ../expressions.md
119
118
[ `Copy` ] : ../special-types-and-traits.md#copy
120
119
[ value namespace ] : ../names/namespaces.md
120
+ [ promotion ] : ../destructors.md#constant-promotion
You can’t perform that action at this time.
0 commit comments