-
Notifications
You must be signed in to change notification settings - Fork 14k
compute temporary scopes when building MIR, not THIR #148706
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
base: master
Are you sure you want to change the base?
Conversation
This removes some unneeded indirection and consolidates the logic for scope resolution.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…try> compute temporary scopes when building MIR, not THIR
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (9de26a5): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.5%, secondary -2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.3%, secondary -4.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 475.809s -> 473.629s (-0.46%) |
| /// The lifetime of this expression if it should be spilled into a | ||
| /// temporary | ||
| pub temp_lifetime: TempLifetime, | ||
| /// The id of the HIR expression whose [temporary scope] should be used for this expression. | ||
| /// | ||
| /// [temporary scope]: https://doc.rust-lang.org/reference/destructors.html#temporary-scopes | ||
| pub temp_scope_id: hir::ItemLocalId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be removed entirely from thir::Expr, and we could use thir::ExprKind::Scopes to set up temporary scopes, but it's a little subtle/inconvenient for certain THIR lowerings (looking at &pin mut here) so for now I've opted to keep it simple.
Based on #148658; only the last commit is new.
This accomplishes two things:
TempLifetimeto every expression.ScopeTreeby only callingScopeTree::temporary_scopewhen building MIR for something that needs to be dropped in a temporary scope.