-
-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Self parameters & C-variadics should be syntactically legal in parenthesized generic argument lists #160797
Copy link
Copy link
Open
Labels
A-grammarArea: The grammar of RustArea: The grammar of RustA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.F-named_fn_trait_parameters`#![feature(named_fn_trait_parameters)]``#![feature(named_fn_trait_parameters)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
Activity
Metadata
Metadata
Assignees
Labels
A-grammarArea: The grammar of RustArea: The grammar of RustA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.F-named_fn_trait_parameters`#![feature(named_fn_trait_parameters)]``#![feature(named_fn_trait_parameters)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
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 #68764, rust-lang/reference#2240 (comment)) and free function items. As it stands, it means we reject
X(self),X(&self),X(&mut self)but acceptX(&&self),X(&&mut self)for example (the latter are rightfully legal as they're interpreted asX(_: &&self)&X(_: &&mut self)essentially1).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.
Originally posted by @fmease in #158517 (comment)
Footnotes
They're however always semantically ill-formed as
selfis a module not a type. ↩