-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ui tests for issue 68590 and 72225
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/test/ui/typeck/issue-68590-reborrow-through-derefmut.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
src/test/ui/typeck/issue-72225-call-fnmut-through-derefmut.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |