]> git.proxmox.com Git - rustc.git/blob - src/tools/miri/tests/run-pass/call_drop_through_trait_object_rc.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / miri / tests / run-pass / call_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 { DROP_CALLED = true; }
10 }
11 }
12
13 impl Foo for Bar {}
14
15 use std::rc::Rc;
16
17 fn main() {
18 let b: Rc<Foo> = Rc::new(Bar);
19 assert!(unsafe { !DROP_CALLED });
20 drop(b);
21 assert!(unsafe { DROP_CALLED });
22 }