Decide on keyword order for `impl`, `mut` restrictions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Both impl and mut restrictions were approved in RFC 3323.
For mut restrictions, the syntax was specified as
StructField :
OuterAttribute*
Visibility?
+ MutRestriction?
IDENTIFIER : Type
TupleField :
OuterAttribute*
Visibility?
+ MutRestriction?
Type
Neither the restrictions RFC nor unsafe fields RFC specify the relative order of the newly-introduced keywords (both appearing between visibility and the identifier/type).
Similarly, the restrictions RFC specifies
Trait :
unsafe?
+ ImplRestriction?
trait IDENTIFIER
GenericParams? ( : TypeParamBounds? )? WhereClause? {
InnerAttribute*
AssociatedItem*
}
as the syntax for impl restrictions.
In my PRs parsing impl restrictions, I put the restriction before unsafety, so as to group it with visibility. This was contrary to what was specified in the RFC and was noticed during review.
Given that I personally authored the restrictions RFC,the initial version of the unsafe fields RFC, and the initial (though ultimately closed) implementation for the restrictions, the fact that I did not know the ordering is concerning. Now that impl restrictions are available on nightly and mut restrictions will be shortly, this is something that should be decided sooner rather than later.
cc tracking issue for restrictions (https://github.com/rust-lang/rust/issues/105077), unsafe fields (https://github.com/rust-lang/rust/issues/132922), r-a request for supporting restrictions (https://github.com/rust-lang/rust-analyzer/issues/22021)
Nominating for the lang team to discuss and hopefully decide. I will note that this presumes that the keywords as originally proposed is the desired syntax, which is explicitly an unresolved question from the RFC.
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 with RFC 3323, the unsafe fields RFC, and the linked PR review discussion; compare their grammar snippets and existing nightly behavior. Done means the lang team records a decision on keyword ordering and whether the proposed syntax remains desired.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100