Add ui tests for issue 68590 and 72225
This commit is contained in:
parent
8121d2e057
commit
4710f85882
2 changed files with 46 additions and 0 deletions
25
src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs
Normal file
25
src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs
Normal 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);
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue