From b8b4ad597a2eac24452e2e78f7b043805f2bb846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 30 Nov 2018 17:38:31 +0100 Subject: [PATCH] Update region_scope_tree --- src/librustc/arena.rs | 1 + src/librustc/middle/region.rs | 5 ++--- src/librustc/query/mod.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_mir/borrow_check/error_reporting.rs | 5 ++--- src/librustc_mir/hair/cx/mod.rs | 3 +-- src/librustc_typeck/check/generator_interior.rs | 3 +-- src/librustc_typeck/check/regionck.rs | 3 +-- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs index e9751a23f1218..2c975f17dcaa5 100644 --- a/src/librustc/arena.rs +++ b/src/librustc/arena.rs @@ -16,6 +16,7 @@ macro_rules! arena_types { )>, [few] mir_keys: rustc::util::nodemap::DefIdSet, [decode] specialization_graph: rustc::traits::specialization_graph::Graph, + [] region_scope_tree: rustc::middle::region::ScopeTree, ], $tcx); ) } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2b3802388106a..a97b4d7354212 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -12,7 +12,6 @@ use crate::ty; use std::mem; use std::fmt; -use rustc_data_structures::sync::Lrc; use rustc_macros::HashStable; use syntax::source_map; use syntax::ast; @@ -1323,7 +1322,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { } fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> Lrc + -> &'tcx ScopeTree { let closure_base_def_id = tcx.closure_base_def_id(def_id); if closure_base_def_id != def_id { @@ -1365,7 +1364,7 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) ScopeTree::default() }; - Lrc::new(scope_tree) + tcx.arena.alloc(scope_tree) } pub fn provide(providers: &mut Providers<'_>) { diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index c22f11f662e02..4311cfbe2b1d5 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -456,7 +456,7 @@ rustc_queries! { /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body; /// in the case of closures, this will be redirected to the enclosing function. - query region_scope_tree(_: DefId) -> Lrc {} + query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {} query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx> { no_force diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 540f374bcf9dc..65a550b1b8914 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -228,7 +228,7 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> { // Some in `borrowck_fn` and cleared later tables: &'a ty::TypeckTables<'tcx>, - region_scope_tree: Lrc, + region_scope_tree: &'tcx region::ScopeTree, owner_def_id: DefId, diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 12dcea7bd5981..54fecb4ad60d9 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -17,7 +17,6 @@ use rustc::ty::layout::VariantIdx; use rustc::ty::print::Print; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::Idx; -use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, DiagnosticBuilder}; use syntax_pos::Span; use syntax::source_map::CompilerDesugaringKind; @@ -811,7 +810,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &mut self, context: Context, name: &str, - scope_tree: &Lrc, + scope_tree: &'tcx ScopeTree, borrow: &BorrowData<'tcx>, drop_span: Span, borrow_spans: UseSpans, @@ -1000,7 +999,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn report_temporary_value_does_not_live_long_enough( &mut self, context: Context, - scope_tree: &Lrc, + scope_tree: &'tcx ScopeTree, borrow: &BorrowData<'tcx>, drop_span: Span, borrow_spans: UseSpans, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 71c6489d63f0d..7aed0bace8c0b 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -18,7 +18,6 @@ use syntax::ast; use syntax::attr; use syntax::symbol::Symbol; use rustc::hir; -use rustc_data_structures::sync::Lrc; use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] @@ -32,7 +31,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { /// Identity `InternalSubsts` for use with const-evaluation. pub identity_substs: &'gcx InternalSubsts<'gcx>, - pub region_scope_tree: Lrc, + pub region_scope_tree: &'gcx region::ScopeTree, pub tables: &'a ty::TypeckTables<'gcx>, /// This is `Constness::Const` if we are compiling a `static`, diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 7f4b0a96a15ab..df3623ea6fbd1 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -8,7 +8,6 @@ use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir::{self, Pat, PatKind, Expr}; use rustc::middle::region; use rustc::ty::{self, Ty}; -use rustc_data_structures::sync::Lrc; use syntax_pos::Span; use super::FnCtxt; use crate::util::nodemap::FxHashMap; @@ -16,7 +15,7 @@ use crate::util::nodemap::FxHashMap; struct InteriorVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, types: FxHashMap, usize>, - region_scope_tree: Lrc, + region_scope_tree: &'gcx region::ScopeTree, expr_count: usize, } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index a03d33a3ef5bc..353b9ac6cc30c 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -86,7 +86,6 @@ use rustc::ty::{self, Ty}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::{self, PatKind}; -use rustc_data_structures::sync::Lrc; use std::mem; use std::ops::Deref; use std::rc::Rc; @@ -195,7 +194,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub struct RegionCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, - pub region_scope_tree: Lrc, + pub region_scope_tree: &'gcx region::ScopeTree, outlives_environment: OutlivesEnvironment<'tcx>,