about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-25 04:06:58 +0000
committerbors <bors@rust-lang.org>2023-12-25 04:06:58 +0000
commitf2348fb29a49d1bd4b62531a36c685f1961a8f46 (patch)
tree961636a122f097a1bfb97471336291193d0fbe19 /compiler/rustc_pattern_analysis/src/lib.rs
parentb87f649a5de8496df7be2fd272da5f1d42d82087 (diff)
parentd437a111f5c08cd85fb5eebecd9d2112a84610a4 (diff)
downloadrust-f2348fb29a49d1bd4b62531a36c685f1961a8f46.tar.gz
rust-f2348fb29a49d1bd4b62531a36c685f1961a8f46.zip
Auto merge of #119122 - matthewjasper:if-let-guard-scoping, r=TaKO8Ki
Give temporaries in if let guards correct scopes

Temporaries in if-let guards have scopes that escape the match arm, this causes problems because the drops might be for temporaries that are not storage live. This PR changes the scope of temporaries in if-let guards to be limited to the arm:

```rust
_ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
//                Temporary for Some(String::new()) is dropped here ^
```

We also now deduplicate temporaries between copies of the guard created for or-patterns:

```rust
// Only create a single Some(String::new()) temporary variable
_ | _ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
```

This changes MIR building to pass around `ExprId`s rather than `Expr`s so that we have a way to index different expressions.

cc #51114
Closes #116079
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
0 files changed, 0 insertions, 0 deletions