Skip to content

Commit 32aa58c

Browse files
committed
rustc_metadata: Privatize CrateMetadata::source
1 parent e241485 commit 32aa58c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/librustc_metadata/creader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ fn dump_crates(cstore: &CStore) {
5151
info!(" cnum: {}", cnum);
5252
info!(" hash: {}", data.root.hash);
5353
info!(" reqd: {:?}", *data.dep_kind.lock());
54-
let CrateSource { dylib, rlib, rmeta } = data.source.clone();
55-
dylib.map(|dl| info!(" dylib: {}", dl.0.display()));
56-
rlib.map(|rl| info!(" rlib: {}", rl.0.display()));
57-
rmeta.map(|rl| info!(" rmeta: {}", rl.0.display()));
54+
let CrateSource { dylib, rlib, rmeta } = data.source();
55+
dylib.as_ref().map(|dl| info!(" dylib: {}", dl.0.display()));
56+
rlib.as_ref().map(|rl| info!(" rlib: {}", rl.0.display()));
57+
rmeta.as_ref().map(|rl| info!(" rmeta: {}", rl.0.display()));
5858
});
5959
}
6060

@@ -118,7 +118,7 @@ impl<'a> CrateLoader<'a> {
118118
// We're also sure to compare *paths*, not actual byte slices. The
119119
// `source` stores paths which are normalized which may be different
120120
// from the strings on the command line.
121-
let source = &self.cstore.get_crate_data(cnum).source;
121+
let source = self.cstore.get_crate_data(cnum).source();
122122
if let Some(entry) = self.sess.opts.externs.get(&name.as_str()) {
123123
// Only use `--extern crate_name=path` here, not `--extern crate_name`.
124124
let found = entry.locations.iter().filter_map(|l| l.as_ref()).any(|l| {

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ crate struct CrateMetadata {
101101
/// How to link (or not link) this crate to the currently compiled crate.
102102
crate dep_kind: Lock<DepKind>,
103103
/// Filesystem location of this crate.
104-
crate source: CrateSource,
104+
source: CrateSource,
105105
/// Whether or not this crate should be consider a private dependency
106106
/// for purposes of the 'exported_private_dependencies' lint
107107
private_dep: bool,
@@ -1534,6 +1534,10 @@ impl<'a, 'tcx> CrateMetadata {
15341534
}
15351535
update
15361536
}
1537+
1538+
crate fn source(&self) -> &CrateSource {
1539+
&self.source
1540+
}
15371541
}
15381542

15391543
// Cannot be implemented on 'ProcMacro', as libproc_macro

0 commit comments

Comments
 (0)