Skip to content
Permalink
Browse files

rustc_metadata: Privatize `CrateMetadata::dependencies`

  • Loading branch information
petrochenkov committed Nov 23, 2019
1 parent 0525cf9 commit 37304cda63d74b1a16f249853623960a003392c9
Showing with 13 additions and 5 deletions.
  1. +2 −2 src/librustc_metadata/creader.rs
  2. +1 −1 src/librustc_metadata/cstore.rs
  3. +10 −2 src/librustc_metadata/rmeta/decoder.rs
@@ -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

0 comments on commit 37304cd

Please sign in to comment.
You can’t perform that action at this time.