]> git.lizzy.rs Git - rust.git/blob - tests/ui/resource-assign-is-not-copy.rs
Do not eagerly recover for bad impl-trait in macros
[rust.git] / tests / ui / resource-assign-is-not-copy.rs
1 // run-pass
2
3 #![allow(non_camel_case_types)]
4 use std::cell::Cell;
5
6 #[derive(Debug)]
7 struct r<'a> {
8     i: &'a Cell<isize>,
9 }
10
11 impl<'a> Drop for r<'a> {
12     fn drop(&mut self) {
13         self.i.set(self.i.get() + 1);
14     }
15 }
16
17 fn r(i: &Cell<isize>) -> r {
18     r {
19         i: i
20     }
21 }
22
23 pub fn main() {
24     let i = &Cell::new(0);
25     // Even though these look like copies, they are guaranteed not to be
26     {
27         let a = r(i);
28         let b = (a, 10);
29         let (c, _d) = b;
30         println!("{:?}", c);
31     }
32     assert_eq!(i.get(), 1);
33 }