Skip to content

'static lifetime elision in associated constants should mirror normal non-associated constants #51370

Open
@Boscop

Description

@Boscop

https://play.rust-lang.org/?gist=8fb655fdb61666de91bd38bfedb537b6&version=stable&mode=debug

const A: &str = "A"; // defaults to 'static

trait Foo {
	const S: &str; // should behave the same
}

impl Foo for () {
	const S: &str = "bar";
}

fn main() {}
error[E0106]: missing lifetime specifier
 --> src/main.rs:4:11
  |
4 |     const S: &str; // should behave the same
  |              ^ expected lifetime parameter

error[E0106]: missing lifetime specifier
 --> src/main.rs:8:14
  |
8 |     const S: &str = "bar";
  |              ^ expected lifetime parameter

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamneeds-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions