Skip to content

Commit 121dac5

Browse files
committed
Deduplicate getting the path of a lib candidate
1 parent d612081 commit 121dac5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/rustc_metadata/src/locator.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,11 @@ impl<'a> CrateLocator<'a> {
495495
0 => Ok(None),
496496
1 => Ok(Some(libraries.into_iter().next().unwrap().1)),
497497
_ => {
498-
let mut libraries: Vec<_> = libraries.into_values().collect();
499-
500-
libraries.sort_by_cached_key(|lib| lib.source.paths().next().unwrap().clone());
501-
let candidates = libraries
502-
.iter()
498+
let mut candidates: Vec<PathBuf> = libraries
499+
.into_values()
503500
.map(|lib| lib.source.paths().next().unwrap().clone())
504-
.collect::<Vec<_>>();
501+
.collect();
502+
candidates.sort();
505503

506504
Err(CrateError::MultipleCandidates(
507505
self.crate_name,

0 commit comments

Comments
 (0)