]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/closure-drop.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / closure-drop.rs
1 struct Foo<'a>(&'a mut bool);
2
3 impl<'a> Drop for Foo<'a> {
4     fn drop(&mut self) {
5         *self.0 = true;
6     }
7 }
8
9 fn f<T: FnOnce()>(t: T) {
10     t()
11 }
12
13 fn main() {
14     let mut ran_drop = false;
15     {
16         let x = Foo(&mut ran_drop);
17         // this closure never by val uses its captures
18         // so it's basically a fn(&self)
19         // the shim used to not drop the `x`
20         let x = move || {
21             let _val = x;
22         };
23         f(x);
24     }
25     assert!(ran_drop);
26 }