Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated consts cannot elide `'static #41792

Closed
withoutboats opened this issue May 6, 2017 · 4 comments
Closed

Associated consts cannot elide `'static #41792

withoutboats opened this issue May 6, 2017 · 4 comments

Comments

@withoutboats
Copy link
Contributor

#![feature(associated_consts)]

trait Foo {
    const X: &str;
}

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

fn main() {}

https://play.rust-lang.org/?gist=84bbc056b2289ed71e169e8a4b9236df&version=nightly&backtrace=0

rustc 1.19.0-nightly (f4209651e 2017-05-05)
error[E0106]: missing lifetime specifier
 --> <anon>:4:14
  |
4 |     const X: &str;
  |              ^ expected lifetime parameter

error[E0106]: missing lifetime specifier
 --> <anon>:8:14
  |
8 |     const X: &str = "";
  |              ^ expected lifetime parameter

@eddyb

@eddyb
Copy link
Member

eddyb commented May 6, 2017

@withoutboats This was an intentional decision (in the RFC, I believe) that could be relaxed in impl blocks with no lifetime parameters.

@withoutboats
Copy link
Contributor Author

Can associated consts depend on the lifetime variables in scope? Was the decision just to avoid ambiguity?

@eddyb
Copy link
Member

eddyb commented May 6, 2017

I'm not sure, to be honest. rust-lang/rfcs#1623 (comment) is the RFC's conclusion.
cc @rust-lang/lang

@petrochenkov
Copy link
Contributor

Duplicate of #38831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants