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.
I made the minimal change to the doc for correctness but I welcome ideas for improvement if anyone feels
the below examples should be called out. I suspect that no additional descriptive text is warranted since
no one has noticed this issue before and commented on it.
This change restricts the CallExpression grammar to match rustc and to resolve a grammatical ambiguity.
CallExpression was described as accepting expressions (including ExpressionWithBlock) as a function operand.
However, rustc parses a block followed by a parenthetical expression as a sequence of Statements, not as a function call.
Furthermore, the
Expression ( CallParams? )
grammar leads to an ambiguity as shown:{expression}(param)
This can be parsed as two statements in sequence or as a function call according to the documented grammar.
Or in this example using
if
:if true {String::new} else {String::new}(some_str)
This can be rewritten as an unambiguous CallExpression by wrapping the if block in parenthesis:
(if true {String::new} else {String::new})(some_str)