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.
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 // Tests that bindings to move-by-default values trigger moves of the
12 // discriminant. Also tests that the compiler explains the move in
13 // terms of the binding, not the discriminant.
15 struct Foo<A> { f: A }
16 fn guard(_s: String) -> bool {panic!()}
17 fn touch<A>(_a: &A) {}
20 let x = Foo {f: "hi".to_string()};
26 touch(&x); //~ ERROR use of partially moved value: `x`
27 //~^ value used here after move
28 //~| move occurs because `x.f` has type `std::string::String`