提交 4710f858 编写于 作者: G Gary Guo

Add ui tests for issue 68590 and 72225

上级 8121d2e0
// 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);
}
// 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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册