Skip to content

Commit

Permalink
middle: resolve: fix inconsistencies around ExportMap and remove the …
Browse files Browse the repository at this point in the history
…2 suffix.
  • Loading branch information
eddyb committed Dec 20, 2014
1 parent 5338222 commit fb1d6f2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
18 changes: 9 additions & 9 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -66,7 +66,7 @@ pub type EncodeInlinedItem<'a> = |ecx: &EncodeContext,
pub struct EncodeParams<'a, 'tcx: 'a> {
pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt<'tcx>,
pub reexports2: &'a middle::resolve::ExportMap2,
pub reexports: &'a middle::resolve::ExportMap,
pub item_symbols: &'a RefCell<NodeMap<String>>,
pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore,
Expand All @@ -77,7 +77,7 @@ pub struct EncodeParams<'a, 'tcx: 'a> {
pub struct EncodeContext<'a, 'tcx: 'a> {
pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt<'tcx>,
pub reexports2: &'a middle::resolve::ExportMap2,
pub reexports: &'a middle::resolve::ExportMap,
pub item_symbols: &'a RefCell<NodeMap<String>>,
pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore,
Expand Down Expand Up @@ -379,7 +379,7 @@ fn encode_path<PI: Iterator<PathElem>>(rbml_w: &mut Encoder, path: PI) {
}

fn encode_reexported_static_method(rbml_w: &mut Encoder,
exp: &middle::resolve::Export2,
exp: &middle::resolve::Export,
method_def_id: DefId,
method_name: ast::Name) {
debug!("(encode reexported static method) {}::{}",
Expand All @@ -398,7 +398,7 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,

fn encode_reexported_static_base_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
exp: &middle::resolve::Export2)
exp: &middle::resolve::Export)
-> bool {
let impl_items = ecx.tcx.impl_items.borrow();
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
Expand Down Expand Up @@ -428,7 +428,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,

fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
exp: &middle::resolve::Export2)
exp: &middle::resolve::Export)
-> bool {
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
Some(trait_items) => {
Expand All @@ -449,7 +449,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
fn encode_reexported_static_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
mod_path: PathElems,
exp: &middle::resolve::Export2) {
exp: &middle::resolve::Export) {
if let Some(ast_map::NodeItem(item)) = ecx.tcx.map.find(exp.def_id.node) {
let original_name = token::get_ident(item.ident);

Expand Down Expand Up @@ -519,7 +519,7 @@ fn encode_reexports(ecx: &EncodeContext,
id: NodeId,
path: PathElems) {
debug!("(encoding info for module) encoding reexports for {}", id);
match ecx.reexports2.get(&id) {
match ecx.reexports.get(&id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
Expand Down Expand Up @@ -2071,7 +2071,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
item_symbols,
diag,
tcx,
reexports2,
reexports,
cstore,
encode_inlined_item,
link_meta,
Expand All @@ -2081,7 +2081,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
let ecx = EncodeContext {
diag: diag,
tcx: tcx,
reexports2: reexports2,
reexports: reexports,
item_symbols: item_symbols,
link_meta: link_meta,
cstore: cstore,
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/privacy.rs
Expand Up @@ -29,7 +29,7 @@ use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit::{mod, Visitor};

type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a resolve::ExportMap2);
type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a resolve::ExportMap);

/// A set of AST nodes exported by the crate.
pub type ExportedItems = NodeSet;
Expand Down Expand Up @@ -136,7 +136,7 @@ impl<'v> Visitor<'v> for ParentVisitor {

struct EmbargoVisitor<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
exp_map2: &'a resolve::ExportMap2,
export_map: &'a resolve::ExportMap,

// This flag is an indicator of whether the previous item in the
// hierarchical chain was exported or not. This is the indicator of whether
Expand Down Expand Up @@ -342,8 +342,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_exported {
assert!(self.exp_map2.contains_key(&id), "wut {}", id);
for export in self.exp_map2[id].iter() {
assert!(self.export_map.contains_key(&id), "wut {}", id);
for export in self.export_map[id].iter() {
if is_local(export.def_id) {
self.reexports.insert(export.def_id.node);
}
Expand Down Expand Up @@ -1520,7 +1520,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}

pub fn check_crate(tcx: &ty::ctxt,
exp_map2: &resolve::ExportMap2,
export_map: &resolve::ExportMap,
external_exports: resolve::ExternalExports,
last_private_map: resolve::LastPrivateMap)
-> (ExportedItems, PublicItems) {
Expand Down Expand Up @@ -1561,7 +1561,7 @@ pub fn check_crate(tcx: &ty::ctxt,
exported_items: NodeSet::new(),
public_items: NodeSet::new(),
reexports: NodeSet::new(),
exp_map2: exp_map2,
export_map: export_map,
prev_exported: true,
prev_public: true,
};
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/resolve.rs
Expand Up @@ -97,13 +97,13 @@ struct BindingInfo {
type BindingMap = HashMap<Name, BindingInfo>;

// Trait method resolution
pub type TraitMap = NodeMap<Vec<DefId> >;
pub type TraitMap = NodeMap<Vec<DefId>>;

// This is the replacement export map. It maps a module to all of the exports
// within.
pub type ExportMap2 = NodeMap<Vec<Export2>>;
pub type ExportMap = NodeMap<Vec<Export>>;

pub struct Export2 {
pub struct Export {
pub name: String, // The name of the target.
pub def_id: DefId, // The definition of the target.
}
Expand Down Expand Up @@ -946,7 +946,7 @@ struct Resolver<'a> {
freevars: RefCell<FreevarMap>,
freevars_seen: RefCell<NodeMap<NodeSet>>,
capture_mode_map: CaptureModeMap,
export_map2: ExportMap2,
export_map: ExportMap,
trait_map: TraitMap,
external_exports: ExternalExports,
last_private: LastPrivateMap,
Expand Down Expand Up @@ -1061,7 +1061,7 @@ impl<'a> Resolver<'a> {
freevars: RefCell::new(NodeMap::new()),
freevars_seen: RefCell::new(NodeMap::new()),
capture_mode_map: NodeMap::new(),
export_map2: NodeMap::new(),
export_map: NodeMap::new(),
trait_map: NodeMap::new(),
used_imports: HashSet::new(),
used_crates: HashSet::new(),
Expand Down Expand Up @@ -3859,12 +3859,12 @@ impl<'a> Resolver<'a> {
}

fn record_exports_for_module(&mut self, module_: &Module) {
let mut exports2 = Vec::new();
let mut exports = Vec::new();

self.add_exports_for_module(&mut exports2, module_);
self.add_exports_for_module(&mut exports, module_);
match module_.def_id.get() {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
self.export_map.insert(def_id.node, exports);
debug!("(computing exports) writing exports for {} (some)",
def_id.node);
}
Expand All @@ -3873,7 +3873,7 @@ impl<'a> Resolver<'a> {
}

fn add_exports_of_namebindings(&mut self,
exports2: &mut Vec<Export2> ,
exports: &mut Vec<Export>,
name: Name,
namebindings: &NameBindings,
ns: Namespace) {
Expand All @@ -3882,7 +3882,7 @@ impl<'a> Resolver<'a> {
let name = token::get_name(name);
debug!("(computing exports) YES: export '{}' => {}",
name, d.def_id());
exports2.push(Export2 {
exports.push(Export {
name: name.get().to_string(),
def_id: d.def_id()
});
Expand All @@ -3894,7 +3894,7 @@ impl<'a> Resolver<'a> {
}

fn add_exports_for_module(&mut self,
exports2: &mut Vec<Export2> ,
exports: &mut Vec<Export>,
module_: &Module) {
for (name, importresolution) in module_.import_resolutions.borrow().iter() {
if !importresolution.is_public {
Expand All @@ -3906,7 +3906,7 @@ impl<'a> Resolver<'a> {
Some(target) => {
debug!("(computing exports) maybe export '{}'",
token::get_name(*name));
self.add_exports_of_namebindings(exports2,
self.add_exports_of_namebindings(exports,
*name,
&*target.bindings,
ns)
Expand Down Expand Up @@ -6322,7 +6322,7 @@ pub struct CrateMap {
pub def_map: DefMap,
pub freevars: RefCell<FreevarMap>,
pub capture_mode_map: RefCell<CaptureModeMap>,
pub exp_map2: ExportMap2,
pub export_map: ExportMap,
pub trait_map: TraitMap,
pub external_exports: ExternalExports,
pub last_private_map: LastPrivateMap,
Expand All @@ -6339,7 +6339,7 @@ pub fn resolve_crate(session: &Session,
def_map: resolver.def_map,
freevars: resolver.freevars,
capture_mode_map: RefCell::new(resolver.capture_mode_map),
exp_map2: resolver.export_map2,
export_map: resolver.export_map,
trait_map: resolver.trait_map,
external_exports: resolver.external_exports,
last_private_map: resolver.last_private,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Expand Up @@ -99,7 +99,7 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
/// The complete set of all analyses described in this module. This is
/// produced by the driver and fed to trans and later passes.
pub struct CrateAnalysis<'tcx> {
pub exp_map2: middle::resolve::ExportMap2,
pub export_map: middle::resolve::ExportMap,
pub exported_items: middle::privacy::ExportedItems,
pub public_items: middle::privacy::PublicItems,
pub ty_cx: ty::ctxt<'tcx>,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_driver/driver.rs
Expand Up @@ -345,7 +345,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
def_map,
freevars,
capture_mode_map,
exp_map2,
export_map,
trait_map,
external_exports,
last_private_map
Expand Down Expand Up @@ -406,7 +406,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
let maps = (external_exports, last_private_map);
let (exported_items, public_items) =
time(time_passes, "privacy checking", maps, |(a, b)|
middle::privacy::check_crate(&ty_cx, &exp_map2, a, b));
middle::privacy::check_crate(&ty_cx, &export_map, a, b));

time(time_passes, "intrinsic checking", (), |_|
middle::intrinsicck::check_crate(&ty_cx));
Expand Down Expand Up @@ -447,7 +447,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
lint::check_crate(&ty_cx, &exported_items));

ty::CrateAnalysis {
exp_map2: exp_map2,
export_map: export_map,
ty_cx: ty_cx,
exported_items: exported_items,
public_items: public_items,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/base.rs
Expand Up @@ -2938,7 +2938,7 @@ pub fn crate_ctxt_to_encode_parms<'a, 'tcx>(cx: &'a SharedCrateContext<'tcx>,
encoder::EncodeParams {
diag: cx.sess().diagnostic(),
tcx: cx.tcx(),
reexports2: cx.exp_map2(),
reexports: cx.export_map(),
item_symbols: cx.item_symbols(),
link_meta: cx.link_meta(),
cstore: &cx.sess().cstore,
Expand Down Expand Up @@ -3071,7 +3071,7 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {

pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
-> (ty::ctxt<'tcx>, CrateTranslation) {
let ty::CrateAnalysis { ty_cx: tcx, exp_map2, reachable, name, .. } = analysis;
let ty::CrateAnalysis { ty_cx: tcx, export_map, reachable, name, .. } = analysis;
let krate = tcx.map.krate();

// Before we touch LLVM, make sure that multithreading is enabled.
Expand All @@ -3098,7 +3098,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
let shared_ccx = SharedCrateContext::new(link_meta.crate_name.as_slice(),
codegen_units,
tcx,
exp_map2,
export_map,
Sha256::new(),
link_meta.clone(),
reachable);
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_trans/trans/context.rs
Expand Up @@ -61,7 +61,7 @@ pub struct SharedCrateContext<'tcx> {
metadata_llmod: ModuleRef,
metadata_llcx: ContextRef,

exp_map2: resolve::ExportMap2,
export_map: resolve::ExportMap,
reachable: NodeSet,
item_symbols: RefCell<NodeMap<String>>,
link_meta: LinkMeta,
Expand Down Expand Up @@ -238,7 +238,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
pub fn new(crate_name: &str,
local_count: uint,
tcx: ty::ctxt<'tcx>,
emap2: resolve::ExportMap2,
export_map: resolve::ExportMap,
symbol_hasher: Sha256,
link_meta: LinkMeta,
reachable: NodeSet)
Expand All @@ -251,7 +251,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
local_ccxs: Vec::with_capacity(local_count),
metadata_llmod: metadata_llmod,
metadata_llcx: metadata_llcx,
exp_map2: emap2,
export_map: export_map,
reachable: reachable,
item_symbols: RefCell::new(NodeMap::new()),
link_meta: link_meta,
Expand Down Expand Up @@ -329,8 +329,8 @@ impl<'tcx> SharedCrateContext<'tcx> {
self.metadata_llcx
}

pub fn exp_map2<'a>(&'a self) -> &'a resolve::ExportMap2 {
&self.exp_map2
pub fn export_map<'a>(&'a self) -> &'a resolve::ExportMap {
&self.export_map
}

pub fn reachable<'a>(&'a self) -> &'a NodeSet {
Expand Down Expand Up @@ -553,8 +553,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
&self.local.item_vals
}

pub fn exp_map2<'a>(&'a self) -> &'a resolve::ExportMap2 {
&self.shared.exp_map2
pub fn export_map<'a>(&'a self) -> &'a resolve::ExportMap {
&self.shared.export_map
}

pub fn reachable<'a>(&'a self) -> &'a NodeSet {
Expand Down

0 comments on commit fb1d6f2

Please sign in to comment.