]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-2735-3.rs
Rollup merge of #91518 - luojia65:rustdoc-riscv-arch, r=GuillaumeGomez
[rust.git] / src / test / ui / issues / issue-2735-3.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3
4 use std::cell::Cell;
5
6 // This test should behave exactly like issue-2735-2
7 struct defer<'a> {
8     b: &'a Cell<bool>,
9 }
10
11 impl<'a> Drop for defer<'a> {
12     fn drop(&mut self) {
13         self.b.set(true);
14     }
15 }
16
17 fn defer(b: &Cell<bool>) -> defer {
18     defer {
19         b: b
20     }
21 }
22
23 pub fn main() {
24     let dtor_ran = &Cell::new(false);
25     defer(dtor_ran);
26     assert!(dtor_ran.get());
27 }