Skip to content

Commit

Permalink
rustc: middle: move Export and ExportMap from resolve to def.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Dec 20, 2014
1 parent 10a862d commit d9504d4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -21,10 +21,10 @@ use metadata::common::*;
use metadata::cstore;
use metadata::decoder;
use metadata::tyencode;
use middle::def;
use middle::ty::{lookup_item_type};
use middle::ty::{mod, Ty};
use middle::stability;
use middle;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};

use serialize::Encodable;
Expand Down 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 reexports: &'a middle::resolve::ExportMap,
pub reexports: &'a def::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 reexports: &'a middle::resolve::ExportMap,
pub reexports: &'a def::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::Export,
exp: &def::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::Export)
exp: &def::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::Export)
exp: &def::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::Export) {
exp: &def::Export) {
if let Some(ast_map::NodeItem(item)) = ecx.tcx.map.find(exp.def_id.node) {
let path_differs = ecx.tcx.map.with_path(exp.def_id.node, |path| {
let (mut a, mut b) = (path, mod_path.clone());
Expand Down
9 changes: 9 additions & 0 deletions src/librustc/middle/def.rs
Expand Up @@ -61,6 +61,15 @@ pub enum Def {

// Definition mapping
pub type DefMap = RefCell<NodeMap<Def>>;
// This is the replacement export map. It maps a module to all of the exports
// within.
pub type ExportMap = NodeMap<Vec<Export>>;

#[deriving(Copy)]
pub struct Export {
pub name: ast::Name, // The name of the target.
pub def_id: ast::DefId, // The definition of the target.
}

#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum MethodProvenance {
Expand Down
6 changes: 3 additions & 3 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::ExportMap);
type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a def::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>,
export_map: &'a resolve::ExportMap,
export_map: &'a def::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 @@ -1520,7 +1520,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}

pub fn check_crate(tcx: &ty::ctxt,
export_map: &resolve::ExportMap,
export_map: &def::ExportMap,
external_exports: resolve::ExternalExports,
last_private_map: resolve::LastPrivateMap)
-> (ExportedItems, PublicItems) {
Expand Down
9 changes: 0 additions & 9 deletions src/librustc/middle/resolve.rs
Expand Up @@ -93,15 +93,6 @@ struct BindingInfo {
// Map from the name in a pattern to its binding mode.
type BindingMap = HashMap<Name, BindingInfo>;

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

pub struct Export {
pub name: Name, // The name of the target.
pub def_id: DefId, // The definition of the target.
}

// This set contains all exported definitions from external crates. The set does
// not contain any entries from local crates.
pub type ExternalExports = DefIdSet;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/ty.rs
Expand Up @@ -46,7 +46,7 @@ use lint;
use metadata::csearch;
use middle;
use middle::const_eval;
use middle::def::{mod, DefMap};
use middle::def::{mod, DefMap, ExportMap};
use middle::dependency_format;
use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem};
use middle::lang_items::{FnOnceTraitLangItem, TyDescStructLangItem};
Expand Down Expand Up @@ -98,7 +98,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 export_map: middle::resolve::ExportMap,
pub export_map: ExportMap,
pub exported_items: middle::privacy::ExportedItems,
pub public_items: middle::privacy::PublicItems,
pub ty_cx: ty::ctxt<'tcx>,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_trans/trans/context.rs
Expand Up @@ -13,7 +13,7 @@ use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef};
use llvm::{TargetData};
use llvm::mk_target_data;
use metadata::common::LinkMeta;
use middle::resolve;
use middle::def::ExportMap;
use middle::traits;
use trans::adt;
use trans::base;
Expand Down Expand Up @@ -61,7 +61,7 @@ pub struct SharedCrateContext<'tcx> {
metadata_llmod: ModuleRef,
metadata_llcx: ContextRef,

export_map: resolve::ExportMap,
export_map: 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>,
export_map: resolve::ExportMap,
export_map: ExportMap,
symbol_hasher: Sha256,
link_meta: LinkMeta,
reachable: NodeSet)
Expand Down Expand Up @@ -329,7 +329,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
self.metadata_llcx
}

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

Expand Down Expand Up @@ -553,7 +553,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
&self.local.item_vals
}

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

Expand Down

0 comments on commit d9504d4

Please sign in to comment.