rustc: Remove local variable IDs from Export
s
Local variables can never be exported.
This commit is contained in:
parent
b69fe57261
commit
294510e1bb
19 changed files with 71 additions and 68 deletions
|
@ -1019,10 +1019,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
}
|
||||
|
||||
/// Iterates over each child of the given item.
|
||||
fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
where
|
||||
F: FnMut(Export<hir::HirId>),
|
||||
{
|
||||
fn each_child_of_item(&self, id: DefIndex, mut callback: impl FnMut(Export), sess: &Session) {
|
||||
if let Some(data) = &self.root.proc_macro_data {
|
||||
/* If we are loading as a proc macro, we want to return the view of this crate
|
||||
* as a proc macro crate.
|
||||
|
|
|
@ -5,7 +5,6 @@ use crate::rmeta::encoder;
|
|||
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::stable_map::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
||||
|
@ -326,28 +325,27 @@ pub fn provide(providers: &mut Providers) {
|
|||
// (restrict scope of mutable-borrow of `visible_parent_map`)
|
||||
{
|
||||
let visible_parent_map = &mut visible_parent_map;
|
||||
let mut add_child =
|
||||
|bfs_queue: &mut VecDeque<_>, child: &Export<hir::HirId>, parent: DefId| {
|
||||
if child.vis != ty::Visibility::Public {
|
||||
return;
|
||||
}
|
||||
let mut add_child = |bfs_queue: &mut VecDeque<_>, child: &Export, parent: DefId| {
|
||||
if child.vis != ty::Visibility::Public {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(child) = child.res.opt_def_id() {
|
||||
match visible_parent_map.entry(child) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
// If `child` is defined in crate `cnum`, ensure
|
||||
// that it is mapped to a parent in `cnum`.
|
||||
if child.is_local() && entry.get().is_local() {
|
||||
entry.insert(parent);
|
||||
}
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
if let Some(child) = child.res.opt_def_id() {
|
||||
match visible_parent_map.entry(child) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
// If `child` is defined in crate `cnum`, ensure
|
||||
// that it is mapped to a parent in `cnum`.
|
||||
if child.is_local() && entry.get().is_local() {
|
||||
entry.insert(parent);
|
||||
bfs_queue.push_back(child);
|
||||
}
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(parent);
|
||||
bfs_queue.push_back(child);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
while let Some(def) = bfs_queue.pop_front() {
|
||||
for child in tcx.item_children(def).iter() {
|
||||
|
@ -393,11 +391,7 @@ impl CStore {
|
|||
self.get_crate_data(def.krate).get_visibility(def.index)
|
||||
}
|
||||
|
||||
pub fn item_children_untracked(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
sess: &Session,
|
||||
) -> Vec<Export<hir::HirId>> {
|
||||
pub fn item_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<Export> {
|
||||
let mut result = vec![];
|
||||
self.get_crate_data(def_id.krate).each_child_of_item(
|
||||
def_id.index,
|
||||
|
|
|
@ -1065,14 +1065,7 @@ impl EncodeContext<'a, 'tcx> {
|
|||
// items - we encode information about proc-macros later on.
|
||||
let reexports = if !self.is_proc_macro {
|
||||
match tcx.module_exports(local_def_id) {
|
||||
Some(exports) => {
|
||||
let hir = self.tcx.hir();
|
||||
self.lazy(
|
||||
exports
|
||||
.iter()
|
||||
.map(|export| export.map_id(|id| hir.local_def_id_to_hir_id(id))),
|
||||
)
|
||||
}
|
||||
Some(exports) => self.lazy(exports),
|
||||
_ => Lazy::empty(),
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -359,7 +359,7 @@ struct RenderedConst(String);
|
|||
|
||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||
struct ModData {
|
||||
reexports: Lazy<[Export<hir::HirId>]>,
|
||||
reexports: Lazy<[Export]>,
|
||||
expansion: ExpnId,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue