]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/moves-based-on-type-match-bindings.rs
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / 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 partially moved value: `x`
17     //~^ value borrowed here after partial move
18     //~| partial move occurs because `x.f` has type `String`
19 }
20
21 fn main() {}