]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/newtype-struct-drop-run.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / structs-enums / newtype-struct-drop-run.rs
1 // run-pass
2 // Make sure the destructor is run for newtype structs.
3
4 use std::cell::Cell;
5
6 struct Foo<'a>(&'a Cell<isize>);
7
8 impl<'a> Drop for Foo<'a> {
9     fn drop(&mut self) {
10         let Foo(i) = *self;
11         i.set(23);
12     }
13 }
14
15 pub fn main() {
16     let y = &Cell::new(32);
17     {
18         let _x = Foo(y);
19     }
20     assert_eq!(y.get(), 23);
21 }