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

Module refactors #6062

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

camsteffen
Copy link
Contributor

A set of refactors, mostly around modules.rs to make code DRYer and simpler. Review one commit at a time and note that some commits are prep work for later commits.

@ytmimi
Copy link
Contributor

ytmimi commented Feb 17, 2024

I'd like to land #5611 before taking a look at these changes. I'm not 100% sure if that will impact what you're trying to do here but I wanted to give you a heads up

Make it so the field is only modified through a with_directory function
so that it is easier to follow.
It's a little tricky to follow, but if you trace the code paths for
inline modules and for external modules, this value is never actually
used. This makes two functions more similar so that they can be deduped
in a later commit.
This variant can be factored out fairly easily. It makes things simpler
overall and opens the door for later refactors.
This makes some code DRYer since we don't need to use Cows and have
different code paths for items with different lifetimes.
Defer creating a Module until needed. This is possible now that we are
using arenas, so ast Items have the 'ast lifetime.
At this point it is just redundant with Module.items.
@camsteffen
Copy link
Contributor Author

camsteffen commented Feb 24, 2024

I removed some commits to keep this PR focused on a series of related changes. I also took things a bit further by introducing an arena. I think this ultimately makes things simpler overall. I also added explanations on most individual commit messages.

(I know we're waiting on #5611. It looks like that will be a pretty simple git conflict.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants