about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-09-10 22:34:56 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-09-13 23:28:10 +0200
commitefc7d46188c6696ae873b2b71ead7e34fc4501ab (patch)
treef6f45c59f62d441e32a51b2c8f7871adf6fb63df /src/librustc_data_structures
parent539f2083de809b5c8304fe7426655cfeb0e66d5e (diff)
downloadrust-efc7d46188c6696ae873b2b71ead7e34fc4501ab.tar.gz
rust-efc7d46188c6696ae873b2b71ead7e34fc4501ab.zip
Analyse storage liveness and preserve it during generator transformation
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/bitslice.rs5
-rw-r--r--src/librustc_data_structures/indexed_set.rs6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/librustc_data_structures/bitslice.rs b/src/librustc_data_structures/bitslice.rs
index f74af6ee163..7665bfd5b11 100644
--- a/src/librustc_data_structures/bitslice.rs
+++ b/src/librustc_data_structures/bitslice.rs
@@ -132,6 +132,11 @@ pub trait BitwiseOperator {
     fn join(&self, pred1: usize, pred2: usize) -> usize;
 }
 
+pub struct Intersect;
+impl BitwiseOperator for Intersect {
+    #[inline]
+    fn join(&self, a: usize, b: usize) -> usize { a & b }
+}
 pub struct Union;
 impl BitwiseOperator for Union {
     #[inline]
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 47fa21e3bf0..c790463e47a 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -15,7 +15,7 @@ use std::mem;
 use std::ops::{Deref, DerefMut, Range};
 use std::slice;
 use bitslice::{BitSlice, Word};
-use bitslice::{bitwise, Union, Subtract};
+use bitslice::{bitwise, Union, Subtract, Intersect};
 use indexed_vec::Idx;
 
 /// Represents a set (or packed family of sets), of some element type
@@ -164,6 +164,10 @@ impl<T: Idx> IdxSet<T> {
         bitwise(self.words_mut(), other.words(), &Subtract)
     }
 
+    pub fn intersect(&mut self, other: &IdxSet<T>) -> bool {
+        bitwise(self.words_mut(), other.words(), &Intersect)
+    }
+
     pub fn iter(&self) -> Iter<T> {
         Iter {
             cur: None,