Closed enp6 closed 4 months ago
Are you going to fix this undefined behavior?
fn ensure_tmp_mut(&self) -> &mut Value { let cp = self as *const Value; let mp = cp as *mut Value; let me = unsafe { &mut *mp }; return me.ensure_tmp(); }
&mut *mp There is an error prompt here
casting
&T
to&mut T
is undefined behavior, even if the reference is unused, consider instead using anUnsafeCell
for more information, visit https://doc.rust-lang.org/book/ch15-05-interior-mutability.html#[deny(invalid_reference_casting)]
on by defaultrustcClick for full compiler diagnostic value.rs(577, 12): casting happend here
You try add #[allow(invalid_reference_casting)]
@Martinfx
This method works, it compiles successfully without modification! Thanks.
&mut *mp There is an error prompt here
casting
&T
to&mut T
is undefined behavior, even if the reference is unused, consider instead using anUnsafeCell
for more information, visit https://doc.rust-lang.org/book/ch15-05-interior-mutability.html#[deny(invalid_reference_casting)]
on by defaultrustcClick for full compiler diagnostic value.rs(577, 12): casting happend here