Skip to content

Commit 676204b

Browse files
authored
Merge pull request #565 from RalfJung/fixme
add FIXME test for coercing &mut to *const
2 parents 173ad36 + d5d1b1e commit 676204b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: tests/run-pass/stacked-borrows.rs

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99
mut_raw_mut();
1010
partially_invalidate_mut();
1111
drop_after_sharing();
12+
direct_mut_to_const_raw();
1213
}
1314

1415
// Deref a raw ptr to access a field of a large struct, where the field
@@ -112,3 +113,13 @@ fn drop_after_sharing() {
112113
let x = String::from("hello!");
113114
let _len = x.len();
114115
}
116+
117+
// Make sure that coercing &mut T to *const T produces a writeable pointer.
118+
fn direct_mut_to_const_raw() {
119+
// FIXME: This is currently disabled, waiting on a fix for <https://github.com/rust-lang/rust/issues/56604>
120+
/*let x = &mut 0;
121+
let y: *const i32 = x;
122+
unsafe { *(y as *mut i32) = 1; }
123+
assert_eq!(*x, 1);
124+
*/
125+
}

0 commit comments

Comments
 (0)