3 // Ensure that invoking a closure counts as a unique immutable borrow
5 type Fn<'a> = Box<dyn FnMut() + 'a>;
8 f: Box<dyn FnMut() + 'a>
11 fn call<F>(mut f: F) where F: FnMut(Fn) {
13 //~^ ERROR: cannot borrow `f` as mutable more than once
24 fn test2<F>(f: &F) where F: FnMut() {
26 //~^ ERROR cannot borrow `*f` as mutable, as it is behind a `&` reference
29 fn test3<F>(f: &mut F) where F: FnMut() {
35 //~^ ERROR: cannot borrow `f.f` as mutable, as it is behind a `&` reference
38 fn test5(f: &mut Test) {
50 fn foo<F>(_: F) where F: FnMut(Box<dyn FnMut(isize)>, isize) {}
51 let s = String::new(); // Capture to make f !Copy
52 let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
56 //~^ ERROR cannot move out of `f` because it is borrowed
58 //~^ ERROR cannot move out of `f`, a captured variable in an `FnMut` closure