Skip to content

Commit 3d9d0a7

Browse files
bors[bot]CAD97
andauthored
Merge #109
109: Use some ptr::addr_of_mut for taking ptr addr r=lnicola a=CAD97 Relevant to #108, but I'm not certain if it addresses the miri failure or not. (Can't check because of rust-lang/miri#705.) Either way, this is a positive change, as previously we were creating `&mut` to uninitialized memory locations. Co-authored-by: Durham, Christopher <[email protected]>
2 parents 86ee956 + 84de51f commit 3d9d0a7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rowan"
3-
version = "0.13.0-pre.7"
3+
version = "0.13.0-pre.8"
44
authors = ["Aleksey Kladov <[email protected]>"]
55
repository = "https://github.com/rust-analyzer/rowan"
66
license = "MIT OR Apache-2.0"

src/arc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@ impl<H, T> ThinArc<H, T> {
372372
//
373373
// Note that any panics here (i.e. from the iterator) are safe, since
374374
// we'll just leak the uninitialized memory.
375-
ptr::write(&mut ((*ptr).count), count);
376-
ptr::write(&mut ((*ptr).data.header), header);
377-
ptr::write(&mut ((*ptr).data.length), num_items);
375+
ptr::write(ptr::addr_of_mut!((*ptr).count), count);
376+
ptr::write(ptr::addr_of_mut!((*ptr).data.header), header);
377+
ptr::write(ptr::addr_of_mut!((*ptr).data.length), num_items);
378378
if num_items != 0 {
379-
let mut current = (*ptr).data.slice.as_mut_ptr();
379+
let mut current = ptr::addr_of_mut!((*ptr).data.slice) as *mut T;
380380
debug_assert_eq!(current as usize - buffer as usize, slice_offset);
381381
for _ in 0..num_items {
382382
ptr::write(

0 commit comments

Comments
 (0)