Decide about generics in arbitrary self types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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
selftype inwfcheck.rsbut 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked arbitrary self types RFC discussions and the experiments in wfcheck.rs. Clarify which generic receiver forms should be accepted or rejected, then record the language decision and identify whether the diagnostics removed by the linked RFC commit need revisiting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100