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

Use SCC algorithm to handle (mutually) recursive types #157

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Conversation

goffrie
Copy link
Contributor

@goffrie goffrie commented Dec 7, 2023

This changes both set_boxed_if_recursive and calc_impls to calculate strongly connected components, instead of using a naive recursive DFS.

  • This makes the set_boxed_if_recursive calculation linear in the size of the input (instead of needing to traverse the type graph once for each message type). Also, we no longer box recursive fields if there is already a box_it annotation elsewhere that would break the cycle (see MutuallyRecursiveWithBoxedB).
  • For calc_impls this makes the analysis more precise instead of always falling back to !Eq + !Copy when encountering a cycle; e.g. RecursiveOneof now derives Eq etc.

@goffrie goffrie requested a review from cyang1 December 7, 2023 17:07
@goffrie goffrie mentioned this pull request Dec 7, 2023
@goffrie goffrie merged commit 3997f8b into main Dec 14, 2023
23 checks passed
@goffrie goffrie deleted the sccs branch December 14, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant