rustc_metadata: Privatize CrateMetadata::source

This commit is contained in:
Vadim Petrochenkov 2019-11-23 23:13:54 +03:00
parent e2414852b1
commit 32aa58c96b
2 changed files with 10 additions and 6 deletions

View File

@ -51,10 +51,10 @@ fn dump_crates(cstore: &CStore) {
info!(" cnum: {}", cnum);
info!(" hash: {}", data.root.hash);
info!(" reqd: {:?}", *data.dep_kind.lock());
let CrateSource { dylib, rlib, rmeta } = data.source.clone();
dylib.map(|dl| info!(" dylib: {}", dl.0.display()));
rlib.map(|rl| info!(" rlib: {}", rl.0.display()));
rmeta.map(|rl| info!(" rmeta: {}", rl.0.display()));
let CrateSource { dylib, rlib, rmeta } = data.source();
dylib.as_ref().map(|dl| info!(" dylib: {}", dl.0.display()));
rlib.as_ref().map(|rl| info!(" rlib: {}", rl.0.display()));
rmeta.as_ref().map(|rl| info!(" rmeta: {}", rl.0.display()));
});
}
@ -118,7 +118,7 @@ impl<'a> CrateLoader<'a> {
// We're also sure to compare *paths*, not actual byte slices. The
// `source` stores paths which are normalized which may be different
// from the strings on the command line.
let source = &self.cstore.get_crate_data(cnum).source;
let source = self.cstore.get_crate_data(cnum).source();
if let Some(entry) = self.sess.opts.externs.get(&name.as_str()) {
// Only use `--extern crate_name=path` here, not `--extern crate_name`.
let found = entry.locations.iter().filter_map(|l| l.as_ref()).any(|l| {

View File

@ -101,7 +101,7 @@ crate struct CrateMetadata {
/// How to link (or not link) this crate to the currently compiled crate.
crate dep_kind: Lock<DepKind>,
/// Filesystem location of this crate.
crate source: CrateSource,
source: CrateSource,
/// Whether or not this crate should be consider a private dependency
/// for purposes of the 'exported_private_dependencies' lint
private_dep: bool,
@ -1534,6 +1534,10 @@ impl<'a, 'tcx> CrateMetadata {
}
update
}
crate fn source(&self) -> &CrateSource {
&self.source
}
}
// Cannot be implemented on 'ProcMacro', as libproc_macro