use Rc to store nonlexical_regioncx in Borrows

This commit is contained in:
Niko Matsakis 2017-12-07 04:30:39 -05:00
parent 594c386549
commit 741ef41e41
2 changed files with 5 additions and 3 deletions

View file

@ -25,6 +25,8 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::indexed_set::IdxSetBuf;
use rustc_data_structures::indexed_vec::Idx;
use std::rc::Rc;
use syntax::ast;
use syntax_pos::Span;
@ -202,7 +204,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
&mut flow_inits,
&mdpe.move_data,
);
(Some(regioncx), opt_closure_req)
(Some(Rc::new(regioncx)), opt_closure_req)
} else {
assert!(!tcx.sess.opts.debugging_opts.nll);
(None, None)

View file

@ -66,7 +66,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>,
local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
region_span_map: FxHashMap<RegionKind, Span>,
nonlexical_regioncx: Option<RegionInferenceContext<'tcx>>,
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
}
// Two-phase borrows actually requires two flow analyses; they need
@ -147,7 +147,7 @@ impl ReserveOrActivateIndex {
impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
mir: &'a Mir<'tcx>,
nonlexical_regioncx: Option<RegionInferenceContext<'tcx>>,
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
def_id: DefId,
body_id: Option<hir::BodyId>)
-> Self {