]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/init-res-into-things.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // pretty-expanded FIXME #23616
13 #![allow(unknown_features)]
14 #![feature(box_syntax)]
15 #![feature(unsafe_destructor)]
19 // Resources can't be copied, but storing into data structures counts
20 // as a move unless the stored thing is used afterwards.
26 struct BoxR
<'a
> { x: r<'a> }
29 impl<'a
> Drop
for r
<'a
> {
31 self.i
.set(self.i
.get() + 1)
35 fn r(i
: &Cell
<isize>) -> r
{
42 let i
= &Cell
::new(0);
44 let _a
= BoxR {x: r(i)}
;
46 assert_eq
!(i
.get(), 1);
54 let i
= &Cell
::new(0);
58 assert_eq
!(i
.get(), 1);
62 let i
= &Cell
::new(0);
66 assert_eq
!(i
.get(), 1);
70 let i
= &Cell
::new(0);
72 let _a
: Box
<_
> = box r(i
);
74 assert_eq
!(i
.get(), 1);
77 fn test_unique_rec() {
78 let i
= &Cell
::new(0);
80 let _a
: Box
<_
> = box BoxR
{
84 assert_eq
!(i
.get(), 1);