FnMut not implemented for mutable FnMut implementors #23015
Closed
Description
For example this program does not compile
fn foo<F: FnMut()>(_: F) {}
fn main() {
let mut cb = || {};
foo(&mut cb);
}
foo.rs:5:5: 5:8 error: the trait `core::ops::Fn<()>` is not implemented for the type `&mut [closure foo.rs:4:18: 4:23]` [E0277]
foo.rs:5 foo(&mut cb);
^~~
error: aborting due to previous error
The unfortunate error message is covered by another issue, but this seems like an unfortunate limitation. I tried to implement this but got coherence violations. I also implemented this "halfway" and got compile errors due to legitimate coherence violations which sprang up. I believe we have some hardwired impls of these traits in the compiler, but I'd like to make sure we have our story straight on these.