about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-03-29 13:14:01 +0300
committerEduard Burtescu <edy.burt@gmail.com>2016-04-06 09:14:21 +0300
commit20f0f3c1f131b54dcc6fdc7eeb1d04ea89f5f6fd (patch)
tree6534c4d72173c9bdaffd33c78bce4c7172baf022
parentffca6c3e155cb6033b1f749d0ba1be32dfc4d22a (diff)
downloadrust-20f0f3c1f131b54dcc6fdc7eeb1d04ea89f5f6fd.tar.gz
rust-20f0f3c1f131b54dcc6fdc7eeb1d04ea89f5f6fd.zip
rustc: move some maps from ty to hir.
-rw-r--r--src/librustc/hir/mod.rs25
-rw-r--r--src/librustc/ty/context.rs2
-rw-r--r--src/librustc/ty/mod.rs28
-rw-r--r--src/librustc_metadata/astencode.rs14
-rw-r--r--src/librustc_mir/hair/cx/expr.rs2
-rw-r--r--src/librustc_resolve/lib.rs8
-rw-r--r--src/librustc_typeck/lib.rs4
7 files changed, 43 insertions, 40 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 10fe86246de..edb9b783527 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -33,6 +33,10 @@ pub use self::ViewPath_::*;
 pub use self::Visibility::*;
 pub use self::PathParameters::*;
 
+use hir::def::Def;
+use hir::def_id::DefId;
+use util::nodemap::{NodeMap, FnvHashSet};
+
 use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
 use syntax::abi::Abi;
 use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
@@ -1625,3 +1629,24 @@ impl ForeignItem_ {
         }
     }
 }
+
+/// A free variable referred to in a function.
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
+pub struct Freevar {
+    /// The variable being accessed free.
+    pub def: Def,
+
+    // First span where it is accessed (there can be multiple).
+    pub span: Span
+}
+
+pub type FreevarMap = NodeMap<Vec<Freevar>>;
+
+pub type CaptureModeMap = NodeMap<CaptureClause>;
+
+// Trait method resolution
+pub type TraitMap = NodeMap<Vec<DefId>>;
+
+// Map from the NodeId of a glob import to a list of items which are actually
+// imported.
+pub type GlobMap = NodeMap<FnvHashSet<Name>>;
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 14ffeadbb3a..bdba700f49a 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -27,7 +27,7 @@ use traits;
 use ty::{self, TraitRef, Ty, TypeAndMut};
 use ty::{TyS, TypeVariants};
 use ty::{AdtDef, ClosureSubsts, ExistentialBounds, Region};
-use ty::{FreevarMap};
+use hir::FreevarMap;
 use ty::{BareFnTy, InferTy, ParamTy, ProjectionTy, TraitTy};
 use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
 use ty::TypeVariants::*;
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 2f0b520d842..4ff859f5a94 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -33,7 +33,7 @@ use ty::fold::TypeFolder;
 use ty::subst::{Subst, Substs, VecPerParamSpace};
 use ty::walk::TypeWalker;
 use util::common::MemoizationMap;
-use util::nodemap::{NodeMap, NodeSet};
+use util::nodemap::NodeSet;
 use util::nodemap::FnvHashMap;
 
 use serialize::{Encodable, Encoder, Decodable, Decoder};
@@ -44,7 +44,6 @@ use std::iter;
 use std::rc::Rc;
 use std::slice;
 use std::vec::IntoIter;
-use std::collections::{HashMap, HashSet};
 use syntax::ast::{self, CrateNum, Name, NodeId};
 use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{DUMMY_SP, Span};
@@ -115,7 +114,7 @@ pub struct CrateAnalysis<'a> {
     pub access_levels: middle::privacy::AccessLevels,
     pub reachable: NodeSet,
     pub name: &'a str,
-    pub glob_map: Option<GlobMap>,
+    pub glob_map: Option<hir::GlobMap>,
 }
 
 #[derive(Copy, Clone)]
@@ -2724,30 +2723,9 @@ pub enum ExplicitSelfCategory {
     ByBox,
 }
 
-/// A free variable referred to in a function.
-#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
-pub struct Freevar {
-    /// The variable being accessed free.
-    pub def: Def,
-
-    // First span where it is accessed (there can be multiple).
-    pub span: Span
-}
-
-pub type FreevarMap = NodeMap<Vec<Freevar>>;
-
-pub type CaptureModeMap = NodeMap<hir::CaptureClause>;
-
-// Trait method resolution
-pub type TraitMap = NodeMap<Vec<DefId>>;
-
-// Map from the NodeId of a glob import to a list of items which are actually
-// imported.
-pub type GlobMap = HashMap<NodeId, HashSet<Name>>;
-
 impl<'tcx> TyCtxt<'tcx> {
     pub fn with_freevars<T, F>(&self, fid: NodeId, f: F) -> T where
-        F: FnOnce(&[Freevar]) -> T,
+        F: FnOnce(&[hir::Freevar]) -> T,
     {
         match self.freevars.borrow().get(&fid) {
             None => f(&[]),
diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs
index df60e35d0f3..3becc93f8a4 100644
--- a/src/librustc_metadata/astencode.rs
+++ b/src/librustc_metadata/astencode.rs
@@ -410,20 +410,20 @@ impl tr for Def {
 // ______________________________________________________________________
 // Encoding and decoding of freevar information
 
-fn encode_freevar_entry(rbml_w: &mut Encoder, fv: &ty::Freevar) {
+fn encode_freevar_entry(rbml_w: &mut Encoder, fv: &hir::Freevar) {
     (*fv).encode(rbml_w).unwrap();
 }
 
 trait rbml_decoder_helper {
     fn read_freevar_entry(&mut self, dcx: &DecodeContext)
-                          -> ty::Freevar;
+                          -> hir::Freevar;
     fn read_capture_mode(&mut self) -> hir::CaptureClause;
 }
 
 impl<'a> rbml_decoder_helper for reader::Decoder<'a> {
     fn read_freevar_entry(&mut self, dcx: &DecodeContext)
-                          -> ty::Freevar {
-        let fv: ty::Freevar = Decodable::decode(self).unwrap();
+                          -> hir::Freevar {
+        let fv: hir::Freevar = Decodable::decode(self).unwrap();
         fv.tr(dcx)
     }
 
@@ -433,9 +433,9 @@ impl<'a> rbml_decoder_helper for reader::Decoder<'a> {
     }
 }
 
-impl tr for ty::Freevar {
-    fn tr(&self, dcx: &DecodeContext) -> ty::Freevar {
-        ty::Freevar {
+impl tr for hir::Freevar {
+    fn tr(&self, dcx: &DecodeContext) -> hir::Freevar {
+        hir::Freevar {
             def: self.def.tr(dcx),
             span: self.span.tr(dcx),
         }
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs
index 7f748ef9b1e..12dcb32da3f 100644
--- a/src/librustc_mir/hair/cx/expr.rs
+++ b/src/librustc_mir/hair/cx/expr.rs
@@ -958,7 +958,7 @@ fn overloaded_lvalue<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
 
 fn capture_freevar<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
                                  closure_expr: &'tcx hir::Expr,
-                                 freevar: &ty::Freevar,
+                                 freevar: &hir::Freevar,
                                  freevar_ty: Ty<'tcx>)
                                  -> ExprRef<'tcx> {
     let id_var = freevar.def.var_id();
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 502b45c9453..299a8c0299d 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -56,8 +56,8 @@ use rustc::hir::def::*;
 use rustc::hir::def_id::DefId;
 use rustc::hir::pat_util::pat_bindings;
 use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace};
-use rustc::ty::{Freevar, FreevarMap, TraitMap, GlobMap};
-use rustc::util::nodemap::{NodeMap, FnvHashMap};
+use rustc::hir::{Freevar, FreevarMap, TraitMap, GlobMap};
+use rustc::util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
 
 use syntax::ast::{self, FloatTy};
 use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, IntTy, UintTy};
@@ -1186,7 +1186,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
 
             emit_errors: true,
             make_glob_map: make_glob_map == MakeGlobMap::Yes,
-            glob_map: HashMap::new(),
+            glob_map: NodeMap(),
 
             callback: None,
             resolved: false,
@@ -1253,7 +1253,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
             return;
         }
 
-        let mut new_set = HashSet::new();
+        let mut new_set = FnvHashSet();
         new_set.insert(name);
         self.glob_map.insert(import_id, new_set);
     }
diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs
index ab2276c324b..7f27d10ce1e 100644
--- a/src/librustc_typeck/lib.rs
+++ b/src/librustc_typeck/lib.rs
@@ -136,7 +136,7 @@ pub struct TypeAndSubsts<'tcx> {
 
 pub struct CrateCtxt<'a, 'tcx: 'a> {
     // A mapping from method call sites to traits that have that method.
-    pub trait_map: ty::TraitMap,
+    pub trait_map: hir::TraitMap,
     /// A vector of every trait accessible in the whole crate
     /// (i.e. including those from subcrates). This is used only for
     /// error reporting, and so is lazily initialised and generally
@@ -329,7 +329,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) {
     }
 }
 
-pub fn check_crate(tcx: &TyCtxt, trait_map: ty::TraitMap) -> CompileResult {
+pub fn check_crate(tcx: &TyCtxt, trait_map: hir::TraitMap) -> CompileResult {
     let time_passes = tcx.sess.time_passes();
     let ccx = CrateCtxt {
         trait_map: trait_map,