Derek Guenther | 730bdb6 | 2014-02-05 22:33:10 | [diff] [blame] | 1 | // Copyright 2014 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. |
| 4 | // |
| 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. |
| 10 | |
Alex Crichton | 0dc48b4 | 2015-01-08 02:53:58 | [diff] [blame] | 11 | #![feature(box_syntax)] |
Patrick Walton | 090040bf | 2014-05-06 01:56:44 | [diff] [blame] | 12 | |
Patrick Walton | cd12073 | 2012-12-10 19:58:37 | [diff] [blame] | 13 | struct S { |
Huon Wilson | 0c70ce1 | 2015-01-08 10:54:35 | [diff] [blame^] | 14 | x: Box<isize>, |
Patrick Walton | cd12073 | 2012-12-10 19:58:37 | [diff] [blame] | 15 | } |
| 16 | |
Patrick Walton | 5fb2546 | 2013-05-31 22:17:22 | [diff] [blame] | 17 | impl S { |
Huon Wilson | 0c70ce1 | 2015-01-08 10:54:35 | [diff] [blame^] | 18 | pub fn foo(self) -> isize { |
Niko Matsakis | 0682ad0 | 2013-01-10 18:59:58 | [diff] [blame] | 19 | self.bar(); |
P1start | 02c6ebd | 2014-09-13 02:03:34 | [diff] [blame] | 20 | return *self.x; //~ ERROR use of moved value: `*self.x` |
Patrick Walton | cd12073 | 2012-12-10 19:58:37 | [diff] [blame] | 21 | } |
| 22 | |
Patrick Walton | 5fb2546 | 2013-05-31 22:17:22 | [diff] [blame] | 23 | pub fn bar(self) {} |
Patrick Walton | cd12073 | 2012-12-10 19:58:37 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | fn main() { |
Patrick Walton | 090040bf | 2014-05-06 01:56:44 | [diff] [blame] | 27 | let x = S { x: box 1 }; |
Brendan Zabarauskas | 4fc0452 | 2014-01-09 10:06:55 | [diff] [blame] | 28 | println!("{}", x.foo()); |
Patrick Walton | cd12073 | 2012-12-10 19:58:37 | [diff] [blame] | 29 | } |