Kaynağa Gözat

clippy: use std::ptr::with_exposed_provenance_mut instead of transmute (#8794)

Kamil Skalski 2 hafta önce
ebeveyn
işleme
ae15902040
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 2 1
      program-test/src/lib.rs

+ 2 - 1
program-test/src/lib.rs

@@ -72,6 +72,7 @@ use {
         mem::transmute,
         panic::AssertUnwindSafe,
         path::{Path, PathBuf},
+        ptr,
         sync::{
             atomic::{AtomicBool, Ordering},
             Arc, RwLock,
@@ -114,7 +115,7 @@ fn get_invoke_context<'a, 'b>() -> &'a mut InvokeContext<'b, 'b> {
         Some(val) => val,
         None => panic!("Invoke context not set!"),
     });
-    unsafe { transmute::<usize, &mut InvokeContext>(ptr) }
+    unsafe { &mut *ptr::with_exposed_provenance_mut(ptr) }
 }
 
 pub fn invoke_builtin_function(