]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/reborrow-sugg-move-then-borrow.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / reborrow-sugg-move-then-borrow.rs
1 // Tests the suggestion to reborrow the first move site
2 // when we move then borrow a `&mut` ref.
3
4 struct State;
5
6 impl IntoIterator for &mut State {
7     type IntoIter = std::vec::IntoIter<()>;
8     type Item = ();
9
10     fn into_iter(self) -> Self::IntoIter {
11         vec![].into_iter()
12     }
13 }
14
15 fn once(f: impl FnOnce()) {}
16
17 fn fill_memory_blocks_mt(state: &mut State) {
18     for _ in state {}
19     //~^ HELP consider creating a fresh reborrow of `state` here
20     fill_segment(state);
21     //~^ ERROR borrow of moved value: `state`
22 }
23
24 fn fill_segment(state: &mut State) {}
25
26 fn main() {}