-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Also consider mem::transmute
with the invalid_reference_casting
lint
#114757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Also consider mem::transmute
with the invalid_reference_casting
lint
#114757
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
0be26d1
to
b517dd5
Compare
Does this also detect if you cast to the mutable reference directly, like |
No, but it's already covered by the |
@bors r+ rollup |
…ence_casting, r=est31 Also consider `mem::transmute` with the `invalid_reference_casting` lint This PR extend the `invalid_reference_casting` lint with regard to the `std::mem::transmute` function. ``` error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:27:16 | LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(&num); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` *I encourage anyone reviewing this PR to do so [without whitespaces](https://github.blog/2011-10-21-github-secrets/#whitespace).*
☀️ Test successful - checks-actions |
Finished benchmarking commit (570601f): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 634.77s -> 634.281s (-0.08%) |
This PR extend the
invalid_reference_casting
lint with regard to thestd::mem::transmute
function.I encourage anyone reviewing this PR to do so without whitespaces.