-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
mir::Constant::span is a footgun for mir optimizations #77608
Copy link
Copy link
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-mir-optArea: MIR optimizationsArea: MIR optimizationsE-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-mir-optArea: MIR optimizationsArea: MIR optimizationsE-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The field is part of the
PartialEqimpl, 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
PartialEqand make it skip theSpanfield.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
PartialEqcc @rust-lang/wg-mir-opt