]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // This would previously leak the Box<Trait> because we wouldn't |
2 | // schedule cleanups when auto borrowing trait objects. | |
3 | // This program should be valgrind clean. | |
4 | ||
1a4d82fc JJ |
5 | static mut DROP_RAN: bool = false; |
6 | ||
7 | struct Foo; | |
8 | impl Drop for Foo { | |
9 | fn drop(&mut self) { | |
10 | unsafe { DROP_RAN = true; } | |
11 | } | |
12 | } | |
13 | ||
14 | ||
85aaf69f | 15 | trait Trait { fn dummy(&self) { } } |
1a4d82fc JJ |
16 | impl Trait for Foo {} |
17 | ||
18 | pub fn main() { | |
19 | { | |
f2b60f7d | 20 | let _x: &Trait = &*(Box::new(Foo) as Box<Trait>); |
1a4d82fc JJ |
21 | } |
22 | unsafe { | |
23 | assert!(DROP_RAN); | |
24 | } | |
25 | } |