Skip to content

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

Open

Description

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.needs-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.This 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