Skip to content

Commit adaa521

Browse files
committed
collector: extract upstream_crates
1 parent bcb98bd commit adaa521

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/librustc/hir/map/collector.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{CrateNum, DefIndex, LOCAL_CRATE};
1111
use rustc_index::vec::IndexVec;
1212
use rustc_session::{CrateDisambiguator, Session};
1313
use rustc_span::source_map::SourceMap;
14-
use rustc_span::Span;
14+
use rustc_span::{Span, Symbol};
1515
use std::iter::repeat;
1616
use syntax::ast::NodeId;
1717

@@ -98,6 +98,21 @@ where
9898
(sig, full)
9999
}
100100

101+
fn upstream_crates(cstore: &dyn CrateStore) -> Vec<(Symbol, Fingerprint, Svh)> {
102+
let mut upstream_crates: Vec<_> = cstore
103+
.crates_untracked()
104+
.iter()
105+
.map(|&cnum| {
106+
let name = cstore.crate_name_untracked(cnum);
107+
let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint();
108+
let hash = cstore.crate_hash_untracked(cnum);
109+
(name, disambiguator, hash)
110+
})
111+
.collect();
112+
upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis));
113+
upstream_crates
114+
}
115+
101116
impl<'a, 'hir> NodeCollector<'a, 'hir> {
102117
pub(super) fn root(
103118
sess: &'a Session,
@@ -190,18 +205,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
190205
},
191206
);
192207

193-
let mut upstream_crates: Vec<_> = cstore
194-
.crates_untracked()
195-
.iter()
196-
.map(|&cnum| {
197-
let name = cstore.crate_name_untracked(cnum);
198-
let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint();
199-
let hash = cstore.crate_hash_untracked(cnum);
200-
(name, disambiguator, hash)
201-
})
202-
.collect();
203-
204-
upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis));
208+
let upstream_crates = upstream_crates(cstore);
205209

206210
// We hash the final, remapped names of all local source files so we
207211
// don't have to include the path prefix remapping commandline args.

0 commit comments

Comments
 (0)