for
loop desugaring treats the loop's trailing expression in unusual way
#61902
Labels
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Namely, it's treated as a semicolon-less statement in a middle of the block.
()
(Do not discern between statements with and without semicolon after lowering to HIR #61753).This is unusual because
Git blame says that the behavior was introduced by @Zoxc in #42265.
We cannot remove this behavior because it appears to be useful and code will break if it's removed.
We can, however, use it in other block constructions for which the block's trailing expression does not represent its result.
if cond { ... } [else { ... }]
if let pat = expr { ... } [else { ... }]
while cond { ... }
while let pat = expr { ... }
for pat in expr { ... }
loop { ... }
[unsafe] { ... }
async { ... }
try { ... }
The text was updated successfully, but these errors were encountered: