]> git.lizzy.rs Git - rust.git/commitdiff
Encode items before encoding the list of AllocIds
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Wed, 11 Apr 2018 11:31:37 +0000 (13:31 +0200)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Sat, 14 Apr 2018 10:21:46 +0000 (12:21 +0200)
src/librustc_metadata/encoder.rs

index d6c673f550d7288cd748b854218cd12263a40c76..5ecfbd7c6fba3faddfde926ecc8812013d76fab6 100644 (file)
@@ -445,12 +445,24 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot> {
 
         let tcx = self.tcx;
 
+        // Encode the items.
+        i = self.position();
+        let items = self.encode_info_for_items();
+        let item_bytes = self.position() - i;
+
         // Encode the allocation index
         let interpret_alloc_index = {
             let mut interpret_alloc_index = Vec::new();
             let mut n = 0;
+            trace!("beginning to encode alloc ids");
             loop {
                 let new_n = self.interpret_alloc_ids.len();
+                // if we have found new ids, serialize those, too
+                if n == new_n {
+                    // otherwise, abort
+                    break;
+                }
+                trace!("encoding {} further alloc ids", new_n - n);
                 for idx in n..new_n {
                     let id = self.interpret_allocs_inverse[idx];
                     let pos = self.position() as u32;
@@ -461,21 +473,12 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot> {
                         id,
                     ).unwrap();
                 }
-                // if we have found new ids, serialize those, too
-                if n == new_n {
-                    // otherwise, abort
-                    break;
-                }
                 n = new_n;
             }
             self.lazy_seq(interpret_alloc_index)
         };
 
-        // Encode and index the items.
-        i = self.position();
-        let items = self.encode_info_for_items();
-        let item_bytes = self.position() - i;
-
+        // Index the items
         i = self.position();
         let index = items.write_index(&mut self.opaque.cursor);
         let index_bytes = self.position() - i;