Skip to content

Commit a72d448

Browse files
committed
add mut_below_shr test, and a Stacked Borrows test
1 parent d4a85f6 commit a72d448

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/run-pass/stacked-borrows/stacked-borrows.rs

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn main() {
1616
disjoint_mutable_subborrows();
1717
raw_ref_to_part();
1818
array_casts();
19+
mut_below_shr();
1920
}
2021

2122
// Make sure that reading from an `&mut` does, like reborrowing to `&`,
@@ -186,3 +187,12 @@ fn array_casts() {
186187
let p = &x as *const usize;
187188
assert_eq!(unsafe { *p.add(1) }, 1);
188189
}
190+
191+
/// Transmuting &&i32 to &&mut i32 is fine.
192+
fn mut_below_shr() {
193+
let x = 0;
194+
let y = &x;
195+
let p = unsafe { core::mem::transmute::<&&i32,&&mut i32>(&y) };
196+
let r = &**p;
197+
let _val = *r;
198+
}

0 commit comments

Comments
 (0)