1
Fork 0

try to cache region_scope_tree as a query

This commit is contained in:
Ding Xiang Fei 2022-05-25 13:52:32 +08:00
parent b2eba058e6
commit 4c6074fbb0
No known key found for this signature in database
GPG key ID: 3CD748647EEF6359
16 changed files with 30 additions and 42 deletions

View file

@ -108,8 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let_scope_stack.push(remainder_scope);
// Declare the bindings, which may create a source scope.
let remainder_span =
remainder_scope.span(this.tcx, &this.typeck_results.region_scope_tree);
let remainder_span = remainder_scope.span(this.tcx, this.region_scope_tree);
let visibility_scope =
Some(this.new_source_scope(remainder_span, LintLevel::Inherited, None));

View file

@ -700,7 +700,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.cfg.push(block, Statement { source_info, kind: StatementKind::StorageLive(local_id) });
// Altough there is almost always scope for given variable in corner cases
// like #92893 we might get variable with no scope.
if let Some(region_scope) = self.typeck_results.region_scope_tree.var_scope(var.local_id) && schedule_drop{
if let Some(region_scope) = self.region_scope_tree.var_scope(var.local_id) && schedule_drop{
self.schedule_drop(span, region_scope, local_id, DropKind::Storage);
}
Place::from(local_id)
@ -713,7 +713,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
for_guard: ForGuard,
) {
let local_id = self.var_local_id(var, for_guard);
if let Some(region_scope) = self.typeck_results.region_scope_tree.var_scope(var.local_id) {
if let Some(region_scope) = self.region_scope_tree.var_scope(var.local_id) {
self.schedule_drop(span, region_scope, local_id, DropKind::Value);
}
}

View file

@ -398,6 +398,7 @@ struct Builder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
infcx: &'a InferCtxt<'a, 'tcx>,
typeck_results: &'tcx TypeckResults<'tcx>,
region_scope_tree: &'tcx region::ScopeTree,
param_env: ty::ParamEnv<'tcx>,
thir: &'a Thir<'tcx>,
@ -880,6 +881,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
tcx,
infcx,
typeck_results: tcx.typeck_opt_const_arg(def),
region_scope_tree: tcx.region_scope_tree(def.did),
param_env,
def_id: def.did.to_def_id(),
hir_id,

View file

@ -916,8 +916,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
if scope.region_scope == region_scope {
let region_scope_span =
region_scope.span(self.tcx, &self.typeck_results.region_scope_tree);
let region_scope_span = region_scope.span(self.tcx, &self.region_scope_tree);
// Attribute scope exit drops to scope's closing brace.
let scope_end = self.tcx.sess.source_map().end_point(region_scope_span);

View file

@ -72,7 +72,7 @@ impl<'tcx> Cx<'tcx> {
tcx,
thir: Thir::new(),
param_env: tcx.param_env(def.did),
region_scope_tree: &typeck_results.region_scope_tree,
region_scope_tree: tcx.region_scope_tree(def.did),
typeck_results,
rvalue_scopes: &typeck_results.rvalue_scopes,
body_owner: def.did.to_def_id(),