1 use std::cell::RefCell;
4 aliasing_mut_and_shr();
5 aliasing_frz_and_shr();
8 fn aliasing_mut_and_shr() {
9 fn inner(rc: &RefCell<i32>, aliasing: &mut i32) {
11 let _escape_to_raw = rc as *const _;
15 // also turning this into a frozen ref now must work
16 let aliasing = &*aliasing;
18 let _escape_to_raw = rc as *const _; // this must NOT unfreeze
20 let _shr = &*rc; // this must NOT unfreeze
24 let rc = RefCell::new(23);
25 let mut bmut = rc.borrow_mut();
26 inner(&rc, &mut *bmut);
28 assert_eq!(*rc.borrow(), 23+12);
31 fn aliasing_frz_and_shr() {
32 fn inner(rc: &RefCell<i32>, aliasing: &i32) {
34 let _escape_to_raw = rc as *const _; // this must NOT unfreeze
36 let _shr = &*rc; // this must NOT unfreeze
40 let rc = RefCell::new(23);
41 let bshr = rc.borrow();
43 assert_eq!(*rc.borrow(), 23);