-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Syntax error on trait fns with destructured args #2847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It looks like the problem is within The parser looks ahead by 4 tokens for one of the following sequences before parsing a pattern:
Anything else, and it will just attempt to parse a type. To detect anything more complex, it looks as though it needs to perform something close to the actual I haven't seen any other examples of backtracking/"retrying" in this fashion, although I'm not too familiar with the project as a whole. |
Lol, TIL that my first Rust RFC is actually implemented: rust-lang/rfcs#1685 How could I have missed that? I think the best thing to do would be to support only 2018 edition and always parse patterns in arguments as required, removing the old lookahead special case. |
Okay - does rust-analyzer generally not support 2015, or is it an just an acceptable lack of coverage in this case? I'd be happy to put up a PR in the next day or so for this. |
For now, we target 2018, and 2015 where it's not too hard to support. Long
term, of course, we need to support all editions.
|
Trait functions with destructured arguments do not parse successfully. Some examples:
These all parse okay as free-standing functions, or in a type impl-block.
The double-deref example is mentioned here, so apologies if this is a known issue.
Running in VS Code, built from commit ea0ee8e.
The text was updated successfully, but these errors were encountered: