]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // run-pass |
2 | ||
3 | #![allow(non_camel_case_types)] | |
4 | ||
1a4d82fc JJ |
5 | use std::cell::Cell; |
6 | ||
223e47cc | 7 | // Make sure that destructors get run on slice literals |
1a4d82fc | 8 | struct foo<'a> { |
c34b1796 | 9 | x: &'a Cell<isize>, |
223e47cc LB |
10 | } |
11 | ||
1a4d82fc JJ |
12 | impl<'a> Drop for foo<'a> { |
13 | fn drop(&mut self) { | |
14 | self.x.set(self.x.get() + 1); | |
223e47cc LB |
15 | } |
16 | } | |
17 | ||
c34b1796 | 18 | fn foo(x: &Cell<isize>) -> foo { |
223e47cc LB |
19 | foo { |
20 | x: x | |
21 | } | |
22 | } | |
23 | ||
24 | pub fn main() { | |
1a4d82fc | 25 | let x = &Cell::new(0); |
223e47cc LB |
26 | { |
27 | let l = &[foo(x)]; | |
1a4d82fc | 28 | assert_eq!(l[0].x.get(), 0); |
223e47cc | 29 | } |
1a4d82fc | 30 | assert_eq!(x.get(), 1); |
223e47cc | 31 | } |