2017-07-26 20:43:11 -05:00
|
|
|
// produce special borrowck message inside all kinds of loops
|
|
|
|
|
|
|
|
struct FuncWrapper<'a, T : 'a> {
|
|
|
|
func : fn(&'a mut T) -> ()
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, T : 'a> FuncWrapper<'a, T> {
|
|
|
|
fn in_loop(self, arg : &'a mut T) {
|
|
|
|
loop {
|
2017-11-20 06:13:27 -06:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-26 20:43:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn in_while(self, arg : &'a mut T) {
|
2019-06-21 18:30:24 -05:00
|
|
|
while true { //~ WARN denote infinite loops with
|
2017-11-20 06:13:27 -06:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-26 20:43:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn in_for(self, arg : &'a mut T) {
|
|
|
|
let v : Vec<()> = vec![];
|
|
|
|
for _ in v.iter() {
|
2017-11-20 06:13:27 -06:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-26 20:43:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|