]> git.lizzy.rs Git - rust.git/blob - tests/ui/moves/moves-based-on-type-access-to-field.rs
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / 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 borrow of moved value: `x`
12 }
13
14 fn main() {}