-
Notifications
You must be signed in to change notification settings - Fork 13.5k
mem::transmute warns if transmuting to a type with interior mutability #133653
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
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
f771457
to
053455f
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
Duplicate of #128351 which has |
Since #128351 got closed could we look into reopening this? This is a strict subset of the linting of the other PR but way simpler since it uses the |
Apparently there's a rebased version (#143343). I'm not sure what's the intended approach for this particular lint. I left a comment on that PR referencing this PR, but I'll delegate to that PR's reviewer re. the approach, since I don't have the bandwidth to look into this lint at the moment. |
closes #111229
Now
mem::transmute
warns when transmuting from&T
->&UnsafeCell<T>
(or things that contain it).In reality it warns when transmuting
&impl Freeze
->&impl !Freeze
so it might also warn against things like extern types and so on.transmute_to_interior_mutability
(please check this as I'm not sure if I've done it properly)mutable_transmutes
lint worksmutable_transmutes
so that we can reuse most of the work.tests/ui/consts/const-eval/issue-55541.rs
I've silenced the error... Should we do something about interior mutability and extern types?mem::transmute
Please review the lint text carefully as I don't know how factual that is.
Also, should we do this with raw pointers too? and if so, which cases are worth covering?