Skip to content

internal: stop expanding UseTrees during ItemTree lowering #8997

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 4 commits into from
May 27, 2021
Merged

internal: stop expanding UseTrees during ItemTree lowering #8997

merged 4 commits into from
May 27, 2021

Conversation

jonas-schievink
Copy link
Contributor

Closes #8908

Messy diff, but ItemTree lowering got simpler, since we now have a strict 1-to-1 mapping between ast::Item and ModItem.

The most messy part is mapping a single UseTree back to its ast::UseTree counterpart for diagnostics, but I think the ad-hoc source map built during lowering does the job.

@jonas-schievink
Copy link
Contributor Author

Note that this somewhat regresses memory usage:

before:
Total:               7.57s, 65ginstr, 273mb
after:
Total:               7.64s, 65ginstr, 280mb


#[derive(Debug, Clone, Eq, PartialEq)]
pub enum UseTreeKind {
/// ```ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for ignore, we disable doc tests for all internal crates to speed up compilation.

@matklad
Copy link
Member

matklad commented May 27, 2021

LGTM

but also, mad scientist idea.

what if, to maintain fidelity with original source code and to save memory, we redefine use trees as compressions of original file? Basically, parse the file into SyntaxNode, remove all irrelevant syntax details (whitespace, comments, bodies), serialize back into text? That’s completely unrelated to the PR, but I wonder if that can give us some idea about memory usage?

@matklad
Copy link
Member

matklad commented May 27, 2021

Thinking about this more, I feel that we should switch to flat stubs at one point: #9023

@jonas-schievink
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented May 27, 2021

@bors bors bot merged commit d0a4ba2 into rust-lang:master May 27, 2021
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.

Stop expanding use trees when lowering ItemTrees
2 participants