]> git.lizzy.rs Git - rust.git/blob - src/test/ui/moves/moves-based-on-type-match-bindings.rs
Suggest `mem::forget` if `mem::ManuallyDrop::new` isn't used
[rust.git] / src / test / ui / moves / moves-based-on-type-match-bindings.rs
1 // Tests that bindings to move-by-default values trigger moves of the
2 // discriminant. Also tests that the compiler explains the move in
3 // terms of the binding, not the discriminant.
4
5 struct Foo<A> { f: A }
6 fn guard(_s: String) -> bool {panic!()}
7 fn touch<A>(_a: &A) {}
8
9 fn f10() {
10     let x = Foo {f: "hi".to_string()};
11
12     let y = match x {
13         Foo {f} => {}
14     };
15
16     touch(&x); //~ ERROR borrow of moved value: `x`
17     //~^ value borrowed here after partial move
18     //~| move occurs because `x.f` has type `std::string::String`
19 }
20
21 fn main() {}