Self parameters & C-variadics should be syntactically legal in parenthesized generic argument lists
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Self parameters shouldn't be syntactically forbidden in this position (only semantically) since that diverges from every other place that can contain "function parameters" IINM.
We intentionally allow self parameters in e.g., function pointer types (CC https://github.com/rust-lang/rust/pull/68764, https://github.com/rust-lang/reference/pull/2240#issuecomment-4320921175) and free function items. As it stands, it means we reject X(self), X(&self), X(&mut self) but accept X(&&self), X(&&mut self) for example (the latter are rightfully legal as they're interpreted as X(_: &&self) & X(_: &&mut self) essentially[^1]).
Similarly, for C-variadics. They should be syntactically allowed, too, IMO.
Unifying this would once again simplify the grammar; we shouldn't fight the fact that self parameters & C-variadics are (meant to be) syntactically valid fn params always.
[^1]: They're however always semantically ill-formed as self is a module not a type.
Originally posted by @fmease in https://github.com/rust-lang/rust/issues/158517#issuecomment-5230955069
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
No file or test is named in the issue. Start by locating the parser rules and existing tests for parenthesized generic argument lists, self parameters, and C-variadics; done means the listed forms are syntactically accepted while their existing semantic validity is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100