mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
30 lines
648 B
Rust
30 lines
648 B
Rust
// 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 {
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
|
}
|
|
}
|
|
|
|
fn in_while(self, arg : &'a mut T) {
|
|
while true { //~ WARN denote infinite loops with
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
|
}
|
|
}
|
|
|
|
fn in_for(self, arg : &'a mut T) {
|
|
let v : Vec<()> = vec![];
|
|
for _ in v.iter() {
|
|
(self.func)(arg) //~ ERROR cannot borrow
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
}
|