Skip to content

Commit 0a34ce4

Browse files
committed
Add and use IndexVec::append
1 parent 80eb5a8 commit 0a34ce4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_index/src/vec.rs

+5
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ impl<I: Idx, T> IndexVec<I, T> {
188188
let min_new_len = elem.index() + 1;
189189
self.raw.resize_with(min_new_len, fill_value);
190190
}
191+
192+
#[inline]
193+
pub fn append(&mut self, other: &mut Self) {
194+
self.raw.append(&mut other.raw);
195+
}
191196
}
192197

193198
/// `IndexVec` is often used as a map, so it provides some map-like APIs.

compiler/rustc_mir_transform/src/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ impl<'tcx> Inliner<'tcx> {
726726

727727
// Insert all of the (mapped) parts of the callee body into the caller.
728728
caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
729-
caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
729+
caller_body.source_scopes.append(&mut callee_body.source_scopes);
730730
if self
731731
.tcx
732732
.sess
@@ -740,7 +740,7 @@ impl<'tcx> Inliner<'tcx> {
740740
// still getting consistent results from the mir-opt tests.
741741
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
742742
}
743-
caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
743+
caller_body.basic_blocks_mut().append(callee_body.basic_blocks_mut());
744744

745745
caller_body[callsite.block].terminator = Some(Terminator {
746746
source_info: callsite.source_info,

0 commit comments

Comments
 (0)