use crate::borrow_check::place_ext::PlaceExt;
use rustc::mir::{self, Location, Place, PlaceBase, Body};
-use rustc::ty::TyCtxt;
+use rustc::ty::{self, TyCtxt};
use rustc::ty::RegionVid;
-use rustc_data_structures::bit_set::BitSet;
+use rustc_index::bit_set::BitSet;
use rustc_data_structures::fx::FxHashMap;
-use rustc_data_structures::indexed_vec::{Idx, IndexVec};
+use rustc_index::vec::{Idx, IndexVec};
use crate::dataflow::{BitDenotation, BottomValue, GenKillSet};
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
use std::rc::Rc;
-newtype_index! {
+rustc_index::newtype_index! {
pub struct BorrowIndex {
DEBUG_FORMAT = "bw{}"
}
pub struct Borrows<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
+ param_env: ty::ParamEnv<'tcx>,
borrow_set: Rc<BorrowSet<'tcx>>,
borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>,
crate fn new(
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
+ param_env: ty::ParamEnv<'tcx>,
nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>,
borrow_set: &Rc<BorrowSet<'tcx>>,
) -> Self {
Borrows {
tcx: tcx,
body: body,
+ param_env,
borrow_set: borrow_set.clone(),
borrows_out_of_scope_at_location,
_nonlexical_regioncx: nonlexical_regioncx,
// If the borrowed place is a local with no projections, all other borrows of this
// local must conflict. This is purely an optimization so we don't have to call
// `places_conflict` for every borrow.
- if place.projection.is_none() {
+ if place.projection.is_empty() {
trans.kill_all(other_borrows_of_local);
return;
}
.filter(|&&i| {
places_conflict::places_conflict(
self.tcx,
+ self.param_env,
self.body,
&self.borrow_set.borrows[i].borrowed_place,
place,
debug!("Borrows::statement_effect: stmt={:?}", stmt);
match stmt.kind {
- mir::StatementKind::Assign(ref lhs, ref rhs) => {
- // Make sure there are no remaining borrows for variables
- // that are assigned over.
- self.kill_borrows_on_place(trans, lhs);
-
- if let mir::Rvalue::Ref(_, _, ref place) = **rhs {
+ mir::StatementKind::Assign(box(ref lhs, ref rhs)) => {
+ if let mir::Rvalue::Ref(_, _, ref place) = *rhs {
if place.ignore_borrow(
self.tcx,
self.body,
trans.gen(*index);
}
+
+ // Make sure there are no remaining borrows for variables
+ // that are assigned over.
+ self.kill_borrows_on_place(trans, lhs);
}
mir::StatementKind::StorageDead(local) => {