]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/without-validation.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / without-validation.rs
1 // When we notice something breaks only without validation, we add a test here.
2 //@compile-flags: -Zmiri-disable-validation
3 use std::cell::*;
4
5 fn refcell_unsize() {
6     let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]);
7     {
8         let mut cellref: RefMut<'_, [i32; 3]> = cell.borrow_mut();
9         cellref[0] = 4;
10         let mut coerced: RefMut<'_, [i32]> = cellref;
11         coerced[2] = 5;
12     }
13     {
14         let comp: &mut [i32] = &mut [4, 2, 5];
15         let cellref: Ref<'_, [i32; 3]> = cell.borrow();
16         assert_eq!(&*cellref, comp);
17         let coerced: Ref<'_, [i32]> = cellref;
18         assert_eq!(&*coerced, comp);
19     }
20 }
21
22 fn main() {
23     refcell_unsize();
24 }