]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-infer-fnonce.rs
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-infer-fnonce.rs
1 // run-pass
2 // Test that we are able to infer a suitable kind for this closure
3 // that is just called (`FnOnce`).
4
5 use std::mem;
6
7 struct DropMe<'a>(&'a mut i32);
8
9 impl<'a> Drop for DropMe<'a> {
10     fn drop(&mut self) {
11         *self.0 += 1;
12     }
13 }
14
15 fn main() {
16     let mut counter = 0;
17
18     {
19         let drop_me = DropMe(&mut counter);
20         let tick = || mem::drop(drop_me);
21         tick();
22     }
23
24     assert_eq!(counter, 1);
25 }