-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When we turn on NLL migration in the 2018 edition, we need two-phase …
…borrows too! Fix #52967.
- Loading branch information
Showing
2 changed files
with
43 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs
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,32 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// This is a regression test for #52967, where we discovered that in | ||
// the initial deployment of NLL for the 2018 edition, I forgot to | ||
// turn on two-phase-borrows in addition to `-Z borrowck=migrate`. | ||
|
||
// revisions: ast zflags edition | ||
//[zflags]compile-flags: -Z borrowck=migrate -Z two-phase-borrows | ||
//[edition]compile-flags: --edition 2018 | ||
|
||
// run-pass | ||
|
||
fn the_bug() { | ||
let mut stuff = ("left", "right"); | ||
match stuff { | ||
(ref mut left, _) if *left == "left" => { *left = "new left"; } | ||
_ => {} | ||
} | ||
assert_eq!(stuff, ("new left", "right")); | ||
} | ||
|
||
fn main() { | ||
the_bug(); | ||
} |