2017-07-27 01:43:11 +00: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 12:13:27 +00:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-27 01:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn in_while(self, arg : &'a mut T) {
|
2019-06-21 23:30:24 +00:00
|
|
|
while true { //~ WARN denote infinite loops with
|
2017-11-20 12:13:27 +00:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-27 01:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn in_for(self, arg : &'a mut T) {
|
|
|
|
let v : Vec<()> = vec![];
|
|
|
|
for _ in v.iter() {
|
2017-11-20 12:13:27 +00:00
|
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
2017-07-27 01:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|