diff options
| author | bors <bors@rust-lang.org> | 2019-02-25 06:27:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-02-25 06:27:35 +0000 |
| commit | 31eb0e2d3c0bfd2e0f5b662d82971c1a203708be (patch) | |
| tree | d54f740779bf1dcdc1d499831dca0aa4e649f504 /src/test/codegen | |
| parent | c1911babed0364ede7dedc646dbca63fac03d5c5 (diff) | |
| parent | 5ffc9197264a07a50bfb27e436fe284ae8c0687c (diff) | |
Auto merge of #57609 - matthewjasper:more-restrictive-match, r=pnkfelix
Use normal mutable borrows in matches
`ref mut` borrows are currently two-phase with NLL enabled. This changes them to be proper mutable borrows. To accommodate this, first the position of fake borrows is changed:
```text
[ 1. Pre-match ]
|
[ (old create fake borrows) ]
[ 2. Discriminant testing -- check discriminants ] <-+
| |
| (once a specific arm is chosen) |
| |
[ (old read fake borrows) ] |
[ 3. Create "guard bindings" for arm ] |
[ (create fake borrows) ] |
| |
[ 4. Execute guard code ] |
[ (read fake borrows) ] --(guard is false)-----------+
|
| (guard results in true)
|
[ 5. Create real bindings and execute arm ]
|
[ Exit match ]
```
The following additional changes are made to accommodate `ref mut` bindings:
* We no longer create fake `Shared` borrows. These borrows are no longer needed for soundness, just to avoid some arguably strange cases.
* `Shallow` borrows no longer conflict with existing borrows, avoiding conflicting access between the guard borrow access and the `ref mut` borrow.
There is some further clean up done in this PR:
* Avoid the "later used here" note for Shallow borrows (since it's not relevant with the message provided)
* Make any use of a two-phase borrow activate it.
* Simplify the cleanup_post_borrowck passes into a single pass.
cc #56254
r? @nikomatsakis
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/match.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/codegen/match.rs b/src/test/codegen/match.rs index 35eac2e7fd5..1b46bb3b25f 100644 --- a/src/test/codegen/match.rs +++ b/src/test/codegen/match.rs @@ -14,12 +14,12 @@ pub fn exhaustive_match(e: E, unit: ()) { // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]] // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]] // CHECK-NEXT: ] +// CHECK: [[OTHERWISE]]: +// CHECK-NEXT: unreachable // CHECK: [[A]]: // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] // CHECK: [[B]]: // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] -// CHECK: [[OTHERWISE]]: -// CHECK-NEXT: unreachable match e { E::A => unit, E::B => unit, |
