diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-17216.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-17216.rs b/src/test/ui/issues/issue-17216.rs new file mode 100644 index 000000000..05baa1bff --- /dev/null +++ b/src/test/ui/issues/issue-17216.rs @@ -0,0 +1,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); +} |