-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add lint against ptr-to-int transmutes in consts #87525
Comments
Cc @rust-lang/wg-const-eval @jhpratt do you want to work on this, or leave this issue open for anyone to pick up? |
Someone else can pick this up, as I've got other priorities for the near future. As I mentioned feel free to use the code linked. It's worth noting that a lint would ideally also catch transmutes that use a union, though that would be quite a bit more difficult I imagine. |
That'll require a lot of complexity, for a case that I assume will be exceedingly rare. So I don't think that is effort, lines of code, and compile time well spent. |
Agreed. Just throwing it out there. |
More context on the lint can be found in the discussion starting at #85769 (comment) |
@rustbot label +A-const-eval |
@rustbot claim |
We do not allow ptr-to-int casts in
const
context, so people might be tempted to do a transmute instead. This will not work, and if they ever actually test their code during CTFE they will get an error, but it might still be good to add an extra layer of defense here (since this is a rather odd corner of the language) and have a lint for this.@jhpratt started working on this, here's a link.
The text was updated successfully, but these errors were encountered: