mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
create only one vector when winnowing candidates
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(transpose_result)]
|
||||
|
||||
#![recursion_limit="512"]
|
||||
|
||||
|
||||
@@ -1368,8 +1368,7 @@ fn candidate_from_obligation_no_cache<'o>(
|
||||
|
||||
// Winnow, but record the exact outcome of evaluation, which
|
||||
// is needed for specialization. Propagate overflow if it occurs.
|
||||
let candidates: Result<Vec<Option<EvaluatedCandidate<'_>>>, _> = candidates
|
||||
.into_iter()
|
||||
let mut candidates = candidates.into_iter()
|
||||
.map(|c| match self.evaluate_candidate(stack, &c) {
|
||||
Ok(eval) if eval.may_apply() => Ok(Some(EvaluatedCandidate {
|
||||
candidate: c,
|
||||
@@ -1378,10 +1377,8 @@ fn candidate_from_obligation_no_cache<'o>(
|
||||
Ok(_) => Ok(None),
|
||||
Err(OverflowError) => Err(Overflow),
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut candidates: Vec<EvaluatedCandidate<'_>> =
|
||||
candidates?.into_iter().filter_map(|c| c).collect();
|
||||
.flat_map(Result::transpose)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
debug!(
|
||||
"winnowed to {} candidates for {:?}: {:?}",
|
||||
@@ -1390,7 +1387,7 @@ fn candidate_from_obligation_no_cache<'o>(
|
||||
candidates
|
||||
);
|
||||
|
||||
// If there are STILL multiple candidate, we can further
|
||||
// If there are STILL multiple candidates, we can further
|
||||
// reduce the list by dropping duplicates -- including
|
||||
// resolving specializations.
|
||||
if candidates.len() > 1 {
|
||||
|
||||
Reference in New Issue
Block a user