Skip to content

Commit 24fb268

Browse files
authored
Merge pull request #1624 from RalfJung/const-has-no-addr
do not talk about the 'address of a constant'
2 parents beb22c7 + cb74f78 commit 24fb268

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/items/constant-items.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ guaranteed to refer to the same memory address.
1414
The constant declaration defines the constant value in the [value namespace] of the module or block where it is located.
1515

1616
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].
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
2625
const 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

0 commit comments

Comments
 (0)