]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/drop_through_trait_object_rc.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / drop_through_trait_object_rc.rs
1 trait Foo {}
2
3 struct Bar;
4
5 static mut DROP_CALLED: bool = false;
6
7 impl Drop for Bar {
8     fn drop(&mut self) {
9         unsafe {
10             DROP_CALLED = true;
11         }
12     }
13 }
14
15 impl Foo for Bar {}
16
17 use std::rc::Rc;
18
19 fn main() {
20     let b: Rc<dyn Foo> = Rc::new(Bar);
21     assert!(unsafe { !DROP_CALLED });
22     drop(b);
23     assert!(unsafe { DROP_CALLED });
24 }