]> git.lizzy.rs Git - rust.git/commit
Auto merge of #52733 - pnkfelix:issue-51348-make-temp-for-each-candidate-in-arm,...
authorbors <bors@rust-lang.org>
Fri, 27 Jul 2018 11:02:27 +0000 (11:02 +0000)
committerbors <bors@rust-lang.org>
Fri, 27 Jul 2018 11:02:27 +0000 (11:02 +0000)
commit6998b369faf3daf849f538d636bac9eda659fa5a
tree7e5d936229061e5ed7d2f33c8277e13961eba1be
parentb18b9edf006c10f4e08794d31425001401e27a09
parent946264526ca0c4c89233410623f231a385e3be71
Auto merge of #52733 - pnkfelix:issue-51348-make-temp-for-each-candidate-in-arm, r=nikomatsakis

[NLL] make temp for each candidate in `match` arm

In NLL, `ref mut` patterns leverage the two-phase borrow infrastructure to allow the shared borrows within a guard before the "activation" of the mutable borrow when we begin execution of the match arm's body. (There is further discussion of this on PR #50783.)

To accommodate the restrictions we impose on two-phase borrows (namely that there is a one-to-one mapping between each activation and the original initialization), this PR is making separate temps for each candidate pattern. So in an arm like this:
```rust
PatA(_, ref mut ident) |
PatB(ref mut ident) |
PatC(_, _, ref mut ident) |
PatD(ref mut ident) if guard_stuff(ident) => ...
```

instead of 3 temps (two for the guard and one for the arm body), we now have 4 + 2 temps associated with `ident`: one for each candidate plus the actual temp that the guard uses directly, and then the sixth is the temp used in the arm body.

Fix #51348
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/test.rs