blob: e9ffb26aba5b72abcfa82485a8a3d63a3b55945d [file] [log] [blame]
Derek Guenther730bdb62014-02-05 22:33:101// 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 Crichton0dc48b42015-01-08 02:53:5811#![feature(box_syntax)]
Patrick Walton090040bf2014-05-06 01:56:4412
Patrick Waltoncd120732012-12-10 19:58:3713struct S {
Huon Wilson0c70ce12015-01-08 10:54:3514 x: Box<isize>,
Patrick Waltoncd120732012-12-10 19:58:3715}
16
Patrick Walton5fb25462013-05-31 22:17:2217impl S {
Huon Wilson0c70ce12015-01-08 10:54:3518 pub fn foo(self) -> isize {
Niko Matsakis0682ad02013-01-10 18:59:5819 self.bar();
P1start02c6ebd2014-09-13 02:03:3420 return *self.x; //~ ERROR use of moved value: `*self.x`
Patrick Waltoncd120732012-12-10 19:58:3721 }
22
Patrick Walton5fb25462013-05-31 22:17:2223 pub fn bar(self) {}
Patrick Waltoncd120732012-12-10 19:58:3724}
25
26fn main() {
Patrick Walton090040bf2014-05-06 01:56:4427 let x = S { x: box 1 };
Brendan Zabarauskas4fc04522014-01-09 10:06:5528 println!("{}", x.foo());
Patrick Waltoncd120732012-12-10 19:58:3729}