summary refs log tree commit diff
path: root/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs
blob: 3e125869ef1e9272c27fe6336210b1117651d2d2 (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
// Test for #56254. The last example originally failed with the ast checker, was
// accidentally allowed under migrate/nll, then linted against in migrate mode
// but disallowed under NLL. Now, we accept it everywhere.

//ignore-compare-mode-nll
//ignore-compare-mode-polonius

//revisions: base nll

//[migrate2018] edition:2018
//[nll2018] edition:2018

#![cfg_attr(nll, feature(nll))]

fn double_conflicts() {
    let mut v = vec![0, 1, 2];
    let shared = &v;

    v.extend(shared);
    //[base]~^ ERROR cannot borrow `v` as mutable
    //[nll]~^^ ERROR cannot borrow `v` as mutable
}

fn activation_conflict() {
    let mut v = vec![0, 1, 2];

    v.extend(&v);
    //[base]~^ ERROR cannot borrow `v` as mutable
    //[nll]~^^ ERROR cannot borrow `v` as mutable
}

fn reservation_allowed() {
    let mut v = vec![0, 1, 2];
    let shared = &v;

    v.push(shared.len());
}

fn main() {}