-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103034 - nathanwhit:let-chains-rhs-temporaries, r=we…
…sleywiser Let expressions on RHS shouldn't be terminating scopes 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](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d1b0a5d1f01882f9c89c2194a75eb19f)). After this PR, we only mark the RHS as a terminating scope if it is not a `let` expression.
- Loading branch information
Showing
4 changed files
with
24 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// check-pass | ||
// compile-flags: -Z validate-mir | ||
#![feature(let_chains)] | ||
|
||
fn let_chains(entry: std::io::Result<std::fs::DirEntry>) { | ||
if let Ok(entry) = entry | ||
&& let Some(s) = entry.file_name().to_str() | ||
&& s.contains("") | ||
{} | ||
} | ||
|
||
fn main() {} |
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