rust/compiler/rustc_mir_build
bors f2348fb29a 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
2023-12-25 04:06:58 +00:00
..
src Auto merge of #119122 - matthewjasper:if-let-guard-scoping, r=TaKO8Ki 2023-12-25 04:06:58 +00:00
Cargo.toml Extract exhaustiveness into its own crate 2023-12-11 11:20:55 +01:00
messages.ftl Extract exhaustiveness into its own crate 2023-12-11 11:20:55 +01:00