rustc_metadata: Privatize CrateMetadata::dependencies
This commit is contained in:
parent
0525cf9d68
commit
37304cda63
3 changed files with 13 additions and 5 deletions
|
@ -428,7 +428,7 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
// Propagate the extern crate info to dependencies.
|
||||
extern_crate.dependency_of = cnum;
|
||||
for &dep_cnum in cmeta.dependencies.borrow().iter() {
|
||||
for &dep_cnum in cmeta.dependencies().iter() {
|
||||
self.update_extern_crate(dep_cnum, extern_crate, visited);
|
||||
}
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ impl<'a> CrateLoader<'a> {
|
|||
}
|
||||
|
||||
info!("injecting a dep from {} to {}", cnum, krate);
|
||||
data.dependencies.borrow_mut().push(krate);
|
||||
data.add_dependency(krate);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ impl CStore {
|
|||
fn push_dependencies_in_postorder(&self, deps: &mut Vec<CrateNum>, cnum: CrateNum) {
|
||||
if !deps.contains(&cnum) {
|
||||
let data = self.get_crate_data(cnum);
|
||||
for &dep in data.dependencies.borrow().iter() {
|
||||
for &dep in data.dependencies().iter() {
|
||||
if dep != cnum {
|
||||
self.push_dependencies_in_postorder(deps, dep);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::rmeta::*;
|
|||
use crate::rmeta::table::{FixedSizeEncoding, Table};
|
||||
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_data_structures::sync::{Lrc, Lock, Once, AtomicCell};
|
||||
use rustc_data_structures::sync::{Lrc, Lock, LockGuard, Once, AtomicCell};
|
||||
use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash};
|
||||
use rustc::hir::map::definitions::DefPathTable;
|
||||
use rustc::hir;
|
||||
|
@ -97,7 +97,7 @@ crate struct CrateMetadata {
|
|||
/// IDs as they are seen from the current compilation session.
|
||||
cnum_map: CrateNumMap,
|
||||
/// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime.
|
||||
crate dependencies: Lock<Vec<CrateNum>>,
|
||||
dependencies: Lock<Vec<CrateNum>>,
|
||||
/// How to link (or not link) this crate to the currently compiled crate.
|
||||
crate dep_kind: Lock<DepKind>,
|
||||
/// Filesystem location of this crate.
|
||||
|
@ -1517,6 +1517,14 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
|
||||
dep_node_index
|
||||
}
|
||||
|
||||
crate fn dependencies(&self) -> LockGuard<'_, Vec<CrateNum>> {
|
||||
self.dependencies.borrow()
|
||||
}
|
||||
|
||||
crate fn add_dependency(&self, cnum: CrateNum) {
|
||||
self.dependencies.borrow_mut().push(cnum);
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot be implemented on 'ProcMacro', as libproc_macro
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue