]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/suggest-as-ref-on-mut-closure.rs
Do not use a suggestion to change a binding's name to a type
[rust.git] / src / test / ui / borrowck / suggest-as-ref-on-mut-closure.rs
1 // This is not exactly right, yet.
2
3 // Ideally we should be suggesting `as_mut` for the first case,
4 // and suggesting to change `as_ref` to `as_mut` in the second.
5
6 fn x(cb: &mut Option<&mut dyn FnMut()>) {
7     cb.map(|cb| cb());
8     //~^ ERROR cannot move out of `*cb` which is behind a mutable reference
9 }
10
11 fn x2(cb: &mut Option<&mut dyn FnMut()>) {
12     cb.as_ref().map(|cb| cb());
13     //~^ ERROR cannot borrow `*cb` as mutable, as it is behind a `&` reference
14 }
15
16 fn main() {}