blob: 14f687c23780c080eb1685c9ff47f435b210840d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Test for #56254, we previously allowed the last example on the 2018
// edition. Make sure that we now emit a warning in that case and an error for
// everyone else.
//ignore-compare-mode-nll
//ignore-compare-mode-polonius
//revisions: migrate2015 migrate2018 nll2015 nll2018
//[migrate2018] edition:2018
//[nll2018] edition:2018
#![cfg_attr(any(nll2015, nll2018), feature(nll))]
fn double_conflicts() {
let mut v = vec![0, 1, 2];
let shared = &v;
v.extend(shared);
//[migrate2015]~^ ERROR cannot borrow `v` as mutable
//[nll2015]~^^ ERROR cannot borrow `v` as mutable
//[migrate2018]~^^^ ERROR cannot borrow `v` as mutable
//[nll2018]~^^^^ ERROR cannot borrow `v` as mutable
}
fn activation_conflict() {
let mut v = vec![0, 1, 2];
v.extend(&v);
//[migrate2015]~^ ERROR cannot borrow `v` as mutable
//[nll2015]~^^ ERROR cannot borrow `v` as mutable
//[migrate2018]~^^^ ERROR cannot borrow `v` as mutable
//[nll2018]~^^^^ ERROR cannot borrow `v` as mutable
}
fn reservation_conflict() {
let mut v = vec![0, 1, 2];
let shared = &v;
v.push(shared.len());
//[nll2015]~^ ERROR cannot borrow `v` as mutable
//[nll2018]~^^ ERROR cannot borrow `v` as mutable
//[migrate2015]~^^^ WARNING cannot borrow `v` as mutable
//[migrate2015]~| WARNING may become a hard error in the future
//[migrate2018]~^^^^^^ WARNING cannot borrow `v` as mutable
//[migrate2018]~| WARNING may become a hard error in the future
}
fn main() {}
|