value.rs "ensure_tmp_mut" error
Closed this issue · 3 comments
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 an UnsafeCell
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
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)]