Fn delegation introduced a theoretical syntax regression (regarding weak keyword `reuse`)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Before the experimental fn delegation (https://github.com/rust-lang/rust/issues/118212, https://github.com/rust-lang/rust/labels/F-fn_delegation) was introduced, the following code used to compile:
fn main() {
let reuse = 0;
reuse < reuse;
}
Now however it leads to
error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `;`
--> src/main.rs:3:18
|
3 | reuse < reuse;
| ^ expected one of 7 possible tokens
despite reuse supposedly being a weak keyword only. Here, the parser likely treats the reuse < reuse as the start of a delegation item because the second reuse can begin a type in theory (it's looking to parse reuse <$type>::$pathtree; / reuse <$type as $traitref>::$pathtree).
Of course, this is very unlikely to be hit in practice. Moreover, I can't really see a good solution (unbounded look-ahead & backtracking is of course not on the table). In any case, the syntax is temporary.
Other example:
fn main() {
let reuse = 0;
reuse << reuse; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `;`
}
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
Reproduce the two Rust examples from the issue and investigate the parser path introduced by experimental fn delegation. Done means preserving these comparison expressions while retaining valid delegation parsing, but the issue does not identify a file, test, or agreed implementation approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100