-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Lint on useless transmutes #441
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
Comments
This absolutely needs a macro check. And it should be |
Well, yeah, match_def_path takes care of that |
I'm trying to implement this, but I'm wondering how to get a |
use the |
Thanks! And to check if two types are equal? |
|
I can't recall if that actually works, or if it computes some arcane form of equality 😝. Worth a try though. If it works, see if it can also catch:
or something. |
It looks like it does a pointer comparison, which sound scary but since it's in an explicit impl I'll believe it. Probably because all the TySs are borrowed from the same cache/arena. |
Otherwise |
rust-lang/rust#11400
We should lint on transmutes between the same type, e.g.
transmute::<u8,u8>(...)
The easiest thing to do here is to find
ExprCall
s which resolve totransmute
, and checking if theexpr_ty
of the argument matches that of the whole call expression.The text was updated successfully, but these errors were encountered: