Skip to content
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

Store VariantIdx to distinguish enum variants #85195

Merged
merged 1 commit into from
May 14, 2021

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented May 11, 2021

This saves ~24% of the instructions on the match-stress-enum benchmark, but I'm not 100% sure that this is OK - if we ever compare two constructors across enums (e.g., a Result and an Option), then this is obviously insufficient; I can experiment with continuing to store the DefId for comparison purposes in that case.

This saves ~24% of the instructions on the match-stress-enum benchmark.
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 11, 2021
@Mark-Simulacrum
Copy link
Member Author

@bors try @rust-timer queue

The only PartialEq user is here, but it's not quite clear if that compares across enums ever.

error[E0369]: binary operation `==` cannot be applied to type `&Constructor<'_>`
   --> compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs:821:55
    |
821 |             Variant(_) => used_ctors.iter().any(|c| c == self),
    |                                                     - ^^ ---- &Constructor<'_>
    |                                                     |
    |                                                     &Constructor<'_>
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `&Constructor<'_>`

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 11, 2021
@bors
Copy link
Contributor

bors commented May 11, 2021

⌛ Trying commit e400595 with merge 8dc9aa2668caece29926c3444fa73fdeda459f27...

@bors
Copy link
Contributor

bors commented May 11, 2021

☀️ Try build successful - checks-actions
Build commit: 8dc9aa2668caece29926c3444fa73fdeda459f27 (8dc9aa2668caece29926c3444fa73fdeda459f27)

@rust-timer
Copy link
Collaborator

Queued 8dc9aa2668caece29926c3444fa73fdeda459f27 with parent ba8d7e2, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (8dc9aa2668caece29926c3444fa73fdeda459f27): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 12, 2021
@Mark-Simulacrum
Copy link
Member Author

Cc @Nadrieril

@Nadrieril
Copy link
Member

That's fine, typechecking ensures we only ever compare Constructors for the same type. The rest of the code relies on this in various places already.
LGTM

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 13, 2021

📌 Commit e400595 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 13, 2021
@bors
Copy link
Contributor

bors commented May 14, 2021

⌛ Testing commit e400595 with merge 754d171...

@bors
Copy link
Contributor

bors commented May 14, 2021

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 754d171 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 14, 2021
@bors bors merged commit 754d171 into rust-lang:master May 14, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants