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;
// 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;
--- /dev/null
+// 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",
+ }
+ }
+}
--- /dev/null
+// 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
+ }
+}
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;
// 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;
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};
}
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;
--- /dev/null
+// 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
+}
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;
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;
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;
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;
pub mod lang_items;
pub mod liveness;
pub mod mem_categorization;
- pub mod pat_util;
pub mod privacy;
pub mod reachable;
pub mod region;
* 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;
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::*;
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;
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>;
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;
+++ /dev/null
-// 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",
- }
- }
-}
+++ /dev/null
-// 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
- }
-}
use self::RootUnsafeContext::*;
use dep_graph::DepNode;
-use middle::def::Def;
+use hir::def::Def;
use ty::{self, Ty, TyCtxt};
use ty::MethodCall;
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;
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};
// 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};
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;
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;
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};
+++ /dev/null
-// 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
-}
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;
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;
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;
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;
// 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::*;
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};
};
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;
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};
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};
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};
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};
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};
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};
// 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};
// 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;
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;
// 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};
// 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;
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;
// 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;
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;
//! 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};
//! 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;
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};
// 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;
//! 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};
// 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;
#![allow(non_snake_case)]
-use middle::def_id::DefId;
+use hir::def_id::DefId;
use syntax::ast;
pub use rustc_data_structures::fnv::FnvHashMap;
// 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};
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;
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;
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;
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;
// 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};
//! 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;
#![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};
// 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;
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};
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;
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;
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};
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;
// 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;
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};
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;
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;
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;
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};
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};
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};
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;
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};
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;
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;
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};
}
/// 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;
use {resolve_error, ResolutionError};
use rustc::lint;
-use rustc::middle::def::*;
+use rustc::hir::def::*;
use syntax::ast::{NodeId, Name};
use syntax::attr::AttrMetaMethods;
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::*;
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;
//! 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};
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};
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::*;
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};
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};
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};
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};
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};
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};
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;
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};
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;
// 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::*;
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;
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};
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;
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;
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};
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};
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::*;
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;
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;
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};
#![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;
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;
// 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};
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;
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;
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;
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};
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};
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;
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;
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};
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;
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;
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;
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};
// 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};
//! 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;
//! 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};
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;
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};
//! 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;
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;
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;
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;
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;
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;
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;
// 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;