Skip to content

stop considering location when computing outlives relationships #50593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 18, 2018
37 changes: 32 additions & 5 deletions src/librustc_data_structures/bitvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::collections::BTreeMap;
use indexed_vec::{Idx, IndexVec};
use std::collections::btree_map::Entry;
use std::marker::PhantomData;
use std::collections::BTreeMap;
use std::iter::FromIterator;
use indexed_vec::{Idx, IndexVec};
use std::marker::PhantomData;

type Word = u128;
const WORD_BITS: usize = 128;
Expand Down Expand Up @@ -317,14 +317,25 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
if read != write {
let (bit_set_read, bit_set_write) = self.vector.pick2_mut(read, write);

for read_val in bit_set_read.iter() {
changed = changed | bit_set_write.insert(read_val);
for read_chunk in bit_set_read.chunks() {
changed = changed | bit_set_write.insert_chunk(read_chunk).any();
}
}

changed
}

/// True if `sub` is a subset of `sup`
pub fn is_subset(&self, sub: R, sup: R) -> bool {
sub == sup || {
let bit_set_sub = &self.vector[sub];
let bit_set_sup = &self.vector[sup];
bit_set_sub
.chunks()
.all(|read_chunk| read_chunk.bits_eq(bit_set_sup.contains_chunk(read_chunk)))
}
}

/// Iterates through all the columns set to true in a given row of
/// the matrix.
pub fn iter<'a>(&'a self, row: R) -> impl Iterator<Item = C> + 'a {
Expand All @@ -346,6 +357,7 @@ pub struct SparseChunk<I> {
}

impl<I: Idx> SparseChunk<I> {
#[inline]
pub fn one(index: I) -> Self {
let index = index.index();
let key_usize = index / 128;
Expand All @@ -358,10 +370,16 @@ impl<I: Idx> SparseChunk<I> {
}
}

#[inline]
pub fn any(&self) -> bool {
self.bits != 0
}

#[inline]
pub fn bits_eq(&self, other: SparseChunk<I>) -> bool {
self.bits == other.bits
}

pub fn iter(&self) -> impl Iterator<Item = I> {
let base = self.key as usize * 128;
let mut bits = self.bits;
Expand Down Expand Up @@ -394,6 +412,10 @@ impl<I: Idx> SparseBitSet<I> {
self.chunk_bits.len() * 128
}

/// Returns a chunk containing only those bits that are already
/// present. You can test therefore if `self` contains all the
/// bits in chunk already by doing `chunk ==
/// self.contains_chunk(chunk)`.
pub fn contains_chunk(&self, chunk: SparseChunk<I>) -> SparseChunk<I> {
SparseChunk {
bits: self.chunk_bits
Expand All @@ -403,6 +425,11 @@ impl<I: Idx> SparseBitSet<I> {
}
}

/// Modifies `self` to contain all the bits from `chunk` (in
/// addition to any pre-existing bits); returns a new chunk that
/// contains only those bits that were newly added. You can test
/// if anything was inserted by invoking `any()` on the returned
/// value.
pub fn insert_chunk(&mut self, chunk: SparseChunk<I>) -> SparseChunk<I> {
if chunk.bits == 0 {
return chunk;
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! This query borrow-checks the MIR to (further) ensure it is not broken.

use borrow_check::nll::region_infer::{RegionCausalInfo, RegionInferenceContext};
use borrow_check::nll::region_infer::RegionInferenceContext;
use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::hir::map::definitions::DefPathData;
Expand Down Expand Up @@ -248,7 +248,6 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
nonlexical_regioncx: regioncx,
used_mut: FxHashSet(),
used_mut_upvars: SmallVec::new(),
nonlexical_cause_info: None,
borrow_set,
dominators,
};
Expand Down Expand Up @@ -367,7 +366,6 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
/// contains the results from region inference and lets us e.g.
/// find out which CFG points are contained in each borrow region.
nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>,
nonlexical_cause_info: Option<RegionCausalInfo>,

/// The set of borrows extracted from the MIR
borrow_set: Rc<BorrowSet<'tcx>>,
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let regioncx = &&self.nonlexical_regioncx;
let mir = self.mir;

if self.nonlexical_cause_info.is_none() {
self.nonlexical_cause_info = Some(regioncx.compute_causal_info(mir));
}

let cause_info = self.nonlexical_cause_info.as_ref().unwrap();
if let Some(cause) = cause_info.why_region_contains_point(borrow.region, context.loc) {
match *cause.root_cause() {
let borrow_region_vid = regioncx.to_region_vid(borrow.region);
if let Some(cause) = regioncx.why_region_contains_point(borrow_region_vid, context.loc) {
match cause {
Cause::LiveVar(local, location) => {
match find_regular_use(mir, regioncx, borrow, location, local) {
Some(p) => {
Expand Down
265 changes: 0 additions & 265 deletions src/librustc_mir/borrow_check/nll/region_infer/dfs.rs

This file was deleted.

Loading