-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove some unnecessary indirection from AST/HIR structures #30087
Conversation
The HIR changes seem like a no-brainer - r+. However, I'm wary about changing the AST and breaking a whole lot of code for no real gain - is there any motivation I'm missing or is this just tidying up? If the latter, I'd rather not change the AST. cc @eddyb who knows about P |
I should note that some (all?) of these are an artifact of @t and how the ast_map used to work (keeping shared boxes) - now they can disappear. |
I'm not sure how much things it will break. I'm totally ready to revert the AST part, but I'd like to hear some more opinions, because cleanup is still an improvement, albeit modest. |
I think a bunch of Visitors might break. No biggie. Clippy would break, because we use Code using aster on nightly will probably break too (so, serde). Not sure how easy the upgrade is there. I'd expect some speed improvements here, surprised there aren't any. But I'm overall okay with this breakage. |
☔ The latest upstream changes (presumably #29850) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased. |
It seems to me that @Manishearth's list of bustage is enough to justify not landing the AST parts. I'd like to land the HIR parts now but not the AST parts. I do think the AST changes are worthwhile though, and if there is a PR in the future which makes breaking changes to the AST, then perhaps this could be landed at the same time. |
There is such a PR! #29850 landed two days ago. (It is the reason why I had to rebase this PR as well) |
Ah, its a shame we didn't land them together. I think they have to land together (or at least to hit the same nightly) to get the benefit. |
Note that I'm mostly okay with clippy breaking on minor things like this if I know in advance, and can fix it up pretty much immediately. The existence of syntex makes things hard for us, though, since tiny public API changes still break compat when aster/etc are in the picture. Not sure how to handle that. |
Updated with AST changes reverted. |
@bors: r+ |
📌 Commit ca88e9c has been approved by |
I've measured the time/memory consumption before and after - the difference is lost in statistical noise, so it's mostly a code simplification. Sizes of `enum`s are not affected. r? @nrc I wonder if AST/HIR visitors could run faster if `P`s are systematically removed (except for cases where they control `enum` sizes). Theoretically they should. Remaining unnecessary `P`s can't be easily removed because many folders accept `P<X>`s as arguments, but these folders can be converted to accept `X`s instead without loss of efficiency. When I have a mood for some mindless refactoring again, I'll probably try to convert the folders, remove remaining `P`s and measure again.
cc #31487 plugin-[breaking-change] The AST part of #30087 r? @Manishearth
I've measured the time/memory consumption before and after - the difference is lost in statistical noise, so it's mostly a code simplification.
Sizes of
enum
s are not affected.r? @nrc
I wonder if AST/HIR visitors could run faster if
P
s are systematically removed (except for cases where they controlenum
sizes). Theoretically they should.Remaining unnecessary
P
s can't be easily removed because many folders acceptP<X>
s as arguments, but these folders can be converted to acceptX
s instead without loss of efficiency.When I have a mood for some mindless refactoring again, I'll probably try to convert the folders, remove remaining
P
s and measure again.