diff options
| author | Gary Guo <gary@garyguo.net> | 2020-06-15 00:59:03 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2020-06-15 01:09:26 +0100 |
| commit | 4710f85882c08594a900b09c13fbe51ca207daec (patch) | |
| tree | d1ca6d011ee90996e63aeb9b29ed6b8b4dedfd03 | |
| parent | 8121d2e0576e74b23f0019e857b1088197ef8c04 (diff) | |
| download | rust-4710f85882c08594a900b09c13fbe51ca207daec.tar.gz rust-4710f85882c08594a900b09c13fbe51ca207daec.zip | |
Add ui tests for issue 68590 and 72225
| -rw-r--r-- | src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs | 21 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs b/src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs new file mode 100644 index 00000000000..e4436260e70 --- /dev/null +++ b/src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs @@ -0,0 +1,25 @@ +// check-pass + +// rust-lang/rust#68590: confusing diagnostics when reborrowing through DerefMut. + +use std::cell::RefCell; + +struct A; + +struct S<'a> { + a: &'a mut A, +} + +fn take_a(_: &mut A) {} + +fn test<'a>(s: &RefCell<S<'a>>) { + let mut guard = s.borrow_mut(); + take_a(guard.a); + let _s2 = S { a: guard.a }; +} + +fn main() { + let a = &mut A; + let s = RefCell::new(S { a }); + test(&s); +} 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 00000000000..3ea05389f04 --- /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); +} |
