Skip to content

Commit 22cbdd4

Browse files
committed
Rollup merge of #30864 - jseyfried:no_record_exports, r=nrc
2 parents d9d902e + a353490 commit 22cbdd4

File tree

4 files changed

+22
-161
lines changed

4 files changed

+22
-161
lines changed

src/librustc_privacy/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
329329
// This code is here instead of in visit_item so that the
330330
// crate module gets processed as well.
331331
if self.prev_level.is_some() {
332-
for export in self.export_map.get(&id).expect("module isn't found in export map") {
333-
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) {
334-
self.update(node_id, Some(AccessLevel::Exported));
332+
if let Some(exports) = self.export_map.get(&id) {
333+
for export in exports {
334+
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) {
335+
self.update(node_id, Some(AccessLevel::Exported));
336+
}
335337
}
336338
}
337339
}

src/librustc_resolve/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ use resolve_imports::Shadowable;
101101
pub mod diagnostics;
102102

103103
mod check_unused;
104-
mod record_exports;
105104
mod build_reduced_graph;
106105
mod resolve_imports;
107106

@@ -4014,9 +4013,6 @@ pub fn create_resolver<'a, 'tcx>(session: &'a Session,
40144013
resolve_imports::resolve_imports(&mut resolver);
40154014
session.abort_if_errors();
40164015

4017-
record_exports::record(&mut resolver);
4018-
session.abort_if_errors();
4019-
40204016
resolver
40214017
}
40224018

src/librustc_resolve/record_exports.rs

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/librustc_resolve/resolve_imports.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
688688
id: directive.id,
689689
is_public: directive.is_public
690690
};
691+
692+
self.add_export(module_, target, &import_resolution[namespace]);
691693
*used_public = name_binding.is_public();
692694
}
693695
UnboundResult => {
@@ -827,6 +829,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
827829
dest_import_resolution[ns] = ImportResolution {
828830
id: id, is_public: is_public, target: Some(target.clone())
829831
};
832+
self.add_export(module_, *name, &dest_import_resolution[ns]);
830833
}
831834
_ => {}
832835
}
@@ -919,6 +922,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
919922
id: id,
920923
is_public: is_public
921924
};
925+
self.add_export(module_, name, &dest_import_resolution[namespace]);
922926
}
923927
} else {
924928
// FIXME #30159: This is required for backwards compatability.
@@ -935,6 +939,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
935939
name);
936940
}
937941

942+
fn add_export(&mut self, module: Module<'b>, name: Name, resolution: &ImportResolution<'b>) {
943+
if !resolution.is_public { return }
944+
let node_id = match module.def_id() {
945+
Some(def_id) => self.resolver.ast_map.as_local_node_id(def_id).unwrap(),
946+
None => return,
947+
};
948+
let export = match resolution.target.as_ref().unwrap().binding.def() {
949+
Some(def) => Export { name: name, def_id: def.def_id() },
950+
None => return,
951+
};
952+
self.resolver.export_map.entry(node_id).or_insert(Vec::new()).push(export);
953+
}
954+
938955
/// Checks that imported names and items don't have the same name.
939956
fn check_for_conflicting_import(&mut self,
940957
import_resolution: &ImportResolutionPerNamespace,

0 commit comments

Comments
 (0)