Skip to content

encode generics_of for fields and ty params #87815

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

Merged
merged 3 commits into from
Aug 8, 2021

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Aug 6, 2021

Fixes #87674
Fixes #87603

ICE was caused by calling generics_of on a DefId without any generics_of results. This was happening when we call generics_of on parent DefIds of an unevaluated const when we evaluate it.

r? @lcnr

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 6, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@eddyb
Copy link
Member

eddyb commented Aug 6, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 6, 2021

📌 Commit 8ff2ecc has been approved by eddyb

@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 Aug 6, 2021
@lcnr
Copy link
Contributor

lcnr commented Aug 6, 2021

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned lcnr Aug 6, 2021
@bors
Copy link
Collaborator

bors commented Aug 8, 2021

⌛ Testing commit 8ff2ecc with merge c4c2986...

@bors
Copy link
Collaborator

bors commented Aug 8, 2021

☀️ Test successful - checks-actions
Approved by: eddyb
Pushing c4c2986 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 8, 2021
@bors bors merged commit c4c2986 into rust-lang:master Aug 8, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 8, 2021
@rylev
Copy link
Member

rylev commented Aug 17, 2021

This change seems to have caused regressions (albeit fairly minor) in several real world crates such as diesel, serde, and futures. The regression seems to be happening in the explicit_predicates_of query which I believe this change would likely impact.

As part of the performance triage process, I'm marking this as a performance regression. If you believe this performance regression to be justifiable or once you have an issue or PR that addresses this regression, please mark this PR with the label perf-regression-triaged.

@rustbot label +perf-regression

@rustbot rustbot added the perf-regression Performance regression. label Aug 17, 2021
@eddyb
Copy link
Member

eddyb commented Aug 19, 2021

One workaround, since the behavior should be quite predictable, would be to have a single generics_of query that is implemented in the same way for both local and cross-crate, for all the DefKinds that don't have their own generics, and then defer to the specific generics_of impls past that point.

However, adding two levels of queries may itself cause additional inefficiencies, so perhaps a more straight-forward fix would be to make the cross-crate generics_of not even try to decode the generics for certain DefKinds, and offer up the Generics we expect (i.e. just pointing to their parent).

@Mark-Simulacrum
Copy link
Member

I investigated the suggested fix a little. It seems like it's probably not worth it for the small potential wins -- we'd have to do some pretty large scale refactoring, and for probably not that many DefKinds. It also seems uncertain that we'd end up winning -- decoding the largely empty generics should be pretty fast, I'd expect.

And if we look at cycles:u, with the new significance calculations, not too many benchmarks actually regressed. So I'm going to say this is probably an acceptable loss for the time being, given the correctness fix.

@rustbot label +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Oct 2, 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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

Computing and checking generics of type which uses const generics generics-related ICE: 'called Option::unwrap() on a None value'
9 participants