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

subtask of RFC 195: implement associated lifetimes #17842

Closed
pnkfelix opened this issue Oct 7, 2014 · 17 comments
Closed

subtask of RFC 195: implement associated lifetimes #17842

pnkfelix opened this issue Oct 7, 2014 · 17 comments
Labels
A-borrow-checker Area: The borrow checker A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Oct 7, 2014

As a subtask of #17307, we want to implement associated lifetimes at some point.

This blocks the code revisions implied by #17828.

@aturon notes here that this may block 1.0; or at least, we certainly cannot mark libraries associated with #17828 as stable, so the real question is whether such library types need to be stable for 1.0.

@aturon
Copy link
Member

aturon commented Oct 9, 2014

To be clear, there's a P-backcompat-lang issue here: the design intends that lifetimes cannot be used in input position, only in output (associated item) position.

The rationale is that the arguments to a trait are used to drive dispatch; each different set of instantiations can provide a distinct implementation for the same Self type (as if they were different traits). But selecting an impl on the basis of a lifetime doesn't make any sense.

I would say this is P-backcompat-lang, but not necessarily 1.0 -- but we should discuss.

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 9, 2014

Assigning P-high, not 1.0.

@pnkfelix pnkfelix added P-medium Medium priority and removed I-nominated labels Oct 9, 2014
@japaric
Copy link
Member

japaric commented Oct 14, 2014

Assigning P-high, not 1.0.

Shouldn't we at least reserve the lifetime keyword before 1.0?

@apasel422
Copy link
Contributor

Is there any plan to move forward on this? It doesn't appear that the lifetime keyword was reserved.

@aturon
Copy link
Member

aturon commented Jul 27, 2015

@apasel422 I don't know of any concrete plans, though a PR would be welcome.

In terms of keyword reservation, this can likely be handled via "contextual keywords".

@apasel422
Copy link
Contributor

@aturon Thanks. Do you know how associated lifetimes will be referenced? The RFC doesn't appear to depict that syntax.

trait Foo {
    lifetime b; // or is this supposed to be `lifetime 'b;`?
    fn foo(&'Self::b self); // unsure if this is correct
}

@aturon
Copy link
Member

aturon commented Jul 27, 2015

@apasel422 You're right -- the RFC is incomplete on these points. I suspect we'd want a ' in both locations. Probably any implementation should be paired with an amendment to the RFC detailing this syntax (which can then be approved via the normal community process).

@apasel422
Copy link
Contributor

By the way, this issue should be renamed to "subtask of RFC 195", not 59.

@pnkfelix pnkfelix changed the title subtask of RFC 59: implement associated lifetimes subtask of RFC 195: implement associated lifetimes Mar 25, 2016
@brson brson added A-typesystem Area: The type system A-borrow-checker Area: The borrow checker C-enhancement Category: An issue proposing an enhancement or a PR with one. I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 20, 2016
@brson
Copy link
Contributor

brson commented Oct 20, 2016

Is this ever going to happen? P-low? Should this be B-RFC-approved to indicate that it's for completion of an RFC?

@nikomatsakis nikomatsakis added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 20, 2016
@nikomatsakis
Copy link
Contributor

Switching over to lang team; my feeling is that I'd like this to happen, but I also sort of feel like a fresh RFC might be a good idea. Certainly I want this regularly when I have some "meta-parameterization" that is just a bundle of associated types (e.g., trait GraphTypes { type Node; type Edge; ... }, and everything has <G: GraphTypes> so they can name G::Node etc.

@nikomatsakis
Copy link
Contributor

I know @pnkfelix and I have also talked about uses for this.

@nikomatsakis
Copy link
Contributor

Anyway, P-low for sure.

triage: P-low

@rust-highfive rust-highfive added P-low Low priority and removed P-medium Medium priority I-nominated labels Oct 20, 2016
@nikomatsakis
Copy link
Contributor

But I'll leave as nominated to discuss question of whether to have a new RFC.

@aturon
Copy link
Member

aturon commented Oct 22, 2016

@nikomatsakis Why do you think a fresh RFC is needed? Offhand it doesn't seem like there's a ton of wiggle room in the design space; the feature has just never been high enough priority to bother implementing it.

@nikomatsakis
Copy link
Contributor

@aturon well, for example, the existing RFC gives zero examples of using an associated lifetime; based on a quick read, I didn't see an obvious syntax for how you name such a lifetime (is it &T::'x Foo? &'T::x Foo?). There seem to be parsing implications that are probably fine but I haven't fully thought through... (is it ok that we don't know if this is a path that leads to a lifetime until later? probably, but it makes the grammar quite a bit more complex I guess)

@aturon
Copy link
Member

aturon commented Oct 25, 2016

@nikomatsakis Got it, thanks.

Given those gaps, I'd be fine closing this out and requiring a fresh RFC to flesh it out and motivate it more substantially.

@nikomatsakis
Copy link
Contributor

Closing because it needs an RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-typesystem Area: The type system C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants