]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/dataflow.rs
Auto merge of #31144 - jseyfried:remove_import_ordering_restriction, r=nrc
[rust.git] / src / librustc / middle / dataflow.rs
index 72013c533da51415f0159a801994f2391f256dc4..933857269cbcd82f99d218d53b3140b053c66148 100644 (file)
@@ -18,6 +18,7 @@
 use middle::cfg::CFGIndex;
 use middle::ty;
 use std::io;
+use std::mem;
 use std::usize;
 use syntax::ast;
 use syntax::ast_util::IdRange;
@@ -229,7 +230,8 @@ pub fn new(tcx: &'a ty::ctxt<'tcx>,
                oper: O,
                id_range: IdRange,
                bits_per_id: usize) -> DataFlowContext<'a, 'tcx, O> {
-        let words_per_id = (bits_per_id + usize::BITS - 1) / usize::BITS;
+        let usize_bits = mem::size_of::<usize>() * 8;
+        let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
         let num_nodes = cfg.graph.all_nodes().len();
 
         debug!("DataFlowContext::new(analysis_name: {}, id_range={:?}, \
@@ -408,10 +410,11 @@ fn each_bit<F>(&self, words: &[usize], mut f: F) -> bool where
         //! Returns false on the first call to `f` that returns false;
         //! if all calls to `f` return true, then returns true.
 
+        let usize_bits = mem::size_of::<usize>() * 8;
         for (word_index, &word) in words.iter().enumerate() {
             if word != 0 {
-                let base_index = word_index * usize::BITS;
-                for offset in 0..usize::BITS {
+                let base_index = word_index * usize_bits;
+                for offset in 0..usize_bits {
                     let bit = 1 << offset;
                     if (word & bit) != 0 {
                         // NB: we round up the total number of bits
@@ -524,8 +527,7 @@ pub fn propagate(&mut self, cfg: &cfg::CFG, blk: &hir::Block) {
         debug!("{}", {
             let mut v = Vec::new();
             self.pretty_print_to(box &mut v, blk).unwrap();
-            println!("{}", String::from_utf8(v).unwrap());
-            ""
+            String::from_utf8(v).unwrap()
         });
     }
 
@@ -618,7 +620,7 @@ fn bits_to_string(words: &[usize]) -> String {
 
     for &word in words {
         let mut v = word;
-        for _ in 0..usize::BYTES {
+        for _ in 0..mem::size_of::<usize>() {
             result.push(sep);
             result.push_str(&format!("{:02x}", v & 0xFF));
             v >>= 8;
@@ -647,8 +649,9 @@ fn bitwise<Op:BitwiseOperator>(out_vec: &mut [usize],
 fn set_bit(words: &mut [usize], bit: usize) -> bool {
     debug!("set_bit: words={} bit={}",
            mut_bits_to_string(words), bit_str(bit));
-    let word = bit / usize::BITS;
-    let bit_in_word = bit % usize::BITS;
+    let usize_bits = mem::size_of::<usize>() * 8;
+    let word = bit / usize_bits;
+    let bit_in_word = bit % usize_bits;
     let bit_mask = 1 << bit_in_word;
     debug!("word={} bit_in_word={} bit_mask={}", word, bit_in_word, word);
     let oldv = words[word];