about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-01-07 14:19:35 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-01-08 21:58:41 +0100
commitadaa521feb09dbb40e5e2143bc3ce62112c8ce04 (patch)
tree115c04dd958c374060e24b0cd52ec1cfdce29bde
parentbcb98bdc348ba58f2f8ba936412001eb9ebbeb14 (diff)
downloadrust-adaa521feb09dbb40e5e2143bc3ce62112c8ce04.tar.gz
rust-adaa521feb09dbb40e5e2143bc3ce62112c8ce04.zip
collector: extract upstream_crates
-rw-r--r--src/librustc/hir/map/collector.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs
index 6879e8fd763..a7d5cb6cbe3 100644
--- a/src/librustc/hir/map/collector.rs
+++ b/src/librustc/hir/map/collector.rs
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{CrateNum, DefIndex, LOCAL_CRATE};
 use rustc_index::vec::IndexVec;
 use rustc_session::{CrateDisambiguator, Session};
 use rustc_span::source_map::SourceMap;
-use rustc_span::Span;
+use rustc_span::{Span, Symbol};
 use std::iter::repeat;
 use syntax::ast::NodeId;
 
@@ -98,6 +98,21 @@ where
     (sig, full)
 }
 
+fn upstream_crates(cstore: &dyn CrateStore) -> Vec<(Symbol, Fingerprint, Svh)> {
+    let mut upstream_crates: Vec<_> = cstore
+        .crates_untracked()
+        .iter()
+        .map(|&cnum| {
+            let name = cstore.crate_name_untracked(cnum);
+            let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint();
+            let hash = cstore.crate_hash_untracked(cnum);
+            (name, disambiguator, hash)
+        })
+        .collect();
+    upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis));
+    upstream_crates
+}
+
 impl<'a, 'hir> NodeCollector<'a, 'hir> {
     pub(super) fn root(
         sess: &'a Session,
@@ -190,18 +205,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
             },
         );
 
-        let mut upstream_crates: Vec<_> = cstore
-            .crates_untracked()
-            .iter()
-            .map(|&cnum| {
-                let name = cstore.crate_name_untracked(cnum);
-                let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint();
-                let hash = cstore.crate_hash_untracked(cnum);
-                (name, disambiguator, hash)
-            })
-            .collect();
-
-        upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis));
+        let upstream_crates = upstream_crates(cstore);
 
         // We hash the final, remapped names of all local source files so we
         // don't have to include the path prefix remapping commandline args.