Description
Over here, @adetaylor gave an update about arbitrary self types that included this bit:
During the preparation of the RFC it was broadly felt that we should ban "generic" self types but we didn't really define what "generic" meant, and I didn't pin it down enough.
Some of the commentary:
- Arbitrary self types v2 rfcs#3519 (comment)
- Arbitrary self types v2 rfcs#3519 (comment)
- Arbitrary self types v2 rfcs#3519 (comment)
- A zulip comment
- I've a feeling there's more which I've been unable to find, including the initial impetus to ban generics from arbitrary self types.
It seems to be widely felt that:
impl SomeType { fn m<R: Deref<Target=Self>>(self: R) {} }would be confusing, but (per those comments) it's actually pretty hard to distinguish that from various legitimate cases for arbitrary self types with generic receivers:
impl SomeType { fn method1(self: MyBox<Self, impl Allocator>) {} fn method2<const ID: u64>(self: ListArc<Self, ID>) {} }I played around with different tests here on the
self
type inwfcheck.rs
but none of them yield the right sort of filter of good/bad cases (which is unsurprising since we haven't quite defined what that means, but I thought I might hit inspiration).From those comment threads, the most concrete proposal (from @joshtriplett) is:
just disallow the case where the top-level receiver type itself is not concrete.
I plan to have a crack at that, unless folks have other thoughts. cc @Nadrieril who had opinions here.
If we do this, I might need to revisit the diagnostics mentioned in the bits of RFC removed by this commit.
We never made a decision about this. Perhaps if we could offer more clarity, it would save @adetaylor some time here, so it may be worth us discussing.
@rustbot labels +T-lang +I-lang-nominated -needs-triage +C-discussion
cc @rust-lang/lang @adetaylor