rust icon indicating copy to clipboard operation
rust copied to clipboard

Let expressions on RHS shouldn't be terminating scopes

Open nathanwhit opened this issue 3 years ago • 1 comments

Fixes #100276.

Before this PR, we were unconditionally marking the RHS of short-circuiting binary expressions as a terminating scope.

In the case of a let chain where the let expression was on the RHS, this meant that temporaries within the let expr would only live until the end of the expression. Since this only affected the RHS, this led to surprising behavior (example).

After this PR, we only mark the RHS as a terminating scope if it is not a let expression.

nathanwhit avatar Oct 14 '22 03:10 nathanwhit

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

rust-highfive avatar Oct 14 '22 03:10 rust-highfive

Thanks @nathanwhit!

@bors r+

wesleywiser avatar Oct 18 '22 19:10 wesleywiser

:pushpin: Commit 3041bc9e71355eea71a5070b7939439fd3cf7e01 has been approved by wesleywiser

It is now in the queue for this repository.

bors avatar Oct 18 '22 19:10 bors