-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
mir::Constant::span
is a footgun for mir optimizations
#77608
Comments
The issue also applies to implicit |
So are we going to use the "trivial" fix – adding a custom impl of |
Ideally we'd remove the |
Perhaps we could add a method on |
Only adding a new method that ignores span equality does not remove the footgun though. Other code would still use the PartialEq which still compares unintuitively because of the span. |
I meant that we should remove |
@spastorino Is it okay if I work on this a bit? |
If someone wants to work on this, feel free to reuse my code. I don't remember how useful it is anymore since it has more than 1 year :). Anyway, feel free to contact me on a Zulip topic. |
The field is part of the
PartialEq
impl, and thus two constants that are equal except in their span will compare inequal. This causes problems in #77551 (comment) and #77549 (comment) and possibly in other places.The "trivial" way to resolve this is to manually implement
PartialEq
and make it skip theSpan
field.Downside: now we may cause weird diagnostics after such an optimization has been applied, because if one of the constants is eliminated, all diagnostics are reported on the other diagnostic's site. We'd need a multispan and properly combine it. That will be hard to ensure to happen if we just silently change
PartialEq
cc @rust-lang/wg-mir-opt
The text was updated successfully, but these errors were encountered: