summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/issue-27868.rs
blob: e436b22dbaad45ebe3edb296bd2f565c6b8d5d82 (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
// Regression test for issue #27868

use std::ops::AddAssign;

struct MyVec<T>(Vec<T>);

impl <T> Drop for MyVec<T> {
    fn drop(&mut self) {
        println!("Being dropped.");
    }
}

impl<T> AddAssign<T> for MyVec<T> {
    fn add_assign(&mut self, _elem: T) {
        println!("In add_assign.");
    }
}

fn main() {
    let mut vec = MyVec(vec![0]);
    let mut vecvec = vec![vec];

    vecvec[0] += {
        vecvec = vec![];
        //~^ ERROR cannot assign to `vecvec` because it is borrowed [E0506]
        0
    };
}