Skip to content

Commit

Permalink
Add ui tests for issue 68590 and 72225
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Jun 15, 2020
1 parent 8121d2e commit 4710f85
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs
Original file line number Diff line number Diff line change
@@ -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);
}
21 changes: 21 additions & 0 deletions src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4710f85

Please sign in to comment.