avoid collecting into vecs in some places
This commit is contained in:
parent
2e3581bca9
commit
7a48987006
@ -357,10 +357,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
|
|||||||
|
|
||||||
let ignore_unused_generics = tcx.sess.instrument_coverage_except_unused_generics();
|
let ignore_unused_generics = tcx.sess.instrument_coverage_except_unused_generics();
|
||||||
|
|
||||||
let eligible_def_ids: Vec<DefId> = tcx
|
let eligible_def_ids = tcx.mir_keys(()).iter().filter_map(|local_def_id| {
|
||||||
.mir_keys(())
|
|
||||||
.iter()
|
|
||||||
.filter_map(|local_def_id| {
|
|
||||||
let def_id = local_def_id.to_def_id();
|
let def_id = local_def_id.to_def_id();
|
||||||
let kind = tcx.def_kind(def_id);
|
let kind = tcx.def_kind(def_id);
|
||||||
// `mir_keys` will give us `DefId`s for all kinds of things, not
|
// `mir_keys` will give us `DefId`s for all kinds of things, not
|
||||||
@ -374,14 +371,13 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(local_def_id.to_def_id())
|
Some(local_def_id.to_def_id())
|
||||||
})
|
});
|
||||||
.collect();
|
|
||||||
|
|
||||||
let codegenned_def_ids = codegenned_and_inlined_items(tcx);
|
let codegenned_def_ids = codegenned_and_inlined_items(tcx);
|
||||||
|
|
||||||
// For each `DefId` that should have coverage instrumentation but wasn't
|
// For each `DefId` that should have coverage instrumentation but wasn't
|
||||||
// codegenned, add it to the function coverage map as an unused function.
|
// codegenned, add it to the function coverage map as an unused function.
|
||||||
for def_id in eligible_def_ids.into_iter().filter(|id| !codegenned_def_ids.contains(id)) {
|
for def_id in eligible_def_ids.filter(|id| !codegenned_def_ids.contains(id)) {
|
||||||
// Skip any function that didn't have coverage data added to it by the
|
// Skip any function that didn't have coverage data added to it by the
|
||||||
// coverage instrumentor.
|
// coverage instrumentor.
|
||||||
let body = tcx.instance_mir(ty::InstanceDef::Item(def_id));
|
let body = tcx.instance_mir(ty::InstanceDef::Item(def_id));
|
||||||
|
@ -860,10 +860,7 @@ fn report_ambiguous_associated_type(
|
|||||||
traits with associated type `{name}`, you could use the \
|
traits with associated type `{name}`, you could use the \
|
||||||
fully-qualified path",
|
fully-qualified path",
|
||||||
),
|
),
|
||||||
traits
|
traits.iter().map(|trait_str| format!("<Example as {trait_str}>::{name}")),
|
||||||
.iter()
|
|
||||||
.map(|trait_str| format!("<Example as {trait_str}>::{name}"))
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2156,10 +2156,7 @@ fn report_private_fields(
|
|||||||
err.span_suggestions(
|
err.span_suggestions(
|
||||||
span.shrink_to_hi().with_hi(expr_span.hi()),
|
span.shrink_to_hi().with_hi(expr_span.hi()),
|
||||||
"you might have meant to use an associated function to build this type",
|
"you might have meant to use an associated function to build this type",
|
||||||
items
|
items.iter().map(|(_, name, args)| suggestion(name, *args)),
|
||||||
.iter()
|
|
||||||
.map(|(_, name, args)| suggestion(name, *args))
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1884,10 +1884,7 @@ fn suggest_alternative_construction_methods(
|
|||||||
err.span_suggestions_with_style(
|
err.span_suggestions_with_style(
|
||||||
path_span.shrink_to_hi().with_hi(call_span.hi()),
|
path_span.shrink_to_hi().with_hi(call_span.hi()),
|
||||||
"you might have meant to use an associated function to build this type",
|
"you might have meant to use an associated function to build this type",
|
||||||
items
|
items.iter().map(|(_, name, len)| suggestion(name, *len)),
|
||||||
.iter()
|
|
||||||
.map(|(_, name, len)| suggestion(name, *len))
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
SuggestionStyle::ShowAlways,
|
SuggestionStyle::ShowAlways,
|
||||||
);
|
);
|
||||||
|
@ -57,7 +57,7 @@ fn clone_pending(&self) -> Vec<PredicateObligation<'tcx>> {
|
|||||||
|
|
||||||
fn take_pending(&mut self) -> Vec<PredicateObligation<'tcx>> {
|
fn take_pending(&mut self) -> Vec<PredicateObligation<'tcx>> {
|
||||||
let mut obligations = mem::take(&mut self.pending);
|
let mut obligations = mem::take(&mut self.pending);
|
||||||
obligations.extend(self.overflowed.drain(..));
|
obligations.append(&mut self.overflowed);
|
||||||
obligations
|
obligations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user