# 'static in const and static references

**URL:** https://internals.rust-lang.org/t/static-in-const-and-static-references/671
**Category:** ideas (deprecated)
**Created:** [October 19, 2014, 4:27pm UTC](https://internals.rust-lang.org/t/static-in-const-and-static-references/671 "2014-10-19T16:27:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![petrochenkov](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/petrochenkov/32/2784_2.png) [@petrochenkov](https://internals.rust-lang.org/u/petrochenkov)
#### Post date: [October 19, 2014, 4:27pm UTC](https://internals.rust-lang.org/t/static-in-const-and-static-references/671/1 "2014-10-19T16:27:56Z")

</div>

Why are `'static` lifetimes required to be written explicitly in `const` and `static` references?

```rust
const MY_STRING: &'static str = "Hello world!";
const MY_ARRAY_REF: &'static [int, ..1000] = &[0, ..1000];

```

If I understand the motivation correctly, the types should be written there explicitly for the similar reasons as for function declarations - they represent interfaces and shouldn’t change silently after changes to initializer or function body. But the lifetimes for `const`/`static` references are always `'static` and will not change, can’t they be elided?

These explicit `'static`s were relatively annoying before, with constant strings, but now they are even more annoying, because after introduction of `const` constant arrays have to be written through references.

```rust
const MY_ARRAY1: [int, ..1000] = [0, ..1000]; // Rvalue arrays are bad
static MY_ARRAY2: [int, ..1000] = [0, ..1000]; // `static` arrays can't be used in constant expressions
const MY_ARRAY3: &'static [int, ..1000] = &[0, ..1000]; // OK, but more verbose than necessary

```

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)
#### Post date: [March 25, 2019, 8:23am UTC](https://internals.rust-lang.org/t/static-in-const-and-static-references/671/2 "2019-03-25T08:23:01Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
