Remove RCs from Borrows

This commit is contained in:
Dániel Buga 2021-02-07 22:32:50 +01:00
parent 46f30455f4
commit 5271c628be
3 changed files with 15 additions and 20 deletions

View File

@ -1330,9 +1330,9 @@ dependencies = [
[[package]] [[package]]
name = "git2" name = "git2"
version = "0.13.14" version = "0.13.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "186dd99cc77576e58344ad614fa9bb27bad9d048f85de3ca850c1f4e8b048260" checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"libc", "libc",
@ -1759,9 +1759,9 @@ dependencies = [
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
version = "0.12.16+1.1.0" version = "0.12.18+1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f91b2f931ee975a98155195be8cd82d02e8e029d7d793d2bac1b8181ac97020" checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -5346,7 +5346,7 @@ dependencies = [
"chrono", "chrono",
"lazy_static", "lazy_static",
"matchers", "matchers",
"parking_lot 0.11.0", "parking_lot 0.9.0",
"regex", "regex",
"serde", "serde",
"serde_json", "serde_json",

View File

@ -259,7 +259,7 @@ fn do_mir_borrowck<'a, 'tcx>(
let regioncx = Rc::new(regioncx); let regioncx = Rc::new(regioncx);
let flow_borrows = Borrows::new(tcx, &body, regioncx.clone(), Rc::clone(borrow_set)) let flow_borrows = Borrows::new(tcx, &body, &regioncx, &borrow_set)
.into_engine(tcx, &body) .into_engine(tcx, &body)
.pass_name("borrowck") .pass_name("borrowck")
.iterate_to_fixpoint(); .iterate_to_fixpoint();
@ -303,7 +303,7 @@ fn do_mir_borrowck<'a, 'tcx>(
regioncx: regioncx.clone(), regioncx: regioncx.clone(),
used_mut: Default::default(), used_mut: Default::default(),
used_mut_upvars: SmallVec::new(), used_mut_upvars: SmallVec::new(),
borrow_set: borrow_set.clone(), borrow_set: Rc::clone(&borrow_set),
dominators, dominators,
upvars: Vec::new(), upvars: Vec::new(),
local_names: IndexVec::from_elem(None, &promoted_body.local_decls), local_names: IndexVec::from_elem(None, &promoted_body.local_decls),
@ -333,10 +333,10 @@ fn do_mir_borrowck<'a, 'tcx>(
move_error_reported: BTreeMap::new(), move_error_reported: BTreeMap::new(),
uninitialized_error_reported: Default::default(), uninitialized_error_reported: Default::default(),
errors_buffer, errors_buffer,
regioncx, regioncx: Rc::clone(&regioncx),
used_mut: Default::default(), used_mut: Default::default(),
used_mut_upvars: SmallVec::new(), used_mut_upvars: SmallVec::new(),
borrow_set, borrow_set: Rc::clone(&borrow_set),
dominators, dominators,
upvars, upvars,
local_names, local_names,

View File

@ -11,7 +11,6 @@ use crate::borrow_check::{
use crate::dataflow::{self, fmt::DebugWithContext, GenKill}; use crate::dataflow::{self, fmt::DebugWithContext, GenKill};
use std::fmt; use std::fmt;
use std::rc::Rc;
rustc_index::newtype_index! { rustc_index::newtype_index! {
pub struct BorrowIndex { pub struct BorrowIndex {
@ -30,11 +29,8 @@ pub struct Borrows<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>, body: &'a Body<'tcx>,
borrow_set: Rc<BorrowSet<'tcx>>, borrow_set: &'a BorrowSet<'tcx>,
borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>, borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>,
/// NLL region inference context with which NLL queries should be resolved
_nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>,
} }
struct StackEntry { struct StackEntry {
@ -47,12 +43,12 @@ struct OutOfScopePrecomputer<'a, 'tcx> {
visited: BitSet<mir::BasicBlock>, visited: BitSet<mir::BasicBlock>,
visit_stack: Vec<StackEntry>, visit_stack: Vec<StackEntry>,
body: &'a Body<'tcx>, body: &'a Body<'tcx>,
regioncx: Rc<RegionInferenceContext<'tcx>>, regioncx: &'a RegionInferenceContext<'tcx>,
borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>, borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>,
} }
impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> { impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> {
fn new(body: &'a Body<'tcx>, regioncx: Rc<RegionInferenceContext<'tcx>>) -> Self { fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
OutOfScopePrecomputer { OutOfScopePrecomputer {
visited: BitSet::new_empty(body.basic_blocks().len()), visited: BitSet::new_empty(body.basic_blocks().len()),
visit_stack: vec![], visit_stack: vec![],
@ -147,10 +143,10 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
crate fn new( crate fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>, body: &'a Body<'tcx>,
nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>, nonlexical_regioncx: &'a RegionInferenceContext<'tcx>,
borrow_set: Rc<BorrowSet<'tcx>>, borrow_set: &'a BorrowSet<'tcx>,
) -> Self { ) -> Self {
let mut prec = OutOfScopePrecomputer::new(body, nonlexical_regioncx.clone()); let mut prec = OutOfScopePrecomputer::new(body, nonlexical_regioncx);
for (borrow_index, borrow_data) in borrow_set.iter_enumerated() { for (borrow_index, borrow_data) in borrow_set.iter_enumerated() {
let borrow_region = borrow_data.region.to_region_vid(); let borrow_region = borrow_data.region.to_region_vid();
let location = borrow_data.reserve_location; let location = borrow_data.reserve_location;
@ -163,7 +159,6 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
body, body,
borrow_set, borrow_set,
borrows_out_of_scope_at_location: prec.borrows_out_of_scope_at_location, borrows_out_of_scope_at_location: prec.borrows_out_of_scope_at_location,
_nonlexical_regioncx: nonlexical_regioncx,
} }
} }