]> git.lizzy.rs Git - rust.git/blob - src/test/ui/moves/moves-based-on-type-access-to-field.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / moves / moves-based-on-type-access-to-field.rs
1 // Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible.
2 // Also tests that we give a more specific error message.
3
4 struct Foo { f: String, y: isize }
5 fn consume(_s: String) {}
6 fn touch<A>(_a: &A) {}
7
8 fn f20() {
9     let x = vec!["hi".to_string()];
10     consume(x.into_iter().next().unwrap());
11     touch(&x[0]); //~ ERROR use of moved value: `x`
12 }
13
14 fn main() {}