diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-03-23 14:59:31 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-07-03 11:52:19 +0000 |
| commit | 121dac5cbb1129d6107a7a01eecda54825ca58aa (patch) | |
| tree | 25a87cc0d9111071630607f9b82fe6feada508b1 /compiler | |
| parent | d6120810e56387730b2e86115471354c8084ca4a (diff) | |
| download | rust-121dac5cbb1129d6107a7a01eecda54825ca58aa.tar.gz rust-121dac5cbb1129d6107a7a01eecda54825ca58aa.zip | |
Deduplicate getting the path of a lib candidate
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_metadata/src/locator.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 941f16bd960..9fb573fb07d 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -495,13 +495,11 @@ impl<'a> CrateLocator<'a> { 0 => Ok(None), 1 => Ok(Some(libraries.into_iter().next().unwrap().1)), _ => { - let mut libraries: Vec<_> = libraries.into_values().collect(); - - libraries.sort_by_cached_key(|lib| lib.source.paths().next().unwrap().clone()); - let candidates = libraries - .iter() + let mut candidates: Vec<PathBuf> = libraries + .into_values() .map(|lib| lib.source.paths().next().unwrap().clone()) - .collect::<Vec<_>>(); + .collect(); + candidates.sort(); Err(CrateError::MultipleCandidates( self.crate_name, |
