Use ptr::cast instead of as casts in several places. (#3507)

`ptr::cast` has the advantage of being unable to silently cast
`*const T` to `*mut T`. This turned up several places that were
performing such casts, which this PR also fixes.
This commit is contained in:
Dan Gohman
2022-01-21 13:03:17 -08:00
committed by GitHub
parent a9d209732d
commit 881c19473d
14 changed files with 64 additions and 58 deletions

View File

@@ -292,7 +292,7 @@ impl State {
let tid = pid; // ThreadId does appear to track underlying thread. Using PID.
for (idx, func) in module.finished_functions() {
let (addr, len) = unsafe { ((*func).as_ptr() as *const u8, (*func).len()) };
let (addr, len) = unsafe { ((*func).as_ptr().cast::<u8>(), (*func).len()) };
if let Some(img) = &dbg_image {
if let Err(err) = self.dump_from_debug_image(img, "wasm", addr, len, pid, tid) {
println!(