Lone `self` in a method body should resolve to the 'self parameter'
Nobody has claimed this yet.
- Dominant language
- reStructuredText
- Stars
- 497
- Forks
- 41
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 4
Description
In a method body, a path expression consisting only of the keyword self should resolve to the (binding of the) method's 'self parameter'.
I believe at the moment the FLS says this resolves to the containing module.
Example:
struct MyType {
x: (),
}
impl MyType {
fn simple_method(self) {
self.x;
}
}
Looking at the self.x FieldAccessExpression:
The part before the . is an UnqualifiedPathExpression whose single SimplePathSegment is the keyword self.
§14.9.4.2 "Path Expression Resolution" says (in fls_dc0yv4306p82) that we resolve the leftmost (and only) segment using general path resolution.
§14.9.4:12 (fls_ri50nc2dg7c4) says that a path segment which is the keyword self resolves to "the entity of the current module".
I've also filed https://github.com/rust-lang/reference/pull/1427
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 FLS §14.9.4, §14.9.4.2, and the cited anchors fls_ri50nc2dg7c4 and fls_dc0yv4306p82; compare the general path-resolution rule with the method-body example. Done means the specification clearly resolves a lone self path in a method body to the method's self parameter rather than the containing module.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100