]> git.lizzy.rs Git - rust.git/commitdiff
rustc: move middle::{def,def_id,pat_util} to hir.
authorEduard Burtescu <edy.burt@gmail.com>
Tue, 29 Mar 2016 09:54:26 +0000 (12:54 +0300)
committerEduard Burtescu <edy.burt@gmail.com>
Wed, 6 Apr 2016 06:14:21 +0000 (09:14 +0300)
136 files changed:
src/librustc/cfg/construct.rs
src/librustc/dep_graph/mod.rs
src/librustc/hir/def.rs [new file with mode: 0644]
src/librustc/hir/def_id.rs [new file with mode: 0644]
src/librustc/hir/map/collector.rs
src/librustc/hir/map/definitions.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/hir/pat_util.rs [new file with mode: 0644]
src/librustc/infer/error_reporting.rs
src/librustc/infer/mod.rs
src/librustc/infer/type_variable.rs
src/librustc/lib.rs
src/librustc/middle/astconv_util.rs
src/librustc/middle/const_val.rs
src/librustc/middle/cstore.rs
src/librustc/middle/dead.rs
src/librustc/middle/def.rs [deleted file]
src/librustc/middle/def_id.rs [deleted file]
src/librustc/middle/effect.rs
src/librustc/middle/entry.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/pat_util.rs [deleted file]
src/librustc/middle/reachable.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/stability.rs
src/librustc/mir/repr.rs
src/librustc/mir/visit.rs
src/librustc/traits/coherence.rs
src/librustc/traits/error_reporting.rs
src/librustc/traits/mod.rs
src/librustc/traits/object_safety.rs
src/librustc/traits/project.rs
src/librustc/traits/select.rs
src/librustc/traits/specialize/mod.rs
src/librustc/traits/specialize/specialization_graph.rs
src/librustc/traits/util.rs
src/librustc/ty/contents.rs
src/librustc/ty/context.rs
src/librustc/ty/error.rs
src/librustc/ty/fast_reject.rs
src/librustc/ty/item_path.rs
src/librustc/ty/maps.rs
src/librustc/ty/mod.rs
src/librustc/ty/relate.rs
src/librustc/ty/sty.rs
src/librustc/ty/subst.rs
src/librustc/ty/trait_def.rs
src/librustc/ty/util.rs
src/librustc/ty/wf.rs
src/librustc/util/nodemap.rs
src/librustc/util/ppaux.rs
src/librustc_borrowck/borrowck/fragments.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/eval.rs
src/librustc_lint/bad_style.rs
src/librustc_lint/builtin.rs
src/librustc_lint/types.rs
src/librustc_lint/unused.rs
src/librustc_metadata/astencode.rs
src/librustc_metadata/csearch.rs
src/librustc_metadata/cstore.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_metadata/index.rs
src/librustc_metadata/tls_context.rs
src/librustc_metadata/tydecode.rs
src/librustc_metadata/tyencode.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/cx/pattern.rs
src/librustc_mir/hair/mod.rs
src/librustc_passes/consts.rs
src/librustc_passes/static_recursion.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs
src/librustc_save_analysis/csv_dumper.rs
src/librustc_save_analysis/data.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/lib.rs
src/librustc_trans/_match.rs
src/librustc_trans/assert_dep_graph.rs
src/librustc_trans/back/symbol_names.rs
src/librustc_trans/base.rs
src/librustc_trans/callee.rs
src/librustc_trans/closure.rs
src/librustc_trans/collector.rs
src/librustc_trans/common.rs
src/librustc_trans/consts.rs
src/librustc_trans/context.rs
src/librustc_trans/controlflow.rs
src/librustc_trans/debuginfo/create_scope_map.rs
src/librustc_trans/debuginfo/metadata.rs
src/librustc_trans/debuginfo/mod.rs
src/librustc_trans/debuginfo/namespace.rs
src/librustc_trans/debuginfo/type_names.rs
src/librustc_trans/debuginfo/utils.rs
src/librustc_trans/expr.rs
src/librustc_trans/inline.rs
src/librustc_trans/meth.rs
src/librustc_trans/monomorphize.rs
src/librustc_trans/type_of.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/op.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/coherence/overlap.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/librustc_typeck/variance/constraints.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/simplify.rs
src/librustdoc/core.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render.rs
src/librustdoc/passes.rs

index 13c3e3895b5d0bfaaed0b901e8e5115d11f57177..7049749135565e9832119f4a50bfde6585f43aad 100644 (file)
@@ -10,8 +10,8 @@
 
 use rustc_data_structures::graph;
 use cfg::*;
-use middle::def::Def;
-use middle::pat_util;
+use hir::def::Def;
+use hir::pat_util;
 use ty::{self, TyCtxt};
 use syntax::ast;
 use syntax::ptr::P;
index 70e7f675fcea9d92243bae1e06d5a203b868471e..55ec56a4bbe669a5597f42d630129cd9080b580e 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use self::thread::{DepGraphThreadData, DepMessage};
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use syntax::ast::NodeId;
 use ty::TyCtxt;
 use hir;
diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs
new file mode 100644 (file)
index 0000000..c270a44
--- /dev/null
@@ -0,0 +1,176 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use hir::def_id::DefId;
+use ty::subst::ParamSpace;
+use util::nodemap::NodeMap;
+use syntax::ast;
+use hir;
+
+#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+pub enum Def {
+    Fn(DefId),
+    SelfTy(Option<DefId>,                    // trait id
+              Option<(ast::NodeId, ast::NodeId)>),   // (impl id, self type id)
+    Mod(DefId),
+    ForeignMod(DefId),
+    Static(DefId, bool /* is_mutbl */),
+    Const(DefId),
+    AssociatedConst(DefId),
+    Local(DefId, // def id of variable
+             ast::NodeId), // node id of variable
+    Variant(DefId /* enum */, DefId /* variant */),
+    Enum(DefId),
+    TyAlias(DefId),
+    AssociatedTy(DefId /* trait */, DefId),
+    Trait(DefId),
+    PrimTy(hir::PrimTy),
+    TyParam(ParamSpace, u32, DefId, ast::Name),
+    Upvar(DefId,        // def id of closed over local
+             ast::NodeId,  // node id of closed over local
+             usize,        // index in the freevars list of the closure
+             ast::NodeId), // expr node that creates the closure
+
+    // If Def::Struct lives in type namespace it denotes a struct item and its DefId refers
+    // to NodeId of the struct itself.
+    // If Def::Struct lives in value namespace (e.g. tuple struct, unit struct expressions)
+    // it denotes a constructor and its DefId refers to NodeId of the struct's constructor.
+    Struct(DefId),
+    Label(ast::NodeId),
+    Method(DefId),
+    Err,
+}
+
+/// The result of resolving a path.
+/// Before type checking completes, `depth` represents the number of
+/// trailing segments which are yet unresolved. Afterwards, if there
+/// were no errors, all paths should be fully resolved, with `depth`
+/// set to `0` and `base_def` representing the final resolution.
+///
+///     module::Type::AssocX::AssocY::MethodOrAssocType
+///     ^~~~~~~~~~~~  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+///     base_def      depth = 3
+///
+///     <T as Trait>::AssocX::AssocY::MethodOrAssocType
+///           ^~~~~~~~~~~~~~  ^~~~~~~~~~~~~~~~~~~~~~~~~
+///           base_def        depth = 2
+#[derive(Copy, Clone, Debug)]
+pub struct PathResolution {
+    pub base_def: Def,
+    pub depth: usize
+}
+
+impl PathResolution {
+    /// Get the definition, if fully resolved, otherwise panic.
+    pub fn full_def(&self) -> Def {
+        if self.depth != 0 {
+            bug!("path not fully resolved: {:?}", self);
+        }
+        self.base_def
+    }
+
+    /// Get the DefId, if fully resolved, otherwise panic.
+    pub fn def_id(&self) -> DefId {
+        self.full_def().def_id()
+    }
+
+    pub fn new(base_def: Def,
+               depth: usize)
+               -> PathResolution {
+        PathResolution {
+            base_def: base_def,
+            depth: depth,
+        }
+    }
+}
+
+// Definition mapping
+pub type DefMap = NodeMap<PathResolution>;
+// This is the replacement export map. It maps a module to all of the exports
+// within.
+pub type ExportMap = NodeMap<Vec<Export>>;
+
+#[derive(Copy, Clone)]
+pub struct Export {
+    pub name: ast::Name,    // The name of the target.
+    pub def_id: DefId, // The definition of the target.
+}
+
+impl Def {
+    pub fn var_id(&self) -> ast::NodeId {
+        match *self {
+            Def::Local(_, id) |
+            Def::Upvar(_, id, _, _) => {
+                id
+            }
+
+            Def::Fn(..) | Def::Mod(..) | Def::ForeignMod(..) | Def::Static(..) |
+            Def::Variant(..) | Def::Enum(..) | Def::TyAlias(..) | Def::AssociatedTy(..) |
+            Def::TyParam(..) | Def::Struct(..) | Def::Trait(..) |
+            Def::Method(..) | Def::Const(..) | Def::AssociatedConst(..) |
+            Def::PrimTy(..) | Def::Label(..) | Def::SelfTy(..) | Def::Err => {
+                bug!("attempted .var_id() on invalid {:?}", self)
+            }
+        }
+    }
+
+    pub fn def_id(&self) -> DefId {
+        match *self {
+            Def::Fn(id) | Def::Mod(id) | Def::ForeignMod(id) | Def::Static(id, _) |
+            Def::Variant(_, id) | Def::Enum(id) | Def::TyAlias(id) | Def::AssociatedTy(_, id) |
+            Def::TyParam(_, _, id, _) | Def::Struct(id) | Def::Trait(id) |
+            Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) |
+            Def::Local(id, _) | Def::Upvar(id, _, _, _) => {
+                id
+            }
+
+            Def::Label(..)  |
+            Def::PrimTy(..) |
+            Def::SelfTy(..) |
+            Def::Err => {
+                bug!("attempted .def_id() on invalid def: {:?}", self)
+            }
+        }
+    }
+
+    pub fn variant_def_ids(&self) -> Option<(DefId, DefId)> {
+        match *self {
+            Def::Variant(enum_id, var_id) => {
+                Some((enum_id, var_id))
+            }
+            _ => None
+        }
+    }
+
+    pub fn kind_name(&self) -> &'static str {
+        match *self {
+            Def::Fn(..) => "function",
+            Def::Mod(..) => "module",
+            Def::ForeignMod(..) => "foreign module",
+            Def::Static(..) => "static",
+            Def::Variant(..) => "variant",
+            Def::Enum(..) => "enum",
+            Def::TyAlias(..) => "type",
+            Def::AssociatedTy(..) => "associated type",
+            Def::Struct(..) => "struct",
+            Def::Trait(..) => "trait",
+            Def::Method(..) => "method",
+            Def::Const(..) => "const",
+            Def::AssociatedConst(..) => "associated const",
+            Def::TyParam(..) => "type parameter",
+            Def::PrimTy(..) => "builtin type",
+            Def::Local(..) => "local variable",
+            Def::Upvar(..) => "closure capture",
+            Def::Label(..) => "label",
+            Def::SelfTy(..) => "self type",
+            Def::Err => "unresolved item",
+        }
+    }
+}
diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs
new file mode 100644 (file)
index 0000000..a3b83ec
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use middle::cstore::LOCAL_CRATE;
+use ty;
+use syntax::ast::CrateNum;
+use std::fmt;
+use std::u32;
+
+/// A DefIndex is an index into the hir-map for a crate, identifying a
+/// particular definition. It should really be considered an interned
+/// shorthand for a particular DefPath.
+#[derive(Clone, Debug, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
+           RustcDecodable, Hash, Copy)]
+pub struct DefIndex(u32);
+
+impl DefIndex {
+    pub fn new(x: usize) -> DefIndex {
+        assert!(x < (u32::MAX as usize));
+        DefIndex(x as u32)
+    }
+
+    pub fn from_u32(x: u32) -> DefIndex {
+        DefIndex(x)
+    }
+
+    pub fn as_usize(&self) -> usize {
+        self.0 as usize
+    }
+
+    pub fn as_u32(&self) -> u32 {
+        self.0
+    }
+}
+
+/// The crate root is always assigned index 0 by the AST Map code,
+/// thanks to `NodeCollector::new`.
+pub const CRATE_DEF_INDEX: DefIndex = DefIndex(0);
+
+/// A DefId identifies a particular *definition*, by combining a crate
+/// index and a def index.
+#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
+           RustcDecodable, Hash, Copy)]
+pub struct DefId {
+    pub krate: CrateNum,
+    pub index: DefIndex,
+}
+
+impl fmt::Debug for DefId {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "DefId {{ krate: {:?}, node: {:?}",
+               self.krate, self.index)?;
+
+        // Unfortunately, there seems to be no way to attempt to print
+        // a path for a def-id, so I'll just make a best effort for now
+        // and otherwise fallback to just printing the crate/node pair
+        if self.is_local() { // (1)
+            // (1) side-step fact that not all external things have paths at
+            // the moment, such as type parameters
+            ty::tls::with_opt(|opt_tcx| {
+                if let Some(tcx) = opt_tcx {
+                    write!(f, " => {}", tcx.item_path_str(*self))?;
+                }
+                Ok(())
+            })?;
+        }
+
+        write!(f, " }}")
+    }
+}
+
+
+impl DefId {
+    pub fn local(index: DefIndex) -> DefId {
+        DefId { krate: LOCAL_CRATE, index: index }
+    }
+
+    pub fn is_local(&self) -> bool {
+        self.krate == LOCAL_CRATE
+    }
+}
index 62c80c9c8bbc38fcd700d46b5fb7a85ae2294036..b1a084ac7994e5634df0cb568d6d223a592c68ee 100644 (file)
@@ -13,7 +13,7 @@
 
 use hir::*;
 use hir::intravisit::Visitor;
-use middle::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
+use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
 use std::iter::repeat;
 use syntax::ast::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
 use syntax::codemap::Span;
index 82574b852297aba88db676c7186203bc0f1c0d07..d045313cb1e972f29925baebde6e5a52beab816f 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use middle::cstore::LOCAL_CRATE;
-use middle::def_id::{DefId, DefIndex};
+use hir::def_id::{DefId, DefIndex};
 use rustc_data_structures::fnv::FnvHashMap;
 use syntax::ast;
 use syntax::parse::token::InternedString;
index 4325be9b9a43b1edf41efe7c9044b5223f354d9e..4096606b001d6fb89b7d8da4f0d456958ace3f72 100644 (file)
@@ -19,7 +19,7 @@
 
 use middle::cstore::InlinedItem;
 use middle::cstore::InlinedItem as II;
-use middle::def_id::{CRATE_DEF_INDEX, DefId};
+use hir::def_id::{CRATE_DEF_INDEX, DefId};
 
 use syntax::abi::Abi;
 use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID};
index cb3cdd0b8258d8be5f508c766570a59a063d46c1..10fe86246de6996e2f0cc59f931e64505479d74c 100644 (file)
@@ -63,10 +63,13 @@ macro_rules! hir_vec {
 }
 
 pub mod check_attr;
+pub mod def;
+pub mod def_id;
 pub mod fold;
 pub mod intravisit;
 pub mod lowering;
 pub mod map;
+pub mod pat_util;
 pub mod print;
 pub mod svh;
 
diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs
new file mode 100644 (file)
index 0000000..5eb4d53
--- /dev/null
@@ -0,0 +1,246 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use hir::def::*;
+use hir::def_id::DefId;
+use ty::TyCtxt;
+use util::nodemap::FnvHashMap;
+
+use syntax::ast;
+use hir::{self, PatKind};
+use syntax::codemap::{respan, Span, Spanned, DUMMY_SP};
+
+use std::cell::RefCell;
+
+pub type PatIdMap = FnvHashMap<ast::Name, ast::NodeId>;
+
+// This is used because same-named variables in alternative patterns need to
+// use the NodeId of their namesake in the first pattern.
+pub fn pat_id_map(dm: &RefCell<DefMap>, pat: &hir::Pat) -> PatIdMap {
+    let mut map = FnvHashMap();
+    pat_bindings(dm, pat, |_bm, p_id, _s, path1| {
+        map.insert(path1.node, p_id);
+    });
+    map
+}
+
+pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::Lit(_) | PatKind::Range(_, _) | PatKind::QPath(..) => true,
+        PatKind::TupleStruct(..) |
+        PatKind::Path(..) |
+        PatKind::Ident(_, _, None) |
+        PatKind::Struct(..) => {
+            match dm.get(&pat.id).map(|d| d.full_def()) {
+                Some(Def::Variant(..)) => true,
+                _ => false
+            }
+        }
+        PatKind::Vec(_, _, _) => true,
+        _ => false
+    }
+}
+
+pub fn pat_is_variant_or_struct(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::TupleStruct(..) |
+        PatKind::Path(..) |
+        PatKind::Ident(_, _, None) |
+        PatKind::Struct(..) => {
+            match dm.get(&pat.id).map(|d| d.full_def()) {
+                Some(Def::Variant(..)) | Some(Def::Struct(..)) | Some(Def::TyAlias(..)) => true,
+                _ => false
+            }
+        }
+        _ => false
+    }
+}
+
+pub fn pat_is_const(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::Ident(_, _, None) | PatKind::Path(..) | PatKind::QPath(..) => {
+            match dm.get(&pat.id).map(|d| d.full_def()) {
+                Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
+                _ => false
+            }
+        }
+        _ => false
+    }
+}
+
+// Same as above, except that partially-resolved defs cause `false` to be
+// returned instead of a panic.
+pub fn pat_is_resolved_const(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::Ident(_, _, None) | PatKind::Path(..) | PatKind::QPath(..) => {
+            match dm.get(&pat.id)
+                    .and_then(|d| if d.depth == 0 { Some(d.base_def) }
+                                  else { None } ) {
+                Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
+                _ => false
+            }
+        }
+        _ => false
+    }
+}
+
+pub fn pat_is_binding(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::Ident(..) => {
+            !pat_is_variant_or_struct(dm, pat) &&
+            !pat_is_const(dm, pat)
+        }
+        _ => false
+    }
+}
+
+pub fn pat_is_binding_or_wild(dm: &DefMap, pat: &hir::Pat) -> bool {
+    match pat.node {
+        PatKind::Ident(..) => pat_is_binding(dm, pat),
+        PatKind::Wild => true,
+        _ => false
+    }
+}
+
+/// Call `it` on every "binding" in a pattern, e.g., on `a` in
+/// `match foo() { Some(a) => (), None => () }`
+pub fn pat_bindings<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
+    I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<ast::Name>),
+{
+    pat.walk(|p| {
+        match p.node {
+          PatKind::Ident(binding_mode, ref pth, _) if pat_is_binding(&dm.borrow(), p) => {
+            it(binding_mode, p.id, p.span, &respan(pth.span, pth.node.name));
+          }
+          _ => {}
+        }
+        true
+    });
+}
+pub fn pat_bindings_ident<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
+    I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<hir::Ident>),
+{
+    pat.walk(|p| {
+        match p.node {
+          PatKind::Ident(binding_mode, ref pth, _) if pat_is_binding(&dm.borrow(), p) => {
+            it(binding_mode, p.id, p.span, &respan(pth.span, pth.node));
+          }
+          _ => {}
+        }
+        true
+    });
+}
+
+/// Checks if the pattern contains any patterns that bind something to
+/// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
+pub fn pat_contains_bindings(dm: &DefMap, pat: &hir::Pat) -> bool {
+    let mut contains_bindings = false;
+    pat.walk(|p| {
+        if pat_is_binding(dm, p) {
+            contains_bindings = true;
+            false // there's at least one binding, can short circuit now.
+        } else {
+            true
+        }
+    });
+    contains_bindings
+}
+
+/// Checks if the pattern contains any `ref` or `ref mut` bindings,
+/// and if yes whether its containing mutable ones or just immutables ones.
+pub fn pat_contains_ref_binding(dm: &RefCell<DefMap>, pat: &hir::Pat) -> Option<hir::Mutability> {
+    let mut result = None;
+    pat_bindings(dm, pat, |mode, _, _, _| {
+        match mode {
+            hir::BindingMode::BindByRef(m) => {
+                // Pick Mutable as maximum
+                match result {
+                    None | Some(hir::MutImmutable) => result = Some(m),
+                    _ => (),
+                }
+            }
+            hir::BindingMode::BindByValue(_) => { }
+        }
+    });
+    result
+}
+
+/// Checks if the patterns for this arm contain any `ref` or `ref mut`
+/// bindings, and if yes whether its containing mutable ones or just immutables ones.
+pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<hir::Mutability> {
+    arm.pats.iter()
+            .filter_map(|pat| pat_contains_ref_binding(dm, pat))
+            .max_by_key(|m| match *m {
+                hir::MutMutable => 1,
+                hir::MutImmutable => 0,
+            })
+}
+
+/// Checks if the pattern contains any patterns that bind something to
+/// an ident or wildcard, e.g. `foo`, or `Foo(_)`, `foo @ Bar(..)`,
+pub fn pat_contains_bindings_or_wild(dm: &DefMap, pat: &hir::Pat) -> bool {
+    let mut contains_bindings = false;
+    pat.walk(|p| {
+        if pat_is_binding_or_wild(dm, p) {
+            contains_bindings = true;
+            false // there's at least one binding/wildcard, can short circuit now.
+        } else {
+            true
+        }
+    });
+    contains_bindings
+}
+
+pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
+    match pat.node {
+        PatKind::Ident(hir::BindByValue(_), ref path1, None) => {
+            Some(path1.node.name)
+        }
+        _ => {
+            None
+        }
+    }
+}
+
+pub fn def_to_path(tcx: &TyCtxt, id: DefId) -> hir::Path {
+    tcx.with_path(id, |path| hir::Path {
+        global: false,
+        segments: path.last().map(|elem| hir::PathSegment {
+            identifier: hir::Ident::from_name(elem.name()),
+            parameters: hir::PathParameters::none(),
+        }).into_iter().collect(),
+        span: DUMMY_SP,
+    })
+}
+
+/// Return variants that are necessary to exist for the pattern to match.
+pub fn necessary_variants(dm: &DefMap, pat: &hir::Pat) -> Vec<DefId> {
+    let mut variants = vec![];
+    pat.walk(|p| {
+        match p.node {
+            PatKind::TupleStruct(..) |
+            PatKind::Path(..) |
+            PatKind::Ident(_, _, None) |
+            PatKind::Struct(..) => {
+                match dm.get(&p.id) {
+                    Some(&PathResolution { base_def: Def::Variant(_, id), .. }) => {
+                        variants.push(id);
+                    }
+                    _ => ()
+                }
+            }
+            _ => ()
+        }
+        true
+    });
+    variants.sort();
+    variants.dedup();
+    variants
+}
index c0c63ac5042fb45013cc6fc018763708858fc16d..5a0d9ec13322ffb04f79a7aa653f4d80cef8fa0c 100644 (file)
@@ -78,8 +78,8 @@
 use hir::print as pprust;
 
 use middle::cstore::CrateStore;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use infer::{self, TypeOrigin};
 use middle::region;
 use ty::subst;
index 427ff88b8f24b04c009577527d51781cddfd9c34..4c1216aa8626ad406c711edf37e4b50befac0b6e 100644 (file)
@@ -18,7 +18,7 @@
 pub use self::freshen::TypeFreshener;
 pub use self::region_inference::{GenericKind, VerifyBound};
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use hir;
 use middle::free_region::FreeRegionMap;
 use middle::mem_categorization as mc;
index 3cc076f1f00be2343710241fd0c0ff7a5b0bcb9c..c2a8d04ac00da6a6ed40c98a515f7029565f2cf7 100644 (file)
@@ -11,7 +11,7 @@
 pub use self::RelationDir::*;
 use self::TypeVariableValue::*;
 use self::UndoEntry::*;
-use middle::def_id::{DefId};
+use hir::def_id::{DefId};
 use ty::{self, Ty};
 use syntax::codemap::Span;
 
index 291eab30decbf927ce97a1eb40de621b1993ce15..deb206277722071cfbd8f903aca237d5f9b67a56 100644 (file)
@@ -86,8 +86,6 @@ pub mod middle {
     pub mod cstore;
     pub mod dataflow;
     pub mod dead;
-    pub mod def;
-    pub mod def_id;
     pub mod dependency_format;
     pub mod effect;
     pub mod entry;
@@ -96,7 +94,6 @@ pub mod middle {
     pub mod lang_items;
     pub mod liveness;
     pub mod mem_categorization;
-    pub mod pat_util;
     pub mod privacy;
     pub mod reachable;
     pub mod region;
index 871440a7e54ff03dd51bcce848dd521110c24020..2a27732b9532cdb83014ab3d6faac6e44ce859cf 100644 (file)
@@ -14,7 +14,7 @@
  * Almost certainly this could (and should) be refactored out of existence.
  */
 
-use middle::def::Def;
+use hir::def::Def;
 use ty::{Ty, TyCtxt};
 
 use syntax::codemap::Span;
index a939389c460ea71d4dd65b5dfe00ba6b12b98c9e..3621cb267d91f9dfb079fc15d6fbebecf8532c1c 100644 (file)
@@ -11,7 +11,7 @@
 use syntax::parse::token::InternedString;
 use syntax::ast;
 use std::rc::Rc;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use std::hash;
 use std::mem::transmute;
 use rustc_const_math::*;
index a7f415ef2a08aa7e369008884ee41bd910897e3e..027792b7439952851765492e403941498d473c46 100644 (file)
 
 use hir::svh::Svh;
 use hir::map as hir_map;
-use middle::def::{self, Def};
+use hir::def::{self, Def};
 use middle::lang_items;
 use ty::{self, Ty, TyCtxt, VariantKind};
-use middle::def_id::{DefId, DefIndex};
+use hir::def_id::{DefId, DefIndex};
 use mir::repr::Mir;
 use mir::mir_map::MirMap;
 use session::Session;
@@ -504,7 +504,7 @@ pub mod tls {
     use std::mem;
     use ty::{self, Ty, TyCtxt};
     use ty::subst::Substs;
-    use middle::def_id::DefId;
+    use hir::def_id::DefId;
 
     pub trait EncodingContext<'tcx> {
         fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>;
index b7b6279270cb4fd16a39ad660ec45595cd1e98a7..dcdc02c9df6097d62f26c935da6f4552fd7ad586 100644 (file)
 
 use dep_graph::DepNode;
 use hir::map as ast_map;
-use hir::{self, PatKind};
+use hir::{self, pat_util, PatKind};
 use hir::intravisit::{self, Visitor};
 
-use middle::{pat_util, privacy};
+use middle::privacy;
 use ty::{self, TyCtxt};
-use middle::def::Def;
-use middle::def_id::{DefId};
+use hir::def::Def;
+use hir::def_id::{DefId};
 use lint;
 
 use std::collections::HashSet;
diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs
deleted file mode 100644 (file)
index ee6e747..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use middle::def_id::DefId;
-use ty::subst::ParamSpace;
-use util::nodemap::NodeMap;
-use syntax::ast;
-use hir;
-
-#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Def {
-    Fn(DefId),
-    SelfTy(Option<DefId>,                    // trait id
-              Option<(ast::NodeId, ast::NodeId)>),   // (impl id, self type id)
-    Mod(DefId),
-    ForeignMod(DefId),
-    Static(DefId, bool /* is_mutbl */),
-    Const(DefId),
-    AssociatedConst(DefId),
-    Local(DefId, // def id of variable
-             ast::NodeId), // node id of variable
-    Variant(DefId /* enum */, DefId /* variant */),
-    Enum(DefId),
-    TyAlias(DefId),
-    AssociatedTy(DefId /* trait */, DefId),
-    Trait(DefId),
-    PrimTy(hir::PrimTy),
-    TyParam(ParamSpace, u32, DefId, ast::Name),
-    Upvar(DefId,        // def id of closed over local
-             ast::NodeId,  // node id of closed over local
-             usize,        // index in the freevars list of the closure
-             ast::NodeId), // expr node that creates the closure
-
-    // If Def::Struct lives in type namespace it denotes a struct item and its DefId refers
-    // to NodeId of the struct itself.
-    // If Def::Struct lives in value namespace (e.g. tuple struct, unit struct expressions)
-    // it denotes a constructor and its DefId refers to NodeId of the struct's constructor.
-    Struct(DefId),
-    Label(ast::NodeId),
-    Method(DefId),
-    Err,
-}
-
-/// The result of resolving a path.
-/// Before type checking completes, `depth` represents the number of
-/// trailing segments which are yet unresolved. Afterwards, if there
-/// were no errors, all paths should be fully resolved, with `depth`
-/// set to `0` and `base_def` representing the final resolution.
-///
-///     module::Type::AssocX::AssocY::MethodOrAssocType
-///     ^~~~~~~~~~~~  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-///     base_def      depth = 3
-///
-///     <T as Trait>::AssocX::AssocY::MethodOrAssocType
-///           ^~~~~~~~~~~~~~  ^~~~~~~~~~~~~~~~~~~~~~~~~
-///           base_def        depth = 2
-#[derive(Copy, Clone, Debug)]
-pub struct PathResolution {
-    pub base_def: Def,
-    pub depth: usize
-}
-
-impl PathResolution {
-    /// Get the definition, if fully resolved, otherwise panic.
-    pub fn full_def(&self) -> Def {
-        if self.depth != 0 {
-            bug!("path not fully resolved: {:?}", self);
-        }
-        self.base_def
-    }
-
-    /// Get the DefId, if fully resolved, otherwise panic.
-    pub fn def_id(&self) -> DefId {
-        self.full_def().def_id()
-    }
-
-    pub fn new(base_def: Def,
-               depth: usize)
-               -> PathResolution {
-        PathResolution {
-            base_def: base_def,
-            depth: depth,
-        }
-    }
-}
-
-// Definition mapping
-pub type DefMap = NodeMap<PathResolution>;
-// This is the replacement export map. It maps a module to all of the exports
-// within.
-pub type ExportMap = NodeMap<Vec<Export>>;
-
-#[derive(Copy, Clone)]
-pub struct Export {
-    pub name: ast::Name,    // The name of the target.
-    pub def_id: DefId, // The definition of the target.
-}
-
-impl Def {
-    pub fn var_id(&self) -> ast::NodeId {
-        match *self {
-            Def::Local(_, id) |
-            Def::Upvar(_, id, _, _) => {
-                id
-            }
-
-            Def::Fn(..) | Def::Mod(..) | Def::ForeignMod(..) | Def::Static(..) |
-            Def::Variant(..) | Def::Enum(..) | Def::TyAlias(..) | Def::AssociatedTy(..) |
-            Def::TyParam(..) | Def::Struct(..) | Def::Trait(..) |
-            Def::Method(..) | Def::Const(..) | Def::AssociatedConst(..) |
-            Def::PrimTy(..) | Def::Label(..) | Def::SelfTy(..) | Def::Err => {
-                bug!("attempted .var_id() on invalid {:?}", self)
-            }
-        }
-    }
-
-    pub fn def_id(&self) -> DefId {
-        match *self {
-            Def::Fn(id) | Def::Mod(id) | Def::ForeignMod(id) | Def::Static(id, _) |
-            Def::Variant(_, id) | Def::Enum(id) | Def::TyAlias(id) | Def::AssociatedTy(_, id) |
-            Def::TyParam(_, _, id, _) | Def::Struct(id) | Def::Trait(id) |
-            Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) |
-            Def::Local(id, _) | Def::Upvar(id, _, _, _) => {
-                id
-            }
-
-            Def::Label(..)  |
-            Def::PrimTy(..) |
-            Def::SelfTy(..) |
-            Def::Err => {
-                bug!("attempted .def_id() on invalid def: {:?}", self)
-            }
-        }
-    }
-
-    pub fn variant_def_ids(&self) -> Option<(DefId, DefId)> {
-        match *self {
-            Def::Variant(enum_id, var_id) => {
-                Some((enum_id, var_id))
-            }
-            _ => None
-        }
-    }
-
-    pub fn kind_name(&self) -> &'static str {
-        match *self {
-            Def::Fn(..) => "function",
-            Def::Mod(..) => "module",
-            Def::ForeignMod(..) => "foreign module",
-            Def::Static(..) => "static",
-            Def::Variant(..) => "variant",
-            Def::Enum(..) => "enum",
-            Def::TyAlias(..) => "type",
-            Def::AssociatedTy(..) => "associated type",
-            Def::Struct(..) => "struct",
-            Def::Trait(..) => "trait",
-            Def::Method(..) => "method",
-            Def::Const(..) => "const",
-            Def::AssociatedConst(..) => "associated const",
-            Def::TyParam(..) => "type parameter",
-            Def::PrimTy(..) => "builtin type",
-            Def::Local(..) => "local variable",
-            Def::Upvar(..) => "closure capture",
-            Def::Label(..) => "label",
-            Def::SelfTy(..) => "self type",
-            Def::Err => "unresolved item",
-        }
-    }
-}
diff --git a/src/librustc/middle/def_id.rs b/src/librustc/middle/def_id.rs
deleted file mode 100644 (file)
index a3b83ec..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use middle::cstore::LOCAL_CRATE;
-use ty;
-use syntax::ast::CrateNum;
-use std::fmt;
-use std::u32;
-
-/// A DefIndex is an index into the hir-map for a crate, identifying a
-/// particular definition. It should really be considered an interned
-/// shorthand for a particular DefPath.
-#[derive(Clone, Debug, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
-           RustcDecodable, Hash, Copy)]
-pub struct DefIndex(u32);
-
-impl DefIndex {
-    pub fn new(x: usize) -> DefIndex {
-        assert!(x < (u32::MAX as usize));
-        DefIndex(x as u32)
-    }
-
-    pub fn from_u32(x: u32) -> DefIndex {
-        DefIndex(x)
-    }
-
-    pub fn as_usize(&self) -> usize {
-        self.0 as usize
-    }
-
-    pub fn as_u32(&self) -> u32 {
-        self.0
-    }
-}
-
-/// The crate root is always assigned index 0 by the AST Map code,
-/// thanks to `NodeCollector::new`.
-pub const CRATE_DEF_INDEX: DefIndex = DefIndex(0);
-
-/// A DefId identifies a particular *definition*, by combining a crate
-/// index and a def index.
-#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
-           RustcDecodable, Hash, Copy)]
-pub struct DefId {
-    pub krate: CrateNum,
-    pub index: DefIndex,
-}
-
-impl fmt::Debug for DefId {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "DefId {{ krate: {:?}, node: {:?}",
-               self.krate, self.index)?;
-
-        // Unfortunately, there seems to be no way to attempt to print
-        // a path for a def-id, so I'll just make a best effort for now
-        // and otherwise fallback to just printing the crate/node pair
-        if self.is_local() { // (1)
-            // (1) side-step fact that not all external things have paths at
-            // the moment, such as type parameters
-            ty::tls::with_opt(|opt_tcx| {
-                if let Some(tcx) = opt_tcx {
-                    write!(f, " => {}", tcx.item_path_str(*self))?;
-                }
-                Ok(())
-            })?;
-        }
-
-        write!(f, " }}")
-    }
-}
-
-
-impl DefId {
-    pub fn local(index: DefIndex) -> DefId {
-        DefId { krate: LOCAL_CRATE, index: index }
-    }
-
-    pub fn is_local(&self) -> bool {
-        self.krate == LOCAL_CRATE
-    }
-}
index e4c93dfdb931921c7c261073db409c41a85ba2c7..ac7a1b8aa0de5bae1abdc4ceec40a891161efd99 100644 (file)
@@ -13,7 +13,7 @@
 use self::RootUnsafeContext::*;
 
 use dep_graph::DepNode;
-use middle::def::Def;
+use hir::def::Def;
 use ty::{self, Ty, TyCtxt};
 use ty::MethodCall;
 
index 4a64980fcdd5a1dbf0ce25c8b246379119f3d5fa..602889375e970250cb6756d1f751d1769e829416 100644 (file)
@@ -11,7 +11,7 @@
 
 use dep_graph::DepNode;
 use hir::map as ast_map;
-use middle::def_id::{CRATE_DEF_INDEX};
+use hir::def_id::{CRATE_DEF_INDEX};
 use session::{config, Session};
 use syntax::ast::NodeId;
 use syntax::attr;
index 1b9673773041bd18e86c7ada06f7489be40df26d..c4d6f100671b003514707e4a7a524b20dab545c6 100644 (file)
@@ -19,9 +19,9 @@
 use self::TrackMatchMode::*;
 use self::OverloadedCallType::*;
 
-use middle::pat_util;
-use middle::def::Def;
-use middle::def_id::{DefId};
+use hir::pat_util;
+use hir::def::Def;
+use hir::def_id::{DefId};
 use infer;
 use middle::mem_categorization as mc;
 use ty::{self, TyCtxt, adjustment};
index 354a6c5e13bca5831ea55115ad3b85b012cfe4a5..767c5adc81e25b5ff44d23b3aa5dd613d49bdfd7 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 use dep_graph::DepNode;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use ty::subst::{Subst, Substs, EnumeratedItems};
 use ty::{TransmuteRestriction, TyCtxt};
 use ty::{self, Ty, TypeFoldable};
index 7aad106c4ed445049884f07d04625461293593ce..86531ced8dfae41e1f174074ef3682c9e97d7bc2 100644 (file)
@@ -25,7 +25,7 @@
 use hir::map as hir_map;
 use session::Session;
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty;
 use middle::weak_lang_items;
 use util::nodemap::FnvHashMap;
index 72d3c9414a4086d58fcb2235636b1364e5929541..35991ae56c8a1477097bd30f065c7aa99acf23d9 100644 (file)
 use self::VarKind::*;
 
 use dep_graph::DepNode;
-use middle::def::*;
-use middle::pat_util;
+use hir::def::*;
+use hir::pat_util;
 use ty::{self, TyCtxt, ParameterEnvironment};
 use traits::{self, ProjectionMode};
 use infer;
index 7260bdde3ee710cb266973c1ee3a8461b702b664..2f77552c389ad4e710dccd924512bb5532d045f0 100644 (file)
 
 use self::Aliasability::*;
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use hir::map as ast_map;
 use infer;
 use middle::const_qualif::ConstQualif;
-use middle::def::Def;
+use hir::def::Def;
 use ty::adjustment;
 use ty::{self, Ty, TyCtxt};
 
diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs
deleted file mode 100644 (file)
index 3c60d54..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use middle::def::*;
-use middle::def_id::DefId;
-use ty::TyCtxt;
-use util::nodemap::FnvHashMap;
-
-use syntax::ast;
-use hir::{self, PatKind};
-use syntax::codemap::{respan, Span, Spanned, DUMMY_SP};
-
-use std::cell::RefCell;
-
-pub type PatIdMap = FnvHashMap<ast::Name, ast::NodeId>;
-
-// This is used because same-named variables in alternative patterns need to
-// use the NodeId of their namesake in the first pattern.
-pub fn pat_id_map(dm: &RefCell<DefMap>, pat: &hir::Pat) -> PatIdMap {
-    let mut map = FnvHashMap();
-    pat_bindings(dm, pat, |_bm, p_id, _s, path1| {
-        map.insert(path1.node, p_id);
-    });
-    map
-}
-
-pub fn pat_is_refutable(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::Lit(_) | PatKind::Range(_, _) | PatKind::QPath(..) => true,
-        PatKind::TupleStruct(..) |
-        PatKind::Path(..) |
-        PatKind::Ident(_, _, None) |
-        PatKind::Struct(..) => {
-            match dm.get(&pat.id).map(|d| d.full_def()) {
-                Some(Def::Variant(..)) => true,
-                _ => false
-            }
-        }
-        PatKind::Vec(_, _, _) => true,
-        _ => false
-    }
-}
-
-pub fn pat_is_variant_or_struct(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::TupleStruct(..) |
-        PatKind::Path(..) |
-        PatKind::Ident(_, _, None) |
-        PatKind::Struct(..) => {
-            match dm.get(&pat.id).map(|d| d.full_def()) {
-                Some(Def::Variant(..)) | Some(Def::Struct(..)) | Some(Def::TyAlias(..)) => true,
-                _ => false
-            }
-        }
-        _ => false
-    }
-}
-
-pub fn pat_is_const(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::Ident(_, _, None) | PatKind::Path(..) | PatKind::QPath(..) => {
-            match dm.get(&pat.id).map(|d| d.full_def()) {
-                Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
-                _ => false
-            }
-        }
-        _ => false
-    }
-}
-
-// Same as above, except that partially-resolved defs cause `false` to be
-// returned instead of a panic.
-pub fn pat_is_resolved_const(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::Ident(_, _, None) | PatKind::Path(..) | PatKind::QPath(..) => {
-            match dm.get(&pat.id)
-                    .and_then(|d| if d.depth == 0 { Some(d.base_def) }
-                                  else { None } ) {
-                Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
-                _ => false
-            }
-        }
-        _ => false
-    }
-}
-
-pub fn pat_is_binding(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::Ident(..) => {
-            !pat_is_variant_or_struct(dm, pat) &&
-            !pat_is_const(dm, pat)
-        }
-        _ => false
-    }
-}
-
-pub fn pat_is_binding_or_wild(dm: &DefMap, pat: &hir::Pat) -> bool {
-    match pat.node {
-        PatKind::Ident(..) => pat_is_binding(dm, pat),
-        PatKind::Wild => true,
-        _ => false
-    }
-}
-
-/// Call `it` on every "binding" in a pattern, e.g., on `a` in
-/// `match foo() { Some(a) => (), None => () }`
-pub fn pat_bindings<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
-    I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<ast::Name>),
-{
-    pat.walk(|p| {
-        match p.node {
-          PatKind::Ident(binding_mode, ref pth, _) if pat_is_binding(&dm.borrow(), p) => {
-            it(binding_mode, p.id, p.span, &respan(pth.span, pth.node.name));
-          }
-          _ => {}
-        }
-        true
-    });
-}
-pub fn pat_bindings_ident<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
-    I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<hir::Ident>),
-{
-    pat.walk(|p| {
-        match p.node {
-          PatKind::Ident(binding_mode, ref pth, _) if pat_is_binding(&dm.borrow(), p) => {
-            it(binding_mode, p.id, p.span, &respan(pth.span, pth.node));
-          }
-          _ => {}
-        }
-        true
-    });
-}
-
-/// Checks if the pattern contains any patterns that bind something to
-/// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
-pub fn pat_contains_bindings(dm: &DefMap, pat: &hir::Pat) -> bool {
-    let mut contains_bindings = false;
-    pat.walk(|p| {
-        if pat_is_binding(dm, p) {
-            contains_bindings = true;
-            false // there's at least one binding, can short circuit now.
-        } else {
-            true
-        }
-    });
-    contains_bindings
-}
-
-/// Checks if the pattern contains any `ref` or `ref mut` bindings,
-/// and if yes whether its containing mutable ones or just immutables ones.
-pub fn pat_contains_ref_binding(dm: &RefCell<DefMap>, pat: &hir::Pat) -> Option<hir::Mutability> {
-    let mut result = None;
-    pat_bindings(dm, pat, |mode, _, _, _| {
-        match mode {
-            hir::BindingMode::BindByRef(m) => {
-                // Pick Mutable as maximum
-                match result {
-                    None | Some(hir::MutImmutable) => result = Some(m),
-                    _ => (),
-                }
-            }
-            hir::BindingMode::BindByValue(_) => { }
-        }
-    });
-    result
-}
-
-/// Checks if the patterns for this arm contain any `ref` or `ref mut`
-/// bindings, and if yes whether its containing mutable ones or just immutables ones.
-pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<hir::Mutability> {
-    arm.pats.iter()
-            .filter_map(|pat| pat_contains_ref_binding(dm, pat))
-            .max_by_key(|m| match *m {
-                hir::MutMutable => 1,
-                hir::MutImmutable => 0,
-            })
-}
-
-/// Checks if the pattern contains any patterns that bind something to
-/// an ident or wildcard, e.g. `foo`, or `Foo(_)`, `foo @ Bar(..)`,
-pub fn pat_contains_bindings_or_wild(dm: &DefMap, pat: &hir::Pat) -> bool {
-    let mut contains_bindings = false;
-    pat.walk(|p| {
-        if pat_is_binding_or_wild(dm, p) {
-            contains_bindings = true;
-            false // there's at least one binding/wildcard, can short circuit now.
-        } else {
-            true
-        }
-    });
-    contains_bindings
-}
-
-pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
-    match pat.node {
-        PatKind::Ident(hir::BindByValue(_), ref path1, None) => {
-            Some(path1.node.name)
-        }
-        _ => {
-            None
-        }
-    }
-}
-
-pub fn def_to_path(tcx: &TyCtxt, id: DefId) -> hir::Path {
-    tcx.with_path(id, |path| hir::Path {
-        global: false,
-        segments: path.last().map(|elem| hir::PathSegment {
-            identifier: hir::Ident::from_name(elem.name()),
-            parameters: hir::PathParameters::none(),
-        }).into_iter().collect(),
-        span: DUMMY_SP,
-    })
-}
-
-/// Return variants that are necessary to exist for the pattern to match.
-pub fn necessary_variants(dm: &DefMap, pat: &hir::Pat) -> Vec<DefId> {
-    let mut variants = vec![];
-    pat.walk(|p| {
-        match p.node {
-            PatKind::TupleStruct(..) |
-            PatKind::Path(..) |
-            PatKind::Ident(_, _, None) |
-            PatKind::Struct(..) => {
-                match dm.get(&p.id) {
-                    Some(&PathResolution { base_def: Def::Variant(_, id), .. }) => {
-                        variants.push(id);
-                    }
-                    _ => ()
-                }
-            }
-            _ => ()
-        }
-        true
-    });
-    variants.sort();
-    variants.dedup();
-    variants
-}
index 8c44594c1f783f5761dacf52983c884cfc9a944c..63bccc2d02eb68dbf42ba12cc293a968b785f418 100644 (file)
@@ -17,8 +17,8 @@
 
 use dep_graph::DepNode;
 use hir::map as ast_map;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use ty::{self, TyCtxt};
 use middle::privacy;
 use session::config;
index 1275753a3406b0c1c7d5d9e26f01d0793973ae5c..585b65b9f5e42e7613a1e5803213d9711bab5b13 100644 (file)
@@ -21,7 +21,7 @@
 use dep_graph::DepNode;
 use hir::map::Map;
 use session::Session;
-use middle::def::{Def, DefMap};
+use hir::def::{Def, DefMap};
 use middle::region;
 use ty::subst;
 use ty;
index ffb4a791363c4ae5ae0cc2259a2825c21cf5e610..6c7c7f160f4e5b5ea9d254c57dcb3fdcdd0ce7de 100644 (file)
@@ -18,8 +18,8 @@
 use session::Session;
 use lint;
 use middle::cstore::{CrateStore, LOCAL_CRATE};
-use middle::def::Def;
-use middle::def_id::{CRATE_DEF_INDEX, DefId};
+use hir::def::Def;
+use hir::def_id::{CRATE_DEF_INDEX, DefId};
 use ty::{self, TyCtxt};
 use middle::privacy::AccessLevels;
 use syntax::parse::token::InternedString;
index 1b24b4f6210bb0db1460171b06699ce2091084c5..28437fa13368aff0b1fd14780839a1fed91822d0 100644 (file)
@@ -11,7 +11,7 @@
 use graphviz::IntoCow;
 use middle::const_val::ConstVal;
 use rustc_const_math::{ConstUsize, ConstInt};
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::Substs;
 use ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty};
 use util::ppaux;
index 403c749fe4bcba674075b26d6793bc922a14096d..ae803f502318e394285d26ee2551d5638d354344 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use middle::const_val::ConstVal;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::Substs;
 use ty::{ClosureSubsts, FnOutput, Region, Ty};
 use mir::repr::*;
index a0ac514852674e86678e103482e4e848362d6400..6710d2a653c848a8a49585c85119a9b637ab2040 100644 (file)
@@ -13,7 +13,7 @@
 use super::{SelectionContext, Obligation, ObligationCause};
 
 use middle::cstore::LOCAL_CRATE;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::TypeSpace;
 use ty::{self, Ty, TyCtxt};
 use infer::{self, InferCtxt, TypeOrigin};
index f15b9ee44ce5293480e29c80d72196168da1ffe9..9357dda258364ab690ac2874fa2e6444244dc323 100644 (file)
@@ -24,7 +24,7 @@
 };
 
 use fmt_macros::{Parser, Piece, Position};
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer::InferCtxt;
 use ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable};
 use ty::fast_reject;
index 867bd054fa9ddc22348670f8c45d7fff19365d1e..a160465e2e815694dafdac08095c7fa0c699a7aa 100644 (file)
@@ -15,7 +15,7 @@
 pub use self::Vtable::*;
 pub use self::ObligationCauseCode::*;
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::free_region::FreeRegionMap;
 use ty::subst;
 use ty::{self, Ty, TypeFoldable};
index 7cd2ac5938d41387bcc66b50d6454c258bba15b1..9af2cfbd04da05ab4970c253202da24120d29e9a 100644 (file)
@@ -20,7 +20,7 @@
 use super::supertraits;
 use super::elaborate_predicates;
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::{self, SelfSpace, TypeSpace};
 use traits;
 use ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable};
index d4d61ec024471b1e39f118ff484676e8664a0e3a..a0d6f5f912b2c1d8be8cc1302d1dccbaa6216b86 100644 (file)
@@ -23,7 +23,7 @@
 use super::VtableImplData;
 use super::util;
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer::{self, InferOk, TypeOrigin};
 use ty::subst::Subst;
 use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
index 97c9caadd523713538078e533c5a16e089754716..8d7df6e44aeb7683191b1615b1760415caaaee14 100644 (file)
@@ -36,7 +36,7 @@
 use super::object_safety;
 use super::util;
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer;
 use infer::{InferCtxt, InferOk, TypeFreshener, TypeOrigin};
 use ty::subst::{Subst, Substs, TypeSpace};
index 88f4129d8860caeeea4a3600be4fcc747e599f4c..63647515a9785ad19257039b12c79ca1abb2e6fd 100644 (file)
@@ -21,7 +21,7 @@
 use super::util::{fresh_type_vars_for_impl, impl_trait_ref_and_oblig};
 
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer::{self, InferCtxt, TypeOrigin};
 use middle::region;
 use ty::subst::{Subst, Substs};
index d3146697ee6271cd97c3860f071a5581138bb472..51b0b6b8b3830b2c0a2550cc4d9d8d6d3587285f 100644 (file)
@@ -14,7 +14,7 @@
 use super::{Overlap, specializes};
 
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer;
 use traits::{self, ProjectionMode};
 use ty::{self, TyCtxt, ImplOrTraitItem, TraitDef, TypeFoldable};
index befca878bc0e435cb290ae3363e3a8b079c5b057..7668b8bf20282dc8422fdb0db9e1645b9765b23f 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer::InferCtxt;
 use ty::subst::{Subst, Substs};
 use ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef};
index ba237184a9f1d8c252280526dab77f5362bec19b..f5dedb132480173c847ea2beeddb858d96d358cf 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::{DefId};
+use hir::def_id::{DefId};
 use ty::{self, Ty, TyCtxt};
 use util::common::MemoizationMap;
 use util::nodemap::FnvHashMap;
index fa5a7f3ca692d11746c7c746cd8a5ce4d1e65ec7..14ffeadbb3a2241d2a622772b93a305b6b5c2ded 100644 (file)
@@ -16,8 +16,8 @@
 use lint;
 use middle;
 use middle::cstore::{CrateStore, LOCAL_CRATE};
-use middle::def::DefMap;
-use middle::def_id::DefId;
+use hir::def::DefMap;
+use hir::def_id::DefId;
 use middle::free_region::FreeRegionMap;
 use middle::region::RegionMaps;
 use middle::resolve_lifetime;
index e6b7b49ea573c191c26f6bf1caf93552f5ddcfcb..73bafc5e850b97a995ddd15409d05907453fec76 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst;
 use infer::type_variable;
 use ty::{self, BoundRegion, Region, Ty, TyCtxt};
index 0865e059f59c5d5c047dfd45087c3e2c4a413253..29647253ad2ad618f95949687d08bfcf3b04a4be 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::{self, Ty, TyCtxt};
 use syntax::ast;
 
index 0648450d8331b04125ec05d530f4d422072cbc60..4d88b6974166e28c6d6c9bbce4a1d930ff94c1e4 100644 (file)
@@ -10,7 +10,7 @@
 
 use hir::map::DefPathData;
 use middle::cstore::LOCAL_CRATE;
-use middle::def_id::{DefId, CRATE_DEF_INDEX};
+use hir::def_id::{DefId, CRATE_DEF_INDEX};
 use ty::{self, Ty, TyCtxt};
 use syntax::ast;
 
index 77b6b03e48fe95c5535930ec43f334fb80398ae4..65a96e79ff43c609d3c03349098ba1cc68011165 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use dep_graph::{DepNode, DepTrackingMapConfig};
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty;
 use std::marker::PhantomData;
 use std::rc::Rc;
index 69a6a6aa920f3b5b818e42c153d1ae171eabcc3b..2f0b520d84276afa1c4992f004d2c2cc12434905 100644 (file)
@@ -23,8 +23,8 @@
 use hir::map::LinkedPath;
 use middle;
 use middle::cstore::{self, CrateStore, LOCAL_CRATE};
-use middle::def::{self, Def, ExportMap};
-use middle::def_id::DefId;
+use hir::def::{self, Def, ExportMap};
+use hir::def_id::DefId;
 use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
 use middle::region::{CodeExtent};
 use traits;
index b1bff9b43cccee818a9a17aec960d49c0ac4403c..f14e680e9e06fa38e680e1112450319afa036e22 100644 (file)
@@ -13,7 +13,7 @@
 //! can be other things. Examples of type relations are subtyping,
 //! type equality, etc.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::{ParamSpace, Substs};
 use ty::{self, Ty, TyCtxt, TypeFoldable};
 use ty::error::{ExpectedFound, TypeError};
index 101c8501bd3dd0d0daa632b424dc40fe94d0b420..c0fb60d4dd3dc59ab5c2694839d8d60b460a2f3d 100644 (file)
@@ -11,7 +11,7 @@
 //! This module contains TypeVariants and its major components
 
 use middle::cstore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::region;
 use ty::subst::{self, Substs};
 use traits;
index 93157f28482a54d1d2af8a3f194bbe94679f3655..dd547da59e9cfada95483ce991c0ab9f5716919c 100644 (file)
@@ -13,7 +13,7 @@
 pub use self::ParamSpace::*;
 
 use middle::cstore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::{self, Ty, TyCtxt};
 use ty::fold::{TypeFoldable, TypeFolder};
 
index 0eb70f93bed30d8620f8422aa0d4d35c1c5b58f5..94f4e31efc66551590e81631b2229c901b1da683 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use dep_graph::DepNode;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use traits::{self, specialization_graph};
 use ty;
 use ty::fast_reject;
index 710cd2e301c09ee4cc4d6631085c63b8bcedd099..354744b27875dbc2eb55380959bc3d216e33a411 100644 (file)
 //! misc. type-system utilities too small to deserve their own file
 
 use hir::svh::Svh;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst;
 use infer;
-use middle::pat_util;
+use hir::pat_util;
 use traits::{self, ProjectionMode};
 use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
 use ty::{Disr, ParameterEnvironment};
index e6c4e90babbf575607de80628c8de975b5245e8b..9ea634bb41c1b13d37a91b972b5a7e1d98348f40 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use infer::InferCtxt;
 use ty::outlives::{self, Component};
 use ty::subst::Substs;
index 4a45797602d811f270571b29794150c9b4c579ef..69bcc9cbfffea807018c7fa2c73b2fab2b8f8164 100644 (file)
@@ -12,7 +12,7 @@
 
 #![allow(non_snake_case)]
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use syntax::ast;
 
 pub use rustc_data_structures::fnv::FnvHashMap;
index c386a670ba256c62b5e675e0aa56d7f20f908ff4..a84a42fc2b535cf033a119e25d6b0365bb7eb1bb 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use ty::subst::{self, Subst};
 use ty::{BrAnon, BrEnv, BrFresh, BrNamed};
 use ty::{TyBool, TyChar, TyStruct, TyEnum};
index d1b30bb2746c934f0e4ce1c01c5b8895c2e063ad..0b1c4efa9ac042ada249ff831c75487868bb1ec4 100644 (file)
@@ -20,7 +20,7 @@
 use borrowck::LoanPathElem::{LpDeref, LpInterior};
 use borrowck::move_data::InvalidMovePathIndex;
 use borrowck::move_data::{MoveData, MovePathIndex};
-use rustc::middle::def_id::{DefId};
+use rustc::hir::def_id::{DefId};
 use rustc::ty::{self, TyCtxt};
 use rustc::middle::mem_categorization as mc;
 
index 789d7dd9fefb001a328bed799555ef8da387cc57..d7c928b8d6e1fe962525ae1ad595894b995bb8c5 100644 (file)
@@ -28,7 +28,7 @@
 use rustc::middle::dataflow::BitwiseOperator;
 use rustc::middle::dataflow::DataFlowOperator;
 use rustc::middle::dataflow::KillFrom;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::free_region::FreeRegionMap;
 use rustc::middle::mem_categorization as mc;
index 797580319b2ee16777acc1cdd06296cf427b99fe..1e662d456d141a5bab79b6ee61bd09e527a90ad7 100644 (file)
 use ::{eval_const_expr, eval_const_expr_partial, compare_const_vals};
 use ::{const_expr_to_pat, lookup_const_by_id};
 use ::EvalHint::ExprTypeChecked;
-use rustc::middle::def::*;
-use rustc::middle::def_id::{DefId};
+use rustc::hir::def::*;
+use rustc::hir::def_id::{DefId};
 use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor};
 use rustc::middle::expr_use_visitor::{LoanCause, MutateMode};
 use rustc::middle::expr_use_visitor as euv;
 use rustc::infer;
 use rustc::middle::mem_categorization::{cmt};
-use rustc::middle::pat_util::*;
+use rustc::hir::pat_util::*;
 use rustc::traits::ProjectionMode;
 use rustc::ty::*;
 use rustc::ty;
index dba31ddef95dd39c33e560676057af45081b91fa..45a90bf00681c7a9aea2792ef8e010b8c1b1757a 100644 (file)
@@ -19,9 +19,9 @@
 use rustc::hir::map::blocks::FnLikeNode;
 use rustc::middle::cstore::{self, CrateStore, InlinedItem};
 use rustc::{infer, traits};
-use rustc::middle::def::Def;
-use rustc::middle::def_id::DefId;
-use rustc::middle::pat_util::def_to_path;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
+use rustc::hir::pat_util::def_to_path;
 use rustc::ty::{self, Ty, TyCtxt, subst};
 use rustc::ty::util::IntTypeExt;
 use rustc::traits::ProjectionMode;
index ed9c66a1882755d923f943c1d5c29f5e01eec669..d10691d12ed970c1d71c61e63e6692a04c0fab84 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def::Def;
+use rustc::hir::def::Def;
 use rustc::ty;
 use lint::{LateContext, LintContext, LintArray};
 use lint::{LintPass, LateLintPass};
index 6f11ebafa86ec3bd039b8c8d7788b8afa012f42b..fe10ca87b75425ad159a710cef46b47539f4ba8c 100644 (file)
@@ -28,9 +28,9 @@
 //! Use the former for unit-like structs and the latter for structs with
 //! a `pub fn new()`.
 
-use middle::def::Def;
+use rustc::hir::def::Def;
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use middle::stability;
 use rustc::{cfg, infer};
 use rustc::ty::subst::Substs;
index 574c7af4cfc28cf348b0f1a1035324093c507487..891731cb29604ee615801933bafe6d6e49c3fa33 100644 (file)
@@ -10,7 +10,7 @@
 
 #![allow(non_snake_case)]
 
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty, TyCtxt};
index f531628601b0f9d91e6f5a6b4281bb692af0cc29..d1595f243c9bfba65f14b3170757f463a0bf8f11 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::pat_util;
+use rustc::hir::pat_util;
 use rustc::ty;
 use rustc::ty::adjustment;
 use util::nodemap::FnvHashMap;
index 61f35a12df7fb0d711c43ee4634bdcb4413baef4..df60e35d0f3d342179d75799554a1aa4f1905c75 100644 (file)
@@ -31,8 +31,8 @@
 use rustc::ty::adjustment;
 use rustc::ty::cast;
 use middle::const_qualif::ConstQualif;
-use middle::def::{self, Def};
-use middle::def_id::DefId;
+use rustc::hir::def::{self, Def};
+use rustc::hir::def_id::DefId;
 use middle::region;
 use rustc::ty::subst;
 use rustc::ty::{self, Ty, TyCtxt};
index c9e661dec510e9ae2752204f9e3a2fedfa9b8698..bb691cebccd122ff3c921de9e82fbedbe4ceefb8 100644 (file)
 
 use middle::cstore::{CrateStore, CrateSource, ChildItem, ExternCrate, FoundAst, DefLike};
 use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference};
-use middle::def;
+use rustc::hir::def;
 use middle::lang_items;
 use rustc::ty::{self, Ty, TyCtxt, VariantKind};
-use middle::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
+use rustc::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
 
 use rustc::hir::map as hir_map;
 use rustc::mir::repr::Mir;
index 3a6cd4d832b9a659118ba08abafebdf098140062..d5a9adafe7dcad71406089649d1fa7ce61da5bb6 100644 (file)
 use index;
 use loader;
 
+use rustc::hir::def_id::DefId;
 use rustc::hir::svh::Svh;
 use rustc::middle::cstore::{ExternCrate};
 use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
-use rustc::middle::def_id::DefId;
 
 use std::cell::{RefCell, Ref, Cell};
 use std::rc::Rc;
index 5aafd015f9a1c7ddd73aae8eb1538f5f1ef646cc..e6f538255ac268f4f60c9f8570637d6958f13558 100644 (file)
@@ -29,8 +29,8 @@
 
 use middle::cstore::{LOCAL_CRATE, FoundAst, InlinedItem, LinkagePreference};
 use middle::cstore::{DefLike, DlDef, DlField, DlImpl, tls};
-use middle::def::Def;
-use middle::def_id::{DefId, DefIndex};
+use rustc::hir::def::Def;
+use rustc::hir::def_id::{DefId, DefIndex};
 use middle::lang_items;
 use rustc::ty::subst;
 use rustc::ty::{ImplContainer, TraitContainer};
index dc21ebcbcfcbd8e218449d36998e52791666bcb5..83ffd8afbeb01fe0f3fa5f232d574f8804e48420 100644 (file)
@@ -21,8 +21,8 @@
 use index::{self, IndexData};
 
 use middle::cstore::{LOCAL_CRATE, CrateStore, InlinedItemRef, LinkMeta, tls};
-use middle::def;
-use middle::def_id::{CRATE_DEF_INDEX, DefId};
+use rustc::hir::def;
+use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
 use middle::dependency_format::Linkage;
 use middle::stability;
 use rustc::ty::subst;
index 60bbdaddd751607c7e75c1ffeade30db3d440852..9c066f9f5f1f1ad688e7237baee70d5c47d48340 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def_id::{DefId, DefIndex};
+use rustc::hir::def_id::{DefId, DefIndex};
 use rbml;
 use std::io::{Cursor, Write};
 use std::slice;
index 6ecd7a7f50ad883315d2b077609e240c143e105e..782c7cba26ec59f472a7a4ec9ab88482a55d1c29 100644 (file)
@@ -14,7 +14,7 @@
 use rbml::opaque::Encoder as OpaqueEncoder;
 use rbml::opaque::Decoder as OpaqueDecoder;
 use rustc::middle::cstore::tls;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, TyCtxt};
 
index cd63b58372b324289928d637303a00c113ae89e6..3004246d1d7e7e9bdf279fd7b529e6b7a462c49e 100644 (file)
@@ -18,7 +18,7 @@
 
 use rustc::hir;
 
-use middle::def_id::{DefId, DefIndex};
+use rustc::hir::def_id::{DefId, DefIndex};
 use middle::region;
 use rustc::ty::subst;
 use rustc::ty::subst::VecPerParamSpace;
index b5079256487dea010518a3e93c2380119237acb7..f49c2e22c6a804cc97a7bbf9abcac3fc1f9d21bf 100644 (file)
@@ -17,7 +17,7 @@
 use std::io::Cursor;
 use std::io::prelude::*;
 
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use middle::region;
 use rustc::ty::subst;
 use rustc::ty::subst::VecPerParamSpace;
index 790833f99ca8a432a62b773bffafb2987d47eb2f..7f748ef9b1ea793a04c2da1ff6691b87655a7ccd 100644 (file)
 use hair::cx::block;
 use hair::cx::to_ref::ToRef;
 use rustc::hir::map;
-use rustc::middle::def::Def;
+use rustc::hir::def::Def;
 use rustc::middle::const_val::ConstVal;
 use rustc_const_eval as const_eval;
 use rustc::middle::region::CodeExtent;
-use rustc::middle::pat_util;
+use rustc::hir::pat_util;
 use rustc::ty::{self, VariantDef, Ty};
 use rustc::mir::repr::*;
 use rustc::hir;
index f0c6887802d6341bbfa1636e517364f0978849e3..c3a5fbd967c84b4279ee846bcee42a1cf994b49c 100644 (file)
@@ -20,7 +20,7 @@
 
 use rustc::middle::const_val::ConstVal;
 use rustc_const_eval as const_eval;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer::InferCtxt;
 use rustc::ty::subst::{Subst, Substs};
 use rustc::ty::{self, Ty, TyCtxt};
index 673d12c33167a2aae9f982c42aa4d7ff09c162ce..990ba9e786c3019435a02d715532e4cd4a98a0c8 100644 (file)
@@ -12,8 +12,8 @@
 use hair::cx::Cx;
 use rustc_data_structures::fnv::FnvHashMap;
 use rustc_const_eval as const_eval;
-use rustc::middle::def::Def;
-use rustc::middle::pat_util::{pat_is_resolved_const, pat_is_binding};
+use rustc::hir::def::Def;
+use rustc::hir::pat_util::{pat_is_resolved_const, pat_is_binding};
 use rustc::ty::{self, Ty};
 use rustc::mir::repr::*;
 use rustc::hir::{self, PatKind};
index 0ea8dece47c7be23aa0148e2f415b26a950a0444..51f2cc2687a9926d2170270b22faa34b7dbb625c 100644 (file)
@@ -17,7 +17,7 @@
 use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp,
     TypedConstVal};
 use rustc::middle::const_val::ConstVal;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::middle::region::CodeExtent;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, AdtDef, ClosureSubsts, Region, Ty};
index 38784191a78283dbae9c735be2eeab2bb826ee5a..4659bb389dc6b4f7e70c15d121f6b3e6e8fbadd3 100644 (file)
@@ -30,8 +30,8 @@
 use rustc_const_eval::{eval_const_expr_partial, lookup_const_by_id};
 use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal};
 use rustc_const_eval::EvalHint::ExprTypeChecked;
-use rustc::middle::def::Def;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::infer;
 use rustc::middle::mem_categorization as mc;
index 2766d13d7b8ab972a35b75d64c35881a041c0181..245960a04f030972917105cdded1ea60fe619df3 100644 (file)
@@ -14,7 +14,7 @@
 use rustc::dep_graph::DepNode;
 use rustc::hir::map as ast_map;
 use rustc::session::{Session, CompileResult};
-use rustc::middle::def::{Def, DefMap};
+use rustc::hir::def::{Def, DefMap};
 use rustc::util::nodemap::NodeMap;
 
 use syntax::{ast};
index 908a7869c42972f2ff28fc490cd442d9932eeb0b..8840bd427178121c4d3c7f801fb53f3e23e25fb5 100644 (file)
@@ -35,8 +35,8 @@
 use rustc::dep_graph::DepNode;
 use rustc::lint;
 use rustc::middle::cstore::CrateStore;
-use rustc::middle::def::{self, Def};
-use rustc::middle::def_id::DefId;
+use rustc::hir::def::{self, Def};
+use rustc::hir::def_id::DefId;
 use rustc::middle::privacy::{AccessLevel, AccessLevels};
 use rustc::ty::{self, TyCtxt};
 use rustc::util::nodemap::NodeSet;
index 470fd88025e4e1c187596e847ba2499d253ba3ed..a422b09f96bf22d285087c6e5d4731982e01eb1d 100644 (file)
@@ -24,8 +24,8 @@
 
 use rustc::middle::cstore::{CrateStore, ChildItem, DlDef};
 use rustc::lint;
-use rustc::middle::def::*;
-use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId};
+use rustc::hir::def::*;
+use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
 use rustc::ty::VariantKind;
 
 use syntax::ast::Name;
index c0b8aad1c091393ce7fd9a526b54bb08ac4281b0..502b45c9453478f0d6f1bb13335dfad0a9c8c4be 100644 (file)
@@ -52,9 +52,9 @@
 use rustc::session::Session;
 use rustc::lint;
 use rustc::middle::cstore::CrateStore;
-use rustc::middle::def::*;
-use rustc::middle::def_id::DefId;
-use rustc::middle::pat_util::pat_bindings;
+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};
@@ -2570,7 +2570,7 @@ fn resolve_possibly_assoc_item(&mut self,
     }
 
     /// Skips `path_depth` trailing segments, which is also reflected in the
-    /// returned value. See `middle::def::PathResolution` for more info.
+    /// returned value. See `hir::def::PathResolution` for more info.
     fn resolve_path(&mut self, id: NodeId, path: &Path, path_depth: usize, namespace: Namespace)
                     -> Option<PathResolution> {
         let span = path.span;
index 2aa8925fb54b58be6ce79fa23e7f30f34b457a3e..738a99fbe9200d5d3b7f935153b032c3089ef158 100644 (file)
@@ -22,7 +22,7 @@
 use {resolve_error, ResolutionError};
 
 use rustc::lint;
-use rustc::middle::def::*;
+use rustc::hir::def::*;
 
 use syntax::ast::{NodeId, Name};
 use syntax::attr::AttrMetaMethods;
index 3021d4e9820b7fd53f1332838b7c5d33da677366..0e02830db7ad75498bb4b2e254faf081da93ab4c 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::io::Write;
 
-use rustc::middle::def_id::{DefId, DefIndex};
+use rustc::hir::def_id::{DefId, DefIndex};
 use syntax::codemap::Span;
 
 use super::data::*;
index 649c8387eb37c48595a23748d6b95d820eeddd08..7f2f2618c3c96aa19f85966eba741cbb47112c19 100644 (file)
@@ -15,7 +15,7 @@
 
 use std::hash::Hasher;
 
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty;
 use syntax::ast::{CrateNum, NodeId};
 use syntax::codemap::Span;
index 310747c89914a3c130da6e2b6bfd80d3fc17cfdf..c724091a2ec87e4ed0d2e739dff2d1c8315a7a0a 100644 (file)
@@ -27,8 +27,8 @@
 //! is used for recording the output in a format-agnostic way (see CsvDumper
 //! for an example).
 
-use rustc::middle::def::Def;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::session::Session;
 use rustc::ty::{self, TyCtxt};
 
index a4f9720bbe26b890e7a7dfc1730bfc0b3f355de9..98c0be1c93c1599f782f355a9c6f92c47ee6c3e4 100644 (file)
@@ -29,8 +29,8 @@
 
 use rustc::hir::{self, lowering};
 use rustc::hir::map::NodeItem;
-use rustc::middle::def::Def;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::session::config::CrateType::CrateTypeExecutable;
 use rustc::ty::{self, TyCtxt};
 
index 3bbead9847bdd2cfa413c06d9caf3b5330dc912b..d8b8f9f08067c0ac3261f9c2eac1af9920cabdff 100644 (file)
 use llvm::{ValueRef, BasicBlockRef};
 use rustc_const_eval::check_match::{self, StaticInliner};
 use rustc_const_eval::{compare_lit_exprs, eval_const_expr};
-use middle::def::{Def, DefMap};
-use middle::def_id::DefId;
+use rustc::hir::def::{Def, DefMap};
+use rustc::hir::def_id::DefId;
 use middle::expr_use_visitor as euv;
 use rustc::infer;
 use middle::lang_items::StrEqFnLangItem;
 use middle::mem_categorization as mc;
 use middle::mem_categorization::Categorization;
-use middle::pat_util::*;
+use rustc::hir::pat_util::*;
 use rustc::ty::subst::Substs;
 use adt;
 use base::*;
index ecbb50494433071418198cb021ce95280b024684..932f66f17cc7b97b6dad876159c3e8fe8f173899 100644 (file)
@@ -39,7 +39,7 @@
 
 use graphviz as dot;
 use rustc::dep_graph::{DepGraphQuery, DepNode};
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty::TyCtxt;
 use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet};
 use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex};
index 949a10297c1e2fdfc582422380b616a6846d46d1..8127d1c0e29ab844e1f4baa41c3dff501394ca31 100644 (file)
 use util::sha2::{Digest, Sha256};
 
 use rustc::middle::cstore;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty::{self, TypeFoldable};
 use rustc::ty::item_path::{ItemPathBuffer, RootMode};
 use rustc::hir::map::definitions::{DefPath, DefPathData};
index 6714f6440ee4ffe25716f13bf34989fd5f7f2b0d..4f1585eeaca3b4ecbf11b6173d452dc44d2b5d3b 100644 (file)
 use llvm;
 use rustc::cfg;
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
 use middle::weak_lang_items;
-use middle::pat_util::simple_name;
+use rustc::hir::pat_util::simple_name;
 use rustc::ty::subst::{self, Substs};
 use rustc::traits;
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
index 2da9acf3250891a685a477d5ee07bd8b5f33d322..392c40a60155c5715fe22d69a4df6986f435247e 100644 (file)
@@ -21,7 +21,7 @@
 use back::symbol_names;
 use llvm::{self, ValueRef, get_params};
 use middle::cstore::LOCAL_CRATE;
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::subst;
 use rustc::ty::subst::{Substs};
index 579848919ecb9a5d877834767fb2df9fb55cfd18..6bd5fd355a731b53384c8dfca7bf78e468d841e8 100644 (file)
@@ -11,7 +11,7 @@
 use arena::TypedArena;
 use back::symbol_names;
 use llvm::{ValueRef, get_param, get_params};
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::traits::ProjectionMode;
 use abi::{Abi, FnType};
index 4f197dbee1315f6fce424d22f503d11c1b060f44..c72a1a6bef32f7d6187d33cf094b6f2c6b6fcdaf 100644 (file)
 use rustc::hir::intravisit as hir_visit;
 
 use rustc::hir::map as hir_map;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::middle::lang_items::{ExchangeFreeFnLangItem, ExchangeMallocFnLangItem};
 use rustc::traits;
 use rustc::ty::subst::{self, Substs, Subst};
index 1f48eb916039b27f0e43bdd6703fade0d10b14a7..5ce7caf5deb06291e14f741694232855d649ef12 100644 (file)
@@ -17,8 +17,8 @@
 use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind};
 use llvm::{True, False, Bool, OperandBundleDef};
 use rustc::cfg;
-use middle::def::Def;
-use middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use middle::lang_items::LangItem;
 use rustc::ty::subst::Substs;
index 7945639f86b327fd812635ad8d70117de2b613b1..89f3b295c8d22e0473eb1a7b670f45af62969c2e 100644 (file)
@@ -15,8 +15,8 @@
 use middle::const_qualif::ConstQualif;
 use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, lookup_const_by_id, ErrKind};
 use rustc_const_eval::eval_repeat_count;
-use middle::def::Def;
-use middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::hir::map as hir_map;
 use {abi, adt, closure, debuginfo, expr, machine};
 use base::{self, exported_name, imported_name, push_ctxt};
index 3574883c5f58823ddf4b56521e593fbed12bcc79..9bbc72eba36ef2ac0bfac561573b4d5c5bc8c582 100644 (file)
@@ -12,8 +12,8 @@
 use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef};
 use rustc::dep_graph::{DepNode, DepTrackingMap, DepTrackingMapConfig};
 use middle::cstore::LinkMeta;
-use middle::def::ExportMap;
-use middle::def_id::DefId;
+use rustc::hir::def::ExportMap;
+use rustc::hir::def_id::DefId;
 use rustc::traits;
 use rustc::mir::mir_map::MirMap;
 use rustc::mir::repr as mir;
index f3cb4d5001aa517a9df5fb44247f020117900d29..58971dec8a9d7cf68c62d47eccb1d6f239e85874 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use llvm::ValueRef;
-use middle::def::Def;
+use rustc::hir::def::Def;
 use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem};
 use rustc::ty::subst::Substs;
 use base::*;
index b98b98813507a39f2eafc0027bd7a67c1519ee82..b1cfeb8125bd384b74939bef27e1add7c8b62331 100644 (file)
@@ -14,7 +14,7 @@
 use llvm;
 use llvm::debuginfo::{DIScope, DISubprogram};
 use common::CrateContext;
-use middle::pat_util;
+use rustc::hir::pat_util;
 use rustc::util::nodemap::NodeMap;
 
 use libc::c_uint;
index acfafc6e3297d3cb8e1c2409cb395e599edbc066..822155f8c36a940028dd67c2a3ec1a6989053597 100644 (file)
@@ -23,9 +23,9 @@
 use llvm::{self, ValueRef};
 use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType};
 
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
-use middle::pat_util;
+use rustc::hir::pat_util;
 use rustc::ty::subst;
 use rustc::hir::map as hir_map;
 use rustc::hir::{self, PatKind};
index 7e9c8228f29f43b30b74d181c9eb869a76a04f7d..bb999c31ffb5e674bd98ab9a9ad0b90fad2510d2 100644 (file)
@@ -26,7 +26,7 @@
 use llvm::{ModuleRef, ContextRef, ValueRef};
 use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray,
                       DIDescriptor, FlagPrototyped};
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer::normalize_associated_type;
 use rustc::ty::subst::{self, Substs};
 use rustc::hir;
index 1feb47a3a7d998ce6bdebf487ee5c20f7c2c2f11..c1487f56956fc743b6abec5edf5da35b396c7a09 100644 (file)
@@ -14,7 +14,7 @@
 
 use llvm;
 use llvm::debuginfo::DIScope;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::hir::map as hir_map;
 use common::CrateContext;
 
index f5bb1677f29baaf9995dc2666c5ec72d160c7a3f..0169734ad3b7cd8aadb72b15010e1effef2450df 100644 (file)
@@ -13,7 +13,7 @@
 use super::namespace::crate_root_namespace;
 
 use common::CrateContext;
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::subst;
 use rustc::ty::{self, Ty};
index 61dc3dc3f8fdbf8c22499af737feccc068e67fd4..bef7af3aec6c8ebf0ea359c184c5140ee58d5f74 100644 (file)
@@ -13,7 +13,7 @@
 use super::{FunctionDebugContext, CrateDebugContext};
 use super::namespace::namespace_for_item;
 
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 
 use llvm;
 use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray};
index fce8656fb93d86dfb03c89a36fb2796a08ce39b9..beca81da05f4c5f38796c8ceaddc608e33fc6a0b 100644 (file)
@@ -53,7 +53,7 @@
 
 use llvm::{self, ValueRef, TypeKind};
 use middle::const_qualif::ConstQualif;
-use middle::def::Def;
+use rustc::hir::def::Def;
 use rustc::ty::subst::Substs;
 use {_match, abi, adt, asm, base, closure, consts, controlflow};
 use base::*;
index 36dfbec115e797b50b66972baa4e4c88257c3e20..1eff09d67f96bb4f3f6a5e8c526fbf5d29141c9d 100644 (file)
@@ -10,7 +10,7 @@
 
 use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage};
 use middle::cstore::{CrateStore, FoundAst, InlinedItem};
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty::subst::Substs;
 use base::{push_ctxt, trans_item, trans_fn};
 use callee::Callee;
index 82b61e15f2bfe1561d04dfc1c80979519eb3a9e3..478094c2b87b02b4f3b3ff19779d9cb18d8f2c93 100644 (file)
@@ -13,7 +13,7 @@
 use arena::TypedArena;
 use back::symbol_names;
 use llvm::{ValueRef, get_params};
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::subst::{FnSpace, Subst, Substs};
 use rustc::ty::subst;
index de66951d091292fa0f5721e179e69a410bc2124e..ef0da37f0b261ed61c1812d503c546a745554303 100644 (file)
@@ -11,7 +11,7 @@
 use back::symbol_names;
 use llvm::ValueRef;
 use llvm;
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer::normalize_associated_type;
 use rustc::ty::subst;
 use rustc::ty::subst::{Subst, Substs};
index 8b1aaafab58ed243de3f5b953ece999994595b50..500eda2624ce7cb712b66e50d5d63cbf5897a9c9 100644 (file)
@@ -10,7 +10,7 @@
 
 #![allow(non_camel_case_types)]
 
-use middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::subst;
 use abi::FnType;
index a52b8cad1083a2193f0b14a1714ba0b4bed58e10..21122e7095dd1cb5280d9cf04828db61f908ca3a 100644 (file)
@@ -52,8 +52,8 @@
 use middle::const_val::ConstVal;
 use rustc_const_eval::eval_const_expr_partial;
 use rustc_const_eval::EvalHint::UncheckedExprHint;
-use middle::def::{self, Def};
-use middle::def_id::DefId;
+use hir::def::{self, Def};
+use hir::def_id::DefId;
 use middle::resolve_lifetime as rl;
 use rustc::ty::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace};
 use rustc::traits;
index eaf8479585f8d8d2aabb61ba711f899892422621..8dbd6496b6fb06bd3ec953b4e2cea520755d9e84 100644 (file)
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use middle::def::{self, Def};
+use hir::def::{self, Def};
 use rustc::infer::{self, InferOk, TypeOrigin};
-use middle::pat_util::{PatIdMap, pat_id_map, pat_is_binding};
-use middle::pat_util::pat_is_resolved_const;
+use hir::pat_util::{PatIdMap, pat_id_map, pat_is_binding};
+use hir::pat_util::pat_is_resolved_const;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty, TypeFoldable, LvaluePreference};
 use check::{check_expr, check_expr_has_type, check_expr_with_expectation};
index 460230c60c60a49322df43e74e4a52aa18790de9..21800d91d9458b3810450293c7375eac278b39d7 100644 (file)
@@ -26,8 +26,8 @@
 
 use CrateCtxt;
 use middle::cstore::LOCAL_CRATE;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use rustc::infer;
 use rustc::ty::{self, LvaluePreference, Ty};
 use syntax::codemap::Span;
index 00a73a062fe1882ca7a24a90034ce3ebf30de8e9..91cdb8d966d419be942e604bc82970fd279a175f 100644 (file)
@@ -44,7 +44,7 @@
 use super::structurally_resolved_type;
 
 use lint;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use rustc::ty::{self, Ty, TypeFoldable};
 use rustc::ty::cast::{CastKind, CastTy};
 use syntax::codemap::Span;
index 1f1bba509e01ecdd4835736a91b248f1445b3f14..368b826b1bb39f24c6c8f9a15962a089f096c2bf 100644 (file)
@@ -10,7 +10,7 @@
 
 use check::regionck::{self, Rcx};
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::free_region::FreeRegionMap;
 use rustc::infer;
 use middle::region;
index cc12b2e05152d4b0ef08626a7fd8838e0e54cacf..b98f1884f01cee471ebb5540a6d32c496c8d8e3b 100644 (file)
@@ -12,7 +12,7 @@
 
 use check::{self, FnCtxt, callee, demand};
 use check::UnresolvedTypeAction;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use rustc::ty::subst::{self};
 use rustc::traits;
 use rustc::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt};
index 72ca73aac940ed09b23711ea3260942fcec9c320..3f069a68316de77cfc1ad57743557d9ab744c7b2 100644 (file)
@@ -12,8 +12,8 @@
 
 use astconv::AstConv;
 use check::FnCtxt;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use rustc::ty::subst;
 use rustc::traits;
 use rustc::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable};
index c907a6dc64020f933e5a22a2bff1ad00de3f6ba4..7d98eac30c5d05c77a4dff150d132271b48c6fcc 100644 (file)
@@ -15,8 +15,8 @@
 
 use check;
 use check::{FnCtxt, UnresolvedTypeAction};
-use middle::def_id::DefId;
-use middle::def::Def;
+use hir::def_id::DefId;
+use hir::def::Def;
 use rustc::ty::subst;
 use rustc::ty::subst::Subst;
 use rustc::traits;
index 620863a7a2e11f9117f43bfa310e4c0ef2f8aac6..c5195cf8787dab57a333b62e5a6ace6c49c24820 100644 (file)
@@ -18,8 +18,8 @@
 use rustc::hir::map as hir_map;
 use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TypeFoldable};
 use middle::cstore::{self, CrateStore};
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use middle::lang_items::FnOnceTraitLangItem;
 use rustc::ty::subst::Substs;
 use rustc::ty::LvaluePreference;
index c3a42826dbc417bb661f2d5cfca045da250bc7bf..e7159e65eeb7c195fb0cbafa83d82e4c6dffaf1d 100644 (file)
 use fmt_macros::{Parser, Piece, Position};
 use middle::astconv_util::prohibit_type_params;
 use middle::cstore::LOCAL_CRATE;
-use middle::def::{self, Def};
-use middle::def_id::DefId;
+use hir::def::{self, Def};
+use hir::def_id::DefId;
 use rustc::infer::{self, InferOk, TypeOrigin, TypeTrace, type_variable};
-use middle::pat_util::{self, pat_id_map};
+use hir::pat_util::{self, pat_id_map};
 use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace};
 use rustc::traits::{self, report_fulfillment_errors, ProjectionMode};
 use rustc::ty::{GenericPredicates, TypeScheme};
index f7f40e6077f4a55c1a89e080642acc50eb280ee1..debf925875723409c393a4f6a7d05d2517f322e0 100644 (file)
@@ -18,7 +18,7 @@
     method,
     FnCtxt,
 };
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue};
 use syntax::ast;
 use syntax::parse::token;
index 02114c170c44bf37ff945d0d0688d1e35e9fae15..2a4de6e091b3d37f9c3fe4236e4b8d8e34a41e30 100644 (file)
@@ -93,7 +93,7 @@
 use rustc::traits;
 use rustc::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable};
 use rustc::infer::{self, GenericKind, InferCtxt, InferOk, SubregionOrigin, TypeOrigin, VerifyBound};
-use middle::pat_util;
+use hir::pat_util;
 use rustc::ty::adjustment;
 use rustc::ty::wf::ImpliedBound;
 
index 0ed0b64b9704f77f2a6caec9375384203f4751af..1b21e6ce9ebe3d1c548e2bc9df4d777395a7467a 100644 (file)
@@ -12,7 +12,7 @@
 use check::{FnCtxt, Inherited, blank_fn_ctxt, regionck};
 use constrained_type_params::{identify_constrained_type_params, Parameter};
 use CrateCtxt;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::region::{CodeExtent};
 use rustc::ty::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace};
 use rustc::traits;
index 50f2f27b3d2a200a422cec737192dca2e4c1fba2..68327ccd39ab69f9f05b94d8f1578a22aabd6f5e 100644 (file)
@@ -15,8 +15,8 @@
 
 use astconv::AstConv;
 use check::FnCtxt;
-use middle::def_id::DefId;
-use middle::pat_util;
+use hir::def_id::DefId;
+use hir::pat_util;
 use rustc::ty::{self, Ty, TyCtxt, MethodCall, MethodCallee};
 use rustc::ty::adjustment;
 use rustc::ty::fold::{TypeFolder,TypeFoldable};
index 1f7fc45327965153ac8dd54f4aa66bf56c493c1f..9c8c9ba50561296655e09d959c2b3aee9cfc40ca 100644 (file)
@@ -15,7 +15,7 @@
 // done by the orphan and overlap modules. Then we build up various
 // mappings. That mapping code resides here.
 
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::lang_items::UnsizeTraitLangItem;
 use rustc::ty::subst::{self, Subst};
 use rustc::ty::{self, TyCtxt, TypeFoldable};
index 0821d5582bdedbd7424f1dfb441f6f370a3a7a38..f3d63957018d672547d26005d390c01117111ca8 100644 (file)
@@ -12,7 +12,7 @@
 //! crate or pertains to a type defined in this crate.
 
 use middle::cstore::LOCAL_CRATE;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use rustc::traits;
 use rustc::ty::{self, TyCtxt};
 use syntax::ast;
index d99c5d52f4a67d243a39cae099670523addf1bda..a05167dbe433333c819515b62aaf9dbd5fb852bb 100644 (file)
@@ -13,7 +13,7 @@
 //! constructor provide a method with the same name.
 
 use middle::cstore::CrateStore;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use rustc::traits::{self, ProjectionMode};
 use rustc::infer;
 use rustc::ty::{self, TyCtxt};
index 53126d3494ab17c5b2d6ae885973d52ff980c3d3..9d76b4c5284b161f9561f0ce49f2f6e2bbf2d10d 100644 (file)
@@ -60,8 +60,8 @@
 
 use astconv::{self, AstConv, ty_of_arg, ast_ty_to_ty, ast_region_to_region};
 use lint;
-use middle::def::Def;
-use middle::def_id::DefId;
+use hir::def::Def;
+use hir::def_id::DefId;
 use constrained_type_params as ctp;
 use coherence;
 use middle::lang_items::SizedTraitLangItem;
index af32026d47e464bb0e46f32079b68cef491e45ed..ab2276c324b605a9ce7c862fda14a00491dae472 100644 (file)
 
 use dep_graph::DepNode;
 use hir::map as hir_map;
-use middle::def::Def;
+use hir::def::Def;
 use rustc::infer::{self, TypeOrigin};
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
index fa3ee80c6dac8ab7f59e58680a80ccec94d44f1e..3b03a713a5b93f8acf8d79f159e9dfe1221e7ae1 100644 (file)
@@ -14,7 +14,7 @@
 //! We walk the set of items and, for each member, generate new constraints.
 
 use dep_graph::DepTrackingMapConfig;
-use middle::def_id::DefId;
+use hir::def_id::DefId;
 use middle::resolve_lifetime as rl;
 use rustc::ty::subst;
 use rustc::ty::subst::ParamSpace;
index 2f080dae37084cd2263e2ef715ddc426c9633719..70997a1a6eed28e379095a55a92216a901a9396d 100644 (file)
@@ -17,8 +17,8 @@
 use rustc::hir;
 
 use rustc::middle::cstore::{self, CrateStore};
-use rustc::middle::def::Def;
-use rustc::middle::def_id::DefId;
+use rustc::hir::def::Def;
+use rustc::hir::def_id::DefId;
 use rustc::ty::{self, TyCtxt};
 use rustc::ty::subst;
 use rustc::middle::stability;
index 715d0e759c3b777fe79fd81400aa41af58c9d0f9..4895022cfac2955010c9133ccda930f3f30dbaad 100644 (file)
@@ -35,8 +35,8 @@
 
 use rustc_trans::back::link;
 use rustc::middle::cstore::{self, CrateStore};
-use rustc::middle::def::Def;
-use rustc::middle::def_id::{DefId, DefIndex};
+use rustc::hir::def::Def;
+use rustc::hir::def_id::{DefId, DefIndex};
 use rustc::ty::subst::{self, ParamSpace, VecPerParamSpace};
 use rustc::ty;
 use rustc::middle::stability;
index e6a4d882c0449fdcc03e753dc698e2df6b0a0df1..4ba412cdc851bb4a843710b94bae8f518ad3b36e 100644 (file)
@@ -29,7 +29,7 @@
 use std::mem;
 use std::collections::HashMap;
 
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::ty::subst;
 
 use clean::PathParameters as PP;
index 4686e60be872a4021f0b966ad70243143bd897dc..6b7aa103e1d0afb7c71ae2f62d48349bf695d0a1 100644 (file)
@@ -13,7 +13,7 @@
 use rustc_driver::{driver, target_features, abort_on_err};
 use rustc::dep_graph::DepGraph;
 use rustc::session::{self, config};
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::middle::privacy::AccessLevels;
 use rustc::ty::{self, TyCtxt};
 use rustc::hir::map as hir_map;
index 9f0b636227ff6010fa9a1212ffa74b445d077052..a43711a32733bd0060256b18b7ba4568076dee07 100644 (file)
@@ -19,7 +19,7 @@
 use std::iter::repeat;
 
 use rustc::middle::cstore::LOCAL_CRATE;
-use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId};
+use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
 use syntax::abi::Abi;
 use rustc::hir;
 
index f97d4fee05391db45dfe697fe9996ebac6312ab6..d63e704e06bfbf030bb7a501e7f20e8a4b63342f 100644 (file)
@@ -56,7 +56,7 @@
 use syntax::{abi, ast};
 use syntax::feature_gate::UnstableFeatures;
 use rustc::middle::cstore::LOCAL_CRATE;
-use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId};
+use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
 use rustc::middle::privacy::AccessLevels;
 use rustc::middle::stability;
 use rustc::session::config::get_unstable_features_setting;
index 31f00caee436f762cc473d1ee086360fd4435060..ff2a9f13e8a1287d39425c78d169d9700aebf89f 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use rustc::middle::def_id::DefId;
+use rustc::hir::def_id::DefId;
 use rustc::middle::privacy::AccessLevels;
 use rustc::util::nodemap::DefIdSet;
 use std::cmp;