-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix misaligned transmute lint. #2418
Fix misaligned transmute lint. #2418
Conversation
This clears up some ambiguous wording within the lint's descriptions, and makes it so that the lint only applies to pointers. This should fix a number of false positives (when the lint was applied to non-pointer types) as well as false negatives (when the lint was applied to two pointers of the same alignment, but whose pointed-to types had differing alignments).
I don't think we should go ahead with this. We should probably remove the lint entirely and create a lint for transmuting references to references, because one should be using raw ptr casts in that case. |
This lint also checks |
No I meant we should forbid transmuting references to references or pointers to pointers and suggest casts instead. And then we can detect casts that go from low to high alignment |
Ah, understood. That seems like a pretty reasonable approach to me as well. |
@devonhollowood do you want to tackle that change? |
@oli-obk Yes, although I probably won't get a chance for another couple weeks, so if someone else wants to jump in and make the change they should feel free to do so. |
@oli-obk I got some free time so I started working on this tonight, and I was wondering if you could clarify something you said earlier:
As far as I know you can't cast to a ref with Also, what is the policy on deprecating old lints? Since it sounds like you want to deprecate |
You can do
We have a collection of deprecated lints in https://github.com/rust-lang-nursery/rust-clippy/blob/master/clippy_lints/src/deprecated_lints.rs |
This clears up some ambiguous wording within the lint's descriptions,
and makes it so that the lint only applies to pointers. This should fix
a number of false positives (when the lint was applied to non-pointer
types) as well as false negatives (when the lint was applied to two
pointers of the same alignment, but whose pointed-to types had differing
alignments). See discussion at #2400.