File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 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.
1414The constant declaration defines the constant value in the [ value namespace] of the module or block where it is located.
1515
1616Constants 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] ;
1820
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.
2423
2524``` rust
2625const BIT1 : u32 = 1 << 0 ;
@@ -118,3 +117,4 @@ fn unused_generic_function<T>() {
118117[ _Expression_ ] : ../expressions.md
119118[ `Copy` ] : ../special-types-and-traits.md#copy
120119[ value namespace ] : ../names/namespaces.md
120+ [ promotion ] : ../destructors.md#constant-promotion
You can’t perform that action at this time.
0 commit comments