Add field is_import to def::Export.
This commit is contained in:
parent
58e80400b2
commit
1b9d0584a0
8 changed files with 22 additions and 9 deletions
|
|
@ -130,6 +130,8 @@ pub struct Export {
|
|||
/// The visibility of the export.
|
||||
/// We include non-`pub` exports for hygienic macros that get used from extern crates.
|
||||
pub vis: ty::Visibility,
|
||||
/// True if from a `use` or and `extern crate`.
|
||||
pub is_import: bool,
|
||||
}
|
||||
|
||||
impl CtorKind {
|
||||
|
|
|
|||
|
|
@ -1163,7 +1163,8 @@ impl_stable_hash_for!(struct hir::def::Export {
|
|||
ident,
|
||||
def,
|
||||
vis,
|
||||
span
|
||||
span,
|
||||
is_import
|
||||
});
|
||||
|
||||
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
||||
|
|
|
|||
|
|
@ -636,6 +636,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
def: def,
|
||||
vis: ty::Visibility::Public,
|
||||
span: DUMMY_SP,
|
||||
is_import: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -675,6 +676,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
ident: Ident::from_str(&self.item_name(child_index)),
|
||||
vis: self.get_visibility(child_index),
|
||||
span: self.entry(child_index).span.decode((self, sess)),
|
||||
is_import: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -692,7 +694,8 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
(self.get_def(child_index), def_key.disambiguated_data.data.get_opt_name()) {
|
||||
let ident = Ident::from_str(&name);
|
||||
let vis = self.get_visibility(child_index);
|
||||
callback(def::Export { def, ident, vis, span });
|
||||
let is_import = false;
|
||||
callback(def::Export { def, ident, vis, span, is_import });
|
||||
// For non-reexport structs and variants add their constructors to children.
|
||||
// Reexport lists automatically contain constructors when necessary.
|
||||
match def {
|
||||
|
|
@ -700,8 +703,11 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
if let Some(ctor_def_id) = self.get_struct_ctor_def_id(child_index) {
|
||||
let ctor_kind = self.get_ctor_kind(child_index);
|
||||
let ctor_def = Def::StructCtor(ctor_def_id, ctor_kind);
|
||||
let vis = self.get_visibility(ctor_def_id.index);
|
||||
callback(def::Export { def: ctor_def, ident, vis, span });
|
||||
callback(def::Export {
|
||||
def: ctor_def,
|
||||
vis: self.get_visibility(ctor_def_id.index),
|
||||
ident, span, is_import,
|
||||
});
|
||||
}
|
||||
}
|
||||
Def::Variant(def_id) => {
|
||||
|
|
@ -710,7 +716,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
let ctor_kind = self.get_ctor_kind(child_index);
|
||||
let ctor_def = Def::VariantCtor(def_id, ctor_kind);
|
||||
let vis = self.get_visibility(child_index);
|
||||
callback(def::Export { def: ctor_def, ident, vis, span });
|
||||
callback(def::Export { def: ctor_def, ident, vis, span, is_import });
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
/// Builds the reduced graph for a single item in an external crate.
|
||||
fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'a>, child: Export) {
|
||||
let Export { ident, def, vis, span } = child;
|
||||
let Export { ident, def, vis, span, .. } = child;
|
||||
let def_id = def.def_id();
|
||||
let expansion = Mark::root(); // FIXME(jseyfried) intercrate hygiene
|
||||
match def {
|
||||
|
|
@ -672,7 +672,7 @@ impl<'a> Resolver<'a> {
|
|||
let result = self.resolve_ident_in_module(module, ident, MacroNS, false, false, span);
|
||||
if let Ok(binding) = result {
|
||||
let (def, vis) = (binding.def(), binding.vis);
|
||||
self.macro_exports.push(Export { ident, def, vis, span });
|
||||
self.macro_exports.push(Export { ident, def, vis, span, is_import: true });
|
||||
} else {
|
||||
span_err!(self.session, span, E0470, "reexported macro not found");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -751,6 +751,7 @@ impl<'a> Resolver<'a> {
|
|||
def: def,
|
||||
vis: ty::Visibility::Public,
|
||||
span: item.span,
|
||||
is_import: false,
|
||||
});
|
||||
} else {
|
||||
self.unused_macros.insert(def_id);
|
||||
|
|
|
|||
|
|
@ -866,6 +866,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
|||
def: def,
|
||||
span: binding.span,
|
||||
vis: binding.vis,
|
||||
is_import: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ fn build_module(cx: &DocContext, did: DefId) -> clean::Module {
|
|||
let mut visited = FxHashSet();
|
||||
for &item in cx.tcx.item_children(did).iter() {
|
||||
let def_id = item.def.def_id();
|
||||
if cx.tcx.visibility(def_id) == ty::Visibility::Public {
|
||||
if item.vis == ty::Visibility::Public {
|
||||
if !visited.insert(def_id) { continue }
|
||||
if let Some(i) = try_inline(cx, item.def, item.ident.name) {
|
||||
items.extend(i)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ impl<'a, 'b, 'tcx> LibEmbargoVisitor<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
for item in self.cx.tcx.item_children(def_id).iter() {
|
||||
self.visit_item(item.def);
|
||||
if !item.is_import || item.vis == Visibility::Public {
|
||||
self.visit_item(item.def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue