summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs b/src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
new file mode 100644
index 000000000..3ea05389f
--- /dev/null
+++ b/src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
@@ -0,0 +1,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);
+}