about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-02 12:40:35 +0000
committerbors <bors@rust-lang.org>2018-08-02 12:40:35 +0000
commit5e92bf280b59fe0c187359743d7d430575fa30b1 (patch)
tree843b5459c4daaa25db4e0d1880f6de92cdca54b1 /src/test
parent76aeeefdc2d52830c1381dbce289769112e0c1ef (diff)
parent09a7e64601eb0b9363a5bc1c3fd9dda174a90fc5 (diff)
Auto merge of #52975 - pnkfelix:issue-52967-edition-2018-implies-2-phase-borrows, r=Mark-Simulacrum
NLL migration in the 2018 edition needs two-phase borrows too!

NLL migration in the 2018 edition needs two-phase borrows too!

Fix #52967.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs
new file mode 100644
index 00000000000..c39fff2644d
--- /dev/null
+++ b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs
@@ -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();
+}