Skip to content

Commit d654cd3

Browse files
committed
Review feedback: Added test with control flow merge of two borrows "before activation"
In reality the currently generated MIR has at least one of the activations in a copy that occurs before the merge. But still, good to have a test, in anticipation of that potentially changing...
1 parent b0421fa commit d654cd3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// revisions: lxl nll
12+
//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
13+
//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
14+
15+
fn main() {
16+
let mut a = 0;
17+
let mut b = 0;
18+
let p = if maybe() {
19+
&mut a
20+
} else {
21+
&mut b
22+
};
23+
use_(p);
24+
}
25+
26+
fn maybe() -> bool { false }
27+
fn use_<T>(_: T) { }

0 commit comments

Comments
 (0)