about summary refs log tree commit diff
path: root/tests/ui/issues/issue-17216.rs
blob: 31b16ef3a2f7b238559268935c08765061b7dc12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ run-pass
#![allow(unused_variables)]
struct Leak<'a> {
    dropped: &'a mut bool
}

impl<'a> Drop for Leak<'a> {
    fn drop(&mut self) {
        *self.dropped = true;
    }
}

fn main() {
    let mut dropped = false;
    {
        let leak = Leak { dropped: &mut dropped };
        for ((), leaked) in Some(((), leak)).into_iter() {}
    }

    assert!(dropped);
}