1
Fork 0

Add ui tests for issue 68590 and 72225

This commit is contained in:
Gary Guo 2020-06-15 00:59:03 +01:00
parent 8121d2e057
commit 4710f85882
2 changed files with 46 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);
}