about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2024-08-13 12:29:46 -0700
committerJosh Stone <jistone@redhat.com>2024-08-13 13:40:05 -0700
commit0a34ce49ceab68a75dd34f1e76555396a8b5b2c8 (patch)
treeac3cbd7b5c0b360ced610511485c9a141cb96e54
parent80eb5a8e910e5185d47cdefe3732d839c78a5e7e (diff)
downloadrust-0a34ce49ceab68a75dd34f1e76555396a8b5b2c8.tar.gz
rust-0a34ce49ceab68a75dd34f1e76555396a8b5b2c8.zip
Add and use `IndexVec::append`
-rw-r--r--compiler/rustc_index/src/vec.rs5
-rw-r--r--compiler/rustc_mir_transform/src/inline.rs4
2 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 7438c97eb58..1cb8bc861af 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -188,6 +188,11 @@ impl<I: Idx, T> IndexVec<I, T> {
         let min_new_len = elem.index() + 1;
         self.raw.resize_with(min_new_len, fill_value);
     }
+
+    #[inline]
+    pub fn append(&mut self, other: &mut Self) {
+        self.raw.append(&mut other.raw);
+    }
 }
 
 /// `IndexVec` is often used as a map, so it provides some map-like APIs.
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 324ddc5e799..61fc5fc8816 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -726,7 +726,7 @@ impl<'tcx> Inliner<'tcx> {
 
         // Insert all of the (mapped) parts of the callee body into the caller.
         caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
-        caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
+        caller_body.source_scopes.append(&mut callee_body.source_scopes);
         if self
             .tcx
             .sess
@@ -740,7 +740,7 @@ impl<'tcx> Inliner<'tcx> {
             // still getting consistent results from the mir-opt tests.
             caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
         }
-        caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
+        caller_body.basic_blocks_mut().append(callee_body.basic_blocks_mut());
 
         caller_body[callsite.block].terminator = Some(Terminator {
             source_info: callsite.source_info,