]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-979.rs
Require Drop impls to have the same constness on its bounds as the bounds on the...
[rust.git] / src / test / ui / issues / issue-979.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3
4 use std::cell::Cell;
5
6 struct r<'a> {
7     b: &'a Cell<isize>,
8 }
9
10 impl<'a> Drop for r<'a> {
11     fn drop(&mut self) {
12         self.b.set(self.b.get() + 1);
13     }
14 }
15
16 fn r(b: &Cell<isize>) -> r {
17     r {
18         b: b
19     }
20 }
21
22 pub fn main() {
23     let b = &Cell::new(0);
24     {
25         let _p = Some(r(b));
26     }
27
28     assert_eq!(b.get(), 1);
29 }