summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
blob: 3ea05389f04a0b7ae8c2fdd3c8f31f34e37b1178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// check-pass

// rust-lang/rust#72225: confusing diagnostics when calling FnMut through DerefMut.

use std::cell::RefCell;

struct S {
    f: Box<dyn FnMut()>
}

fn test(s: &RefCell<S>) {
    let mut guard = s.borrow_mut();
    (guard.f)();
}

fn main() {
    let s = RefCell::new(S {
        f: Box::new(|| ())
    });
    test(&s);
}