rustc_metadata: inherit dependency privacy flag
This commit is contained in:
parent
64025bb168
commit
e36020cdb3
@ -365,6 +365,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
lib: Library,
|
||||
dep_kind: CrateDepKind,
|
||||
name: Symbol,
|
||||
private_dep: bool,
|
||||
) -> Result<CrateNum, CrateError> {
|
||||
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
|
||||
|
||||
@ -518,15 +519,16 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
if !name.as_str().is_ascii() {
|
||||
return Err(CrateError::NonAsciiName(name));
|
||||
}
|
||||
let (root, hash, host_hash, extra_filename, path_kind) = match dep {
|
||||
let (root, hash, host_hash, extra_filename, path_kind, private_dep) = match dep {
|
||||
Some((root, dep)) => (
|
||||
Some(root),
|
||||
Some(dep.hash),
|
||||
dep.host_hash,
|
||||
Some(&dep.extra_filename[..]),
|
||||
PathKind::Dependency,
|
||||
dep.is_private,
|
||||
),
|
||||
None => (None, None, None, None, PathKind::Crate),
|
||||
None => (None, None, None, None, PathKind::Crate, false),
|
||||
};
|
||||
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
|
||||
(LoadResult::Previous(cnum), None)
|
||||
@ -562,10 +564,11 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
dep_kind = CrateDepKind::MacrosOnly;
|
||||
}
|
||||
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
|
||||
data.update_private_dep(|private_dep| private_dep && private_dep);
|
||||
Ok(cnum)
|
||||
}
|
||||
(LoadResult::Loaded(library), host_library) => {
|
||||
self.register_crate(host_library, root, library, dep_kind, name)
|
||||
self.register_crate(host_library, root, library, dep_kind, name, private_dep)
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ pub(crate) struct CrateMetadata {
|
||||
source: Lrc<CrateSource>,
|
||||
/// Whether or not this crate should be consider a private dependency
|
||||
/// for purposes of the 'exported_private_dependencies' lint
|
||||
private_dep: bool,
|
||||
private_dep: Lock<bool>,
|
||||
/// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
|
||||
host_hash: Option<Svh>,
|
||||
|
||||
@ -690,12 +690,13 @@ impl MetadataBlob {
|
||||
writeln!(out, "=External Dependencies=")?;
|
||||
|
||||
for (i, dep) in root.crate_deps.decode(self).enumerate() {
|
||||
let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
|
||||
let CrateDep { name, extra_filename, hash, host_hash, kind, is_private } = dep;
|
||||
let number = i + 1;
|
||||
|
||||
writeln!(
|
||||
out,
|
||||
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
|
||||
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?} {privacy}",
|
||||
privacy = if is_private { "private" } else { "public" }
|
||||
)?;
|
||||
}
|
||||
write!(out, "\n")?;
|
||||
@ -1617,7 +1618,7 @@ impl CrateMetadata {
|
||||
dependencies,
|
||||
dep_kind: Lock::new(dep_kind),
|
||||
source: Lrc::new(source),
|
||||
private_dep,
|
||||
private_dep: Lock::new(private_dep),
|
||||
host_hash,
|
||||
extern_crate: Lock::new(None),
|
||||
hygiene_context: Default::default(),
|
||||
@ -1665,6 +1666,10 @@ impl CrateMetadata {
|
||||
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
|
||||
}
|
||||
|
||||
pub(crate) fn update_private_dep(&self, f: impl FnOnce(bool) -> bool) {
|
||||
self.private_dep.with_lock(|private_dep| *private_dep = f(*private_dep))
|
||||
}
|
||||
|
||||
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
|
||||
self.root.required_panic_strategy
|
||||
}
|
||||
|
@ -285,7 +285,10 @@ provide! { tcx, def_id, other, cdata,
|
||||
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
|
||||
|
||||
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
|
||||
is_private_dep => { cdata.private_dep }
|
||||
is_private_dep => {
|
||||
let r = *cdata.private_dep.lock();
|
||||
r
|
||||
}
|
||||
is_panic_runtime => { cdata.root.panic_runtime }
|
||||
is_compiler_builtins => { cdata.root.compiler_builtins }
|
||||
has_global_allocator => { cdata.root.has_global_allocator }
|
||||
|
@ -1880,6 +1880,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
host_hash: self.tcx.crate_host_hash(cnum),
|
||||
kind: self.tcx.dep_kind(cnum),
|
||||
extra_filename: self.tcx.extra_filename(cnum).clone(),
|
||||
is_private: self.tcx.is_private_dep(cnum),
|
||||
};
|
||||
(cnum, dep)
|
||||
})
|
||||
|
@ -302,6 +302,7 @@ pub(crate) struct CrateDep {
|
||||
pub host_hash: Option<Svh>,
|
||||
pub kind: CrateDepKind,
|
||||
pub extra_filename: String,
|
||||
pub is_private: bool,
|
||||
}
|
||||
|
||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user