1
Fork 0

Rollup merge of #129067 - cuviper:append, r=wesleywiser

Use `append` instead of `extend(drain(..))`

The first commit adds `IndexVec::append` that forwards to `Vec::append`, and uses it in a couple places.

The second commit updates `indexmap` for its new `IndexMap::append`, and also uses that in a couple places.

These changes are similar to what [`clippy::extend_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#/extend_with_drain) would suggest, just for other collection types.
This commit is contained in:
Matthias Krüger 2024-08-15 00:02:27 +02:00 committed by GitHub
commit c582c0c137
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 7 deletions

View file

@ -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,