Simpler lifetimes in static and const

Minimum Rust version: 1.17

In older Rust, you had to explicitly write the 'static lifetime in anystatic or const that needed a lifetime:

2. #![allow(unused_variables)]
3. fn main() {
4. mod foo {
5. const NAME: &'static str = "Ferris";
6. }
7. mod bar {
8. static NAME: &'static str = "Ferris";
9. }
10. }

But 'static is the only possible lifetime there. So Rust now assumes the 'static lifetime,and you don't have to write it out:

2. #![allow(unused_variables)]
3. fn main() {
4. mod foo {
5. const NAME: &str = "Ferris";
6. }
7. mod bar {
8. static NAME: &str = "Ferris";
9. }
10. }

In some situations, this can remove a lot of boilerplate:

2. #![allow(unused_variables)]
3. fn main() {
4. mod foo {
5. // old
6. const NAMES: &'static [&'static str; 2] = &["Ferris", "Bors"];
7. }
8. mod bar {

10. // new
11. const NAMES: &[&str; 2] = &["Ferris", "Bors"];
12. }
13. }