]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/mut-borrow-in-loop.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / mut-borrow-in-loop.rs
1 // produce special borrowck message inside all kinds of loops
2
3 struct FuncWrapper<'a, T : 'a> {
4     func : fn(&'a mut T) -> ()
5 }
6
7 impl<'a, T : 'a> FuncWrapper<'a, T> {
8     fn in_loop(self, arg : &'a mut T) {
9         loop {
10             (self.func)(arg) //~ ERROR cannot borrow
11         }
12     }
13
14     fn in_while(self, arg : &'a mut T) {
15         while true { //~ WARN denote infinite loops with
16             (self.func)(arg) //~ ERROR cannot borrow
17         }
18     }
19
20     fn in_for(self, arg : &'a mut T) {
21         let v : Vec<()> = vec![];
22         for _ in v.iter() {
23             (self.func)(arg) //~ ERROR cannot borrow
24         }
25     }
26 }
27
28 fn main() {
29 }