From acfc99dddd26a318867d9e1602738619d097ac6f Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 25 Apr 2014 18:06:49 +0200 Subject: [PATCH] Include file paths when dumping the list of resolved crates via `debug!`. --- src/librustc/metadata/creader.rs | 9 +++++++-- src/librustc/metadata/cstore.rs | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index eabd316b7c5..5ed8da8a82b 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -17,7 +17,7 @@ use back::svh::Svh; use driver::session::Session; use driver::{driver, config}; use metadata::cstore; -use metadata::cstore::CStore; +use metadata::cstore::{CStore, CrateSource}; use metadata::decoder; use metadata::loader; use metadata::loader::CratePaths; @@ -68,10 +68,15 @@ impl<'a> visit::Visitor<()> for Env<'a> { fn dump_crates(cstore: &CStore) { debug!("resolved crates:"); - cstore.iter_crate_data(|_, data| { + cstore.iter_crate_data_origins(|_, data, opt_source| { debug!("crate_id: {}", data.crate_id()); debug!(" cnum: {}", data.cnum); debug!(" hash: {}", data.hash()); + opt_source.map(|cs| { + let CrateSource { dylib, rlib, cnum: _ } = cs; + dylib.map(|dl| debug!(" dylib: {}", dl.display())); + rlib.map(|rl| debug!(" rlib: {}", rl.display())); + }); }) } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index ede70c94ecb..cbf8944f039 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -114,6 +114,17 @@ impl CStore { } } + /// Like `iter_crate_data`, but passes source paths (if available) as well. + pub fn iter_crate_data_origins(&self, i: |ast::CrateNum, + &crate_metadata, + Option|) { + for (&k, v) in self.metas.borrow().iter() { + let origin = self.get_used_crate_source(k); + origin.as_ref().map(|cs| { assert!(k == cs.cnum); }); + i(k, &**v, origin); + } + } + pub fn add_used_crate_source(&self, src: CrateSource) { let mut used_crate_sources = self.used_crate_sources.borrow_mut(); if !used_crate_sources.contains(&src) {