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

RFC: inherent trait implementation #2375

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@newpavlov
Copy link

newpavlov commented Mar 27, 2018

Continuation of #2309.

Fixes: #1880,#1971

This RFC allows us to write the following code:

#[inherent]
impl Bar for Foo {
    // code
}

Which allows methods from Bar trait to be used on Foo instances without having Bar in the scope.

Rendered

@newpavlov

This comment has been minimized.

Copy link

newpavlov commented Mar 27, 2018

cc @nikomatsakis, @aturon

This RFC assumes that rust-lang/rust#48444 will be treated as a feature and not as a bug.

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Mar 27, 2018

To clarify: #2309 was postponed until we figure out the story for delegation. While you talk about it a bit in this new RFC, it's not clear what in this proposal changes the situation compared to when the lang team previous took up this question. Can you expand on your thinking here?

@newpavlov

This comment has been minimized.

Copy link

newpavlov commented Mar 27, 2018

I was under impression that the previous RFC was closed due to the lack of reaction from @Diggsey to add requested changes, and not postponed. (ctrl+f "postpone" yields zero results)

While I agree that delegation RFC and inherent traits should be discussed together, in my opinion RFCs have orthogonal scopes and similar only in the end effect. As was shown in the text, delegation can be nicely composed with #[inhrent] attribute and there is no need to overload delegation with an additional functionality.

Yes, the new delegation RFC draft mentions inherent trait impls as a possible future extension, but I don't think that using delegate is a correct approach here. Also in my opinion inherent trait implementations can have a much bigger impact on the ecosystem (including stdlib and core) than the delegation RFC, thus it should consider as one of the main topics and not as a vague future extension.

@Diggsey

This comment has been minimized.

Copy link
Contributor

Diggsey commented Mar 27, 2018

@newpavlov I don't think that's an accurate assessment. The RFC was closed because:

We discussed this in the lang team meeting today, and everyone agreed it would be nice to provide "inherent trait methods" of some sort. However, we also felt that this feature would probably fall out naturally from a solution to the more general problem of trait and method delegation. We'd like to see another RFC for delegation before we accept a feature like this.

ie. the lang team wanted a more general solution

@scottmcm scottmcm added the T-lang label Mar 28, 2018

@newpavlov

This comment has been minimized.

Copy link

newpavlov commented Mar 31, 2018

@Diggsey
Yeah, my mistake. Though by reading discussion of the new version of delegation RFC it looks like this use case is not going to "fall out naturally" any time soon.

@aturon
So should I close this RFC until lang-team decides how inherent traits and delegation will interact with each other or should I leave it to be for now?

@aturon

This comment has been minimized.

Copy link
Member

aturon commented Apr 19, 2018

@newpavlov Sorry for the delay, was out on vacation.

Yes, I think it should probably be closed for the time being, especially since there's now a delegation RFC. Would be good to revisit after Rust 2018 ships!

@dwijnand

This comment has been minimized.

Copy link
Member

dwijnand commented Dec 10, 2018

Where's the delegation RFC? My searches failed to find anything.

@newpavlov

This comment has been minimized.

Copy link

newpavlov commented Dec 10, 2018

@dwijnand #2393

@newpavlov

This comment has been minimized.

Copy link

newpavlov commented Dec 13, 2018

@aturon
How about reopening this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment