summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/issue-82462.rs
blob: 5a3c64255cc64a1604625314b0b2b5897c815de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct DroppingSlice<'a>(&'a [i32]);

impl Drop for DroppingSlice<'_> {
    fn drop(&mut self) {
        println!("hi from slice");
    }
}

impl DroppingSlice<'_> {
    fn iter(&self) -> std::slice::Iter<'_, i32> {
        self.0.iter()
    }
}

fn main() {
    let mut v = vec![1, 2, 3, 4];
    for x in DroppingSlice(&*v).iter() {
        v.push(*x); //~ERROR
        break;
    }
}