First pass at replacing loop
with while true
.
#18553
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proto-RFC here: https://github.com/jkleint/rfcs/blob/remove-loop-keyword/text/0000-remove-loop-keyword.md
This is my first foray into modifying the Rust compiler, so please let me know if I'm way off the mark. I'm not sure this is the right way to do things, it's just to get the conversation started and show it may be simple.
This piggybacks on while-expression parsing the same way as
while let
to recognizewhile true
and call the existingloop
parsing code.I haven't been able to thoroughly test it, but it does seem to compile code like this:
which previously did not compile (
x
possibly uninitialized).I'm unsure of how to use the existing deprecation machinery for a keyword, so I have just put in placeholder warnings, but please advise on how do do that properly. I'm also not sure if the source span properly encompasses the whole while loop.
Fixes #12975.