Use Vec extend instead of repeated pushes in several places
This commit is contained in:
parent
e6b883c74f
commit
883d0a7aa5
5 changed files with 6 additions and 16 deletions
|
@ -329,9 +329,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
|
||||||
fn mir_to_initial_sorted_coverage_spans(&self) -> Vec<CoverageSpan> {
|
fn mir_to_initial_sorted_coverage_spans(&self) -> Vec<CoverageSpan> {
|
||||||
let mut initial_spans = Vec::<CoverageSpan>::with_capacity(self.mir_body.num_nodes() * 2);
|
let mut initial_spans = Vec::<CoverageSpan>::with_capacity(self.mir_body.num_nodes() * 2);
|
||||||
for (bcb, bcb_data) in self.basic_coverage_blocks.iter_enumerated() {
|
for (bcb, bcb_data) in self.basic_coverage_blocks.iter_enumerated() {
|
||||||
for coverage_span in self.bcb_to_initial_coverage_spans(bcb, bcb_data) {
|
initial_spans.extend(self.bcb_to_initial_coverage_spans(bcb, bcb_data));
|
||||||
initial_spans.push(coverage_span);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if initial_spans.is_empty() {
|
if initial_spans.is_empty() {
|
||||||
|
|
|
@ -498,9 +498,7 @@ fn orphan_check_trait_ref<'tcx>(
|
||||||
return Err(OrphanCheckErr::UncoveredTy(input_ty, local_type));
|
return Err(OrphanCheckErr::UncoveredTy(input_ty, local_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
for input_ty in non_local_tys {
|
non_local_spans.extend(non_local_tys.into_iter().map(|input_ty| (input_ty, i == 0)));
|
||||||
non_local_spans.push((input_ty, i == 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If we exit above loop, never found a local type.
|
// If we exit above loop, never found a local type.
|
||||||
debug!("orphan_check_trait_ref: no local type");
|
debug!("orphan_check_trait_ref: no local type");
|
||||||
|
|
|
@ -362,9 +362,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
.infcx
|
.infcx
|
||||||
.probe(|_| self.match_projection_obligation_against_definition_bounds(obligation));
|
.probe(|_| self.match_projection_obligation_against_definition_bounds(obligation));
|
||||||
|
|
||||||
for predicate_index in result {
|
candidates.vec.extend(result.into_iter().map(ProjectionCandidate));
|
||||||
candidates.vec.push(ProjectionCandidate(predicate_index));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
|
/// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
|
||||||
|
|
|
@ -686,9 +686,8 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||||
};
|
};
|
||||||
let mut where_clauses = vec![];
|
let mut where_clauses = vec![];
|
||||||
for (ty, bounds) in types {
|
for (ty, bounds) in types {
|
||||||
for bound in &bounds {
|
where_clauses
|
||||||
where_clauses.push(format!("{}: {}", ty, tcx.def_path_str(*bound)));
|
.extend(bounds.into_iter().map(|bound| format!("{}: {}", ty, tcx.def_path_str(bound))));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for projection in &projections {
|
for projection in &projections {
|
||||||
let p = projection.skip_binder();
|
let p = projection.skip_binder();
|
||||||
|
|
|
@ -904,10 +904,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) -> MigrationWarningReason {
|
) -> MigrationWarningReason {
|
||||||
let mut reasons = MigrationWarningReason::default();
|
let mut reasons = MigrationWarningReason::default();
|
||||||
|
|
||||||
for auto_trait in auto_trait_reasons {
|
reasons.auto_traits.extend(auto_trait_reasons);
|
||||||
reasons.auto_traits.push(auto_trait);
|
|
||||||
}
|
|
||||||
|
|
||||||
reasons.drop_order = drop_order;
|
reasons.drop_order = drop_order;
|
||||||
|
|
||||||
reasons
|
reasons
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue