Skip to content

Commit ae67917

Browse files
committed
Clarify static / const lifetime extension
What we want to say, for lifetime extension on `static` and `const` items, is that the lifetime is extended to the end of the program when the temporary would be extended, according to our other rules, to a scope outside that of the initializer expression. Let's take the easy way out here and simply refer normatively to the other rule for this.
1 parent 5c7558e commit ae67917

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/destructors.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,7 @@ println!("{}", x);
336336
```
337337

338338
r[destructors.scope.lifetime-extension.static]
339-
Lifetime extension also applies to the top-level scope of `static` and `const` items,
340-
where it makes temporaries live until the end of the program.
341-
For example:
339+
The temporary scopes for expressions in `const` and `static` item initialiizers are sometimes extended until the end of the program following the same rule as in [destructors.scope.lifetime-extension.let]. For example:
342340

343341
```rust
344342
const C: &Vec<i32> = &Vec::new();

0 commit comments

Comments
 (0)