You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's no reason to use an unsafe transmute to get a pointer from a reference, and as that code example shows it can easily hide bugs. We should (at least) warn about it.
For &T to *mut T, recommend from_ref+cast_mut, but not auto-applicable because we should comment that it's probably wrong, and they probably want from_mut instead, but that will require larger reworking of the code.
Inspired by #124861, specifically glium/glium@ebdc18e
There's no reason to use an unsafe transmute to get a pointer from a reference, and as that code example shows it can easily hide bugs. We should (at least) warn about it.
&Tto*const T, recommend https://doc.rust-lang.org/std/ptr/fn.from_ref.html (machine-applicable, because it's always right)&mut Tto*mut T, recommend https://doc.rust-lang.org/std/ptr/fn.from_mut.html (machine-applicable, because it's always right)&Tto*mut T, recommendfrom_ref+cast_mut, but not auto-applicable because we should comment that it's probably wrong, and they probably wantfrom_mutinstead, but that will require larger reworking of the code.&mut Tto*const T, recommend https://doc.rust-lang.org/std/ptr/fn.from_mut.html with a note that in a generic context it might also need.cast_const().