-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
FunctionDef::set_return_visibility
(#5941)
# Description ## Problem Resolves #5902 ## Summary ## Additional Context There's a catch: if you pass `quote { hello world }` to the method, it doesn't crash. The reason is that when we parse the visibility, if it's not `pub` or one of the other non-private visibilities, we simply assume it's private (in regular code then would come a type or `{` and that's where it would fail to parse). I wanted to error in this case but couldn't: 1. One idea I had was to check if we get a non-empty tokens stream. If that's the case and we don't get a private visibility, it's an error. Well, that worked, but I didn't know how to easily create a `ParserError` for that. 2. Another idea is to have a specific parser to parse this or EOF... but I tried a choice with `TokenKind::Token(Token::EOF)` and when it was EOF, it said it was expecting EOF (kind of confusing). Any ideas about the best way to do this? We could also capture a follow-up issue for this, because merging this unblocks some stuff. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[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
11 changed files
with
156 additions
and
87 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
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.