-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: turbofish operator on path segments (#5603)
# Description ## Problem Part of #5584 ## Summary This PR adds support for parsing turbofishes in any path segments. Turbofish is only still checked when elaborating variables, but only for the last turbofish (like before). For now any other placement of a turbofish will give a type error, but at least they can be parsed now. In later PRs we can make them work in the middle of variables, in constructors, etc. ## Additional Context Right now turbofishes aren't parsed in named typed (for example in a struct pattern). The reason is that if I use `path()` instead of `path_no_turbofish()` then the parser gives a stack overflow and I'm not sure why. Maybe it's because `parse_type()` is used recursively, I'm not sure... but these stack overflow errors are kind of hard to diagnose. In any case we can parse those later on once we decide to support turbofish in struct patterns. Also, because a `Path`'s segments changed from `Vec<Ident>` to `Vec<PathSegment>` some functions, like `Path::last_segment()` made more sense if they returned `PathSegment` instead of `Ident`. Then I introduced a bunch of helper functions to reduce some call chains, but also introduced helpers like `last_name()` which is nice because it returns a `&str` where in some cases an unnecessary clone was made (so some refactors/cleanups are included in this PR as part of this feature). ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
28 changed files
with
362 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.