Rollup merge of #32570 - eddyb:tis-but-a-front, r=nikomatsakis

r? @nikomatsakis

Conflicts:
	src/librustc_save_analysis/lib.rs
	src/libsyntax/ast_util.rs
This commit is contained in:
Manish Goregaokar 2016-04-06 17:31:16 +05:30
commit 552af51ffb
235 changed files with 1307 additions and 2183 deletions

View File

@ -56,7 +56,7 @@ TARGET_CRATES := libc std term \
alloc_system alloc_jemalloc
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
rustc_data_structures rustc_front rustc_platform_intrinsics \
rustc_data_structures rustc_platform_intrinsics \
rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
rustc_const_eval rustc_const_math
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
@ -93,38 +93,37 @@ DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
DEPS_syntax_ext := syntax fmt_macros
DEPS_rustc_const_math := std syntax log serialize
DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize rustc_front \
DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
rustc_back graphviz
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml rustc_front\
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml \
log graphviz rustc_back rustc_data_structures\
rustc_const_math
DEPS_rustc_back := std syntax rustc_front flate log libc
DEPS_rustc_borrowck := rustc rustc_front rustc_mir log graphviz syntax
DEPS_rustc_back := std syntax flate log libc
DEPS_rustc_borrowck := rustc rustc_mir log graphviz syntax
DEPS_rustc_data_structures := std log serialize
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \
rustc_trans rustc_privacy rustc_lint rustc_plugin \
rustc_metadata syntax_ext rustc_passes rustc_save_analysis rustc_const_eval
DEPS_rustc_front := std syntax log serialize
DEPS_rustc_lint := rustc log syntax rustc_const_eval
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
DEPS_rustc_metadata := rustc rustc_front syntax rbml rustc_const_math
DEPS_rustc_passes := syntax rustc core rustc_front rustc_const_eval
DEPS_rustc_mir := rustc rustc_front syntax rustc_const_math rustc_const_eval
DEPS_rustc_resolve := arena rustc rustc_front log syntax
DEPS_rustc_metadata := rustc syntax rbml rustc_const_math
DEPS_rustc_passes := syntax rustc core rustc_const_eval
DEPS_rustc_mir := rustc syntax rustc_const_math rustc_const_eval
DEPS_rustc_resolve := arena rustc log syntax
DEPS_rustc_platform_intrinsics := std
DEPS_rustc_plugin := rustc rustc_metadata syntax rustc_mir
DEPS_rustc_privacy := rustc rustc_front log syntax
DEPS_rustc_privacy := rustc log syntax
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics \
log syntax serialize rustc_llvm rustc_platform_intrinsics \
rustc_const_math rustc_const_eval
DEPS_rustc_save_analysis := rustc log syntax rustc_front
DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics rustc_const_math \
DEPS_rustc_save_analysis := rustc log syntax
DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
rustc_const_eval
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
test rustc_lint rustc_front rustc_const_eval
test rustc_lint rustc_const_eval
TOOL_DEPS_compiletest := test getopts log

View File

@ -19,6 +19,5 @@ rustc_back = { path = "../librustc_back" }
rustc_bitflags = { path = "../librustc_bitflags" }
rustc_const_math = { path = "../librustc_const_math" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_front = { path = "../librustc_front" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }

View File

@ -10,13 +10,13 @@
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;
use rustc_front::hir::{self, PatKind};
use hir::{self, PatKind};
struct CFGBuilder<'a, 'tcx: 'a> {
tcx: &'a TyCtxt<'tcx>,
@ -257,7 +257,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.match_(expr.id, &discr, &arms, pred)
}
hir::ExprBinary(op, ref l, ref r) if ::rustc_front::util::lazy_binop(op.node) => {
hir::ExprBinary(op, ref l, ref r) if op.node.is_lazy() => {
//
// [pred]
// |

View File

@ -17,7 +17,7 @@ use graphviz::IntoCow;
use syntax::ast;
use front::map as ast_map;
use hir::map as ast_map;
use cfg;
pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);

View File

@ -14,7 +14,7 @@
use rustc_data_structures::graph;
use ty::TyCtxt;
use syntax::ast;
use rustc_front::hir;
use hir;
mod construct;
pub mod graphviz;

View File

@ -9,11 +9,11 @@
// 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 rustc_front::hir;
use rustc_front::intravisit::Visitor;
use hir;
use hir::intravisit::Visitor;
use std::rc::Rc;
mod dep_tracking_map;

View File

@ -8,11 +8,11 @@
// 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::ParamSpace;
use util::nodemap::NodeMap;
use syntax::ast;
use rustc_front::hir;
use hir;
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum Def {

View File

@ -908,14 +908,6 @@ pub fn noop_fold_item<T: Folder>(item: Item, folder: &mut T) -> Item {
let Item { id, name, attrs, node, vis, span } = item;
let id = folder.new_id(id);
let node = folder.fold_item_underscore(node);
// FIXME: we should update the impl_pretty_name, but it uses pretty printing.
// let ident = match node {
// // The node may have changed, recompute the "pretty" impl name.
// ItemImpl(_, _, _, ref maybe_trait, ref ty, _) => {
// impl_pretty_name(maybe_trait, Some(&**ty))
// }
// _ => ident
// };
Item {
id: id,

View File

@ -31,6 +31,9 @@ use syntax::attr::ThinAttributesExt;
use syntax::codemap::Span;
use hir::*;
use std::cmp;
use std::u32;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum FnKind<'a> {
/// fn foo() or extern "Abi" fn foo()
@ -835,3 +838,233 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
visitor.visit_expr(&arm.body);
walk_list!(visitor, visit_attribute, &arm.attrs);
}
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct IdRange {
pub min: NodeId,
pub max: NodeId,
}
impl IdRange {
pub fn max() -> IdRange {
IdRange {
min: u32::MAX,
max: u32::MIN,
}
}
pub fn empty(&self) -> bool {
self.min >= self.max
}
pub fn add(&mut self, id: NodeId) {
self.min = cmp::min(self.min, id);
self.max = cmp::max(self.max, id + 1);
}
}
pub trait IdVisitingOperation {
fn visit_id(&mut self, node_id: NodeId);
}
pub struct IdRangeComputingVisitor {
pub result: IdRange,
}
impl IdRangeComputingVisitor {
pub fn new() -> IdRangeComputingVisitor {
IdRangeComputingVisitor { result: IdRange::max() }
}
pub fn result(&self) -> IdRange {
self.result
}
}
impl IdVisitingOperation for IdRangeComputingVisitor {
fn visit_id(&mut self, id: NodeId) {
self.result.add(id);
}
}
pub struct IdVisitor<'a, O: 'a> {
operation: &'a mut O,
// In general, the id visitor visits the contents of an item, but
// not including nested trait/impl items, nor other nested items.
// The base visitor itself always skips nested items, but not
// trait/impl items. This means in particular that if you start by
// visiting a trait or an impl, you should not visit the
// trait/impl items respectively. This is handled by setting
// `skip_members` to true when `visit_item` is on the stack. This
// way, if the user begins by calling `visit_trait_item`, we will
// visit the trait item, but if they begin with `visit_item`, we
// won't visit the (nested) trait items.
skip_members: bool,
}
impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> {
pub fn new(operation: &'a mut O) -> IdVisitor<'a, O> {
IdVisitor { operation: operation, skip_members: false }
}
fn visit_generics_helper(&mut self, generics: &Generics) {
for type_parameter in generics.ty_params.iter() {
self.operation.visit_id(type_parameter.id)
}
for lifetime in &generics.lifetimes {
self.operation.visit_id(lifetime.lifetime.id)
}
}
}
impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
fn visit_mod(&mut self, module: &Mod, _: Span, node_id: NodeId) {
self.operation.visit_id(node_id);
walk_mod(self, module)
}
fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
self.operation.visit_id(foreign_item.id);
walk_foreign_item(self, foreign_item)
}
fn visit_item(&mut self, item: &Item) {
assert!(!self.skip_members);
self.skip_members = true;
self.operation.visit_id(item.id);
match item.node {
ItemUse(ref view_path) => {
match view_path.node {
ViewPathSimple(_, _) |
ViewPathGlob(_) => {}
ViewPathList(_, ref paths) => {
for path in paths {
self.operation.visit_id(path.node.id())
}
}
}
}
_ => {}
}
walk_item(self, item);
self.skip_members = false;
}
fn visit_local(&mut self, local: &Local) {
self.operation.visit_id(local.id);
walk_local(self, local)
}
fn visit_block(&mut self, block: &Block) {
self.operation.visit_id(block.id);
walk_block(self, block)
}
fn visit_stmt(&mut self, statement: &Stmt) {
self.operation.visit_id(statement.node.id());
walk_stmt(self, statement)
}
fn visit_pat(&mut self, pattern: &Pat) {
self.operation.visit_id(pattern.id);
walk_pat(self, pattern)
}
fn visit_expr(&mut self, expression: &Expr) {
self.operation.visit_id(expression.id);
walk_expr(self, expression)
}
fn visit_ty(&mut self, typ: &Ty) {
self.operation.visit_id(typ.id);
walk_ty(self, typ)
}
fn visit_generics(&mut self, generics: &Generics) {
self.visit_generics_helper(generics);
walk_generics(self, generics)
}
fn visit_fn(&mut self,
function_kind: FnKind<'v>,
function_declaration: &'v FnDecl,
block: &'v Block,
span: Span,
node_id: NodeId) {
self.operation.visit_id(node_id);
match function_kind {
FnKind::ItemFn(_, generics, _, _, _, _, _) => {
self.visit_generics_helper(generics)
}
FnKind::Method(_, sig, _, _) => {
self.visit_generics_helper(&sig.generics)
}
FnKind::Closure(_) => {}
}
for argument in &function_declaration.inputs {
self.operation.visit_id(argument.id)
}
walk_fn(self, function_kind, function_declaration, block, span);
}
fn visit_struct_field(&mut self, struct_field: &StructField) {
self.operation.visit_id(struct_field.id);
walk_struct_field(self, struct_field)
}
fn visit_variant_data(&mut self,
struct_def: &VariantData,
_: Name,
_: &Generics,
_: NodeId,
_: Span) {
self.operation.visit_id(struct_def.id());
walk_struct_def(self, struct_def);
}
fn visit_trait_item(&mut self, ti: &TraitItem) {
if !self.skip_members {
self.operation.visit_id(ti.id);
walk_trait_item(self, ti);
}
}
fn visit_impl_item(&mut self, ii: &ImplItem) {
if !self.skip_members {
self.operation.visit_id(ii.id);
walk_impl_item(self, ii);
}
}
fn visit_lifetime(&mut self, lifetime: &Lifetime) {
self.operation.visit_id(lifetime.id);
}
fn visit_lifetime_def(&mut self, def: &LifetimeDef) {
self.visit_lifetime(&def.lifetime);
}
fn visit_trait_ref(&mut self, trait_ref: &TraitRef) {
self.operation.visit_id(trait_ref.ref_id);
walk_trait_ref(self, trait_ref);
}
}
/// Computes the id range for a single fn body, ignoring nested items.
pub fn compute_id_range_for_fn_body(fk: FnKind,
decl: &FnDecl,
body: &Block,
sp: Span,
id: NodeId)
-> IdRange {
let mut visitor = IdRangeComputingVisitor { result: IdRange::max() };
let mut id_visitor = IdVisitor::new(&mut visitor);
id_visitor.visit_fn(fk, decl, body, sp, id);
id_visitor.operation.result
}

View File

@ -23,14 +23,14 @@
pub use self::Code::*;
use front::map::{self, Node};
use hir::map::{self, Node};
use syntax::abi;
use rustc_front::hir::{Block, FnDecl};
use hir::{Block, FnDecl};
use syntax::ast::{Attribute, Name, NodeId};
use syntax::attr::ThinAttributesExt;
use rustc_front::hir as ast;
use hir as ast;
use syntax::codemap::Span;
use rustc_front::intravisit::FnKind;
use hir::intravisit::FnKind;
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
/// and a body (as well as a NodeId, a span, etc).

View File

@ -11,10 +11,10 @@
use super::*;
use super::MapEntry::*;
use rustc_front::hir::*;
use rustc_front::util;
use rustc_front::intravisit::{self, Visitor};
use middle::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
use hir::*;
use hir::intravisit::Visitor;
use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
use middle::cstore::InlinedItem;
use std::iter::repeat;
use syntax::ast::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
use syntax::codemap::Span;
@ -47,7 +47,7 @@ impl<'ast> NodeCollector<'ast> {
}
pub fn extend(krate: &'ast Crate,
parent: &'ast InlinedParent,
parent: &'ast InlinedItem,
parent_node: NodeId,
parent_def_path: DefPath,
parent_def_id: DefId,
@ -305,7 +305,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
}
fn visit_stmt(&mut self, stmt: &'ast Stmt) {
let id = util::stmt_id(stmt);
let id = stmt.node.id();
self.insert(id, NodeStmt(stmt));
let parent_node = self.parent_node;
self.parent_node = id;

View 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;

View File

@ -9,7 +9,6 @@
// except according to those terms.
pub use self::Node::*;
pub use self::PathElem::*;
use self::MapEntry::*;
use self::collector::NodeCollector;
pub use self::definitions::{Definitions, DefKey, DefPath, DefPathData,
@ -19,100 +18,26 @@ use dep_graph::{DepGraph, DepNode};
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};
use syntax::attr::ThinAttributesExt;
use syntax::codemap::{Span, Spanned};
use syntax::parse::token;
use rustc_front::hir::*;
use rustc_front::fold::Folder;
use rustc_front::intravisit;
use rustc_front::print::pprust;
use hir::*;
use hir::fold::Folder;
use hir::print as pprust;
use arena::TypedArena;
use std::cell::RefCell;
use std::fmt;
use std::io;
use std::iter;
use std::mem;
use std::slice;
pub mod blocks;
mod collector;
pub mod definitions;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum PathElem {
PathMod(Name),
PathName(Name)
}
impl PathElem {
pub fn name(&self) -> Name {
match *self {
PathMod(name) | PathName(name) => name
}
}
}
impl fmt::Display for PathElem {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.name())
}
}
#[derive(Clone)]
pub struct LinkedPathNode<'a> {
node: PathElem,
next: LinkedPath<'a>,
}
#[derive(Copy, Clone)]
pub struct LinkedPath<'a>(Option<&'a LinkedPathNode<'a>>);
impl<'a> LinkedPath<'a> {
pub fn empty() -> LinkedPath<'a> {
LinkedPath(None)
}
pub fn from(node: &'a LinkedPathNode) -> LinkedPath<'a> {
LinkedPath(Some(node))
}
}
impl<'a> Iterator for LinkedPath<'a> {
type Item = PathElem;
fn next(&mut self) -> Option<PathElem> {
match self.0 {
Some(node) => {
*self = node.next;
Some(node.node)
}
None => None
}
}
}
/// The type of the iterator used by with_path.
pub type PathElems<'a, 'b> = iter::Chain<iter::Cloned<slice::Iter<'a, PathElem>>, LinkedPath<'b>>;
pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
let itr = token::get_ident_interner();
path.fold(String::new(), |mut s, e| {
let e = itr.get(e.name());
if !s.is_empty() {
s.push_str("::");
}
s.push_str(&e[..]);
s
})
}
#[derive(Copy, Clone, Debug)]
pub enum Node<'ast> {
NodeItem(&'ast Item),
@ -157,7 +82,7 @@ pub enum MapEntry<'ast> {
/// Roots for node trees.
RootCrate,
RootInlinedParent(&'ast InlinedParent)
RootInlinedParent(&'ast InlinedItem)
}
impl<'ast> Clone for MapEntry<'ast> {
@ -166,12 +91,6 @@ impl<'ast> Clone for MapEntry<'ast> {
}
}
#[derive(Debug)]
pub struct InlinedParent {
path: Vec<PathElem>,
ii: InlinedItem
}
impl<'ast> MapEntry<'ast> {
fn from_node(p: NodeId, node: Node<'ast>) -> MapEntry<'ast> {
match node {
@ -234,7 +153,7 @@ impl<'ast> MapEntry<'ast> {
pub struct Forest {
krate: Crate,
pub dep_graph: DepGraph,
inlined_items: TypedArena<InlinedParent>
inlined_items: TypedArena<InlinedItem>
}
impl Forest {
@ -352,8 +271,10 @@ impl<'ast> Map<'ast> {
self.definitions.borrow().def_key(def_id.index)
}
pub fn def_path_from_id(&self, id: NodeId) -> DefPath {
self.def_path(self.local_def_id(id))
pub fn def_path_from_id(&self, id: NodeId) -> Option<DefPath> {
self.opt_local_def_id(id).map(|def_id| {
self.def_path(def_id)
})
}
pub fn def_path(&self, def_id: DefId) -> DefPath {
@ -552,8 +473,8 @@ impl<'ast> Map<'ast> {
pub fn get_parent_did(&self, id: NodeId) -> DefId {
let parent = self.get_parent(id);
match self.find_entry(parent) {
Some(RootInlinedParent(&InlinedParent {ii: II::TraitItem(did, _), ..})) => did,
Some(RootInlinedParent(&InlinedParent {ii: II::ImplItem(did, _), ..})) => did,
Some(RootInlinedParent(&II::TraitItem(did, _))) |
Some(RootInlinedParent(&II::ImplItem(did, _))) => did,
_ => self.local_def_id(parent)
}
}
@ -635,80 +556,21 @@ impl<'ast> Map<'ast> {
}
}
/// returns the name associated with the given NodeId's AST
pub fn get_path_elem(&self, id: NodeId) -> PathElem {
let node = self.get(id);
match node {
NodeItem(item) => {
match item.node {
ItemMod(_) | ItemForeignMod(_) => {
PathMod(item.name)
}
_ => PathName(item.name)
}
}
NodeForeignItem(i) => PathName(i.name),
NodeImplItem(ii) => PathName(ii.name),
NodeTraitItem(ti) => PathName(ti.name),
NodeVariant(v) => PathName(v.node.name),
NodeLifetime(lt) => PathName(lt.name),
NodeTyParam(tp) => PathName(tp.name),
/// Returns the name associated with the given NodeId's AST.
pub fn name(&self, id: NodeId) -> Name {
match self.get(id) {
NodeItem(i) => i.name,
NodeForeignItem(i) => i.name,
NodeImplItem(ii) => ii.name,
NodeTraitItem(ti) => ti.name,
NodeVariant(v) => v.node.name,
NodeLifetime(lt) => lt.name,
NodeTyParam(tp) => tp.name,
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
PathName(l.node.name)
l.node.name
},
_ => bug!("no path elem for {:?}", node)
}
}
pub fn with_path<T, F>(&self, id: NodeId, f: F) -> T where
F: FnOnce(PathElems) -> T,
{
self.with_path_next(id, LinkedPath::empty(), f)
}
pub fn path_to_string(&self, id: NodeId) -> String {
self.with_path(id, |path| path_to_string(path))
}
fn path_to_str_with_name(&self, id: NodeId, name: Name) -> String {
self.with_path(id, |path| {
path_to_string(path.chain(Some(PathName(name))))
})
}
fn with_path_next<T, F>(&self, id: NodeId, next: LinkedPath, f: F) -> T where
F: FnOnce(PathElems) -> T,
{
// This function reveals the name of the item and hence is a
// kind of read. This is inefficient, since it walks ancestors
// and we are walking them anyhow, but whatever.
self.read(id);
let parent = self.get_parent(id);
let parent = match self.find_entry(id) {
Some(EntryForeignItem(..)) => {
// Anonymous extern items go in the parent scope.
self.get_parent(parent)
}
// But tuple struct ctors don't have names, so use the path of its
// parent, the struct item. Similarly with closure expressions.
Some(EntryStructCtor(..)) | Some(EntryExpr(..)) => {
return self.with_path_next(parent, next, f);
}
_ => parent
};
if parent == id {
match self.find_entry(id) {
Some(RootInlinedParent(data)) => {
f(data.path.iter().cloned().chain(next))
}
_ => f([].iter().cloned().chain(next))
}
} else {
self.with_path_next(parent, LinkedPath::from(&LinkedPathNode {
node: self.get_path_elem(id),
next: next
}), f)
NodeStructCtor(_) => self.name(self.get_parent(id)),
_ => bug!("no name for {}", self.node_to_string(id))
}
}
@ -959,7 +821,6 @@ pub fn map_crate<'ast>(forest: &'ast mut Forest) -> Map<'ast> {
/// Used for items loaded from external crate that are being inlined into this
/// crate.
pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
parent_path: Vec<PathElem>,
parent_def_path: DefPath,
parent_def_id: DefId,
ii: InlinedItem,
@ -979,27 +840,24 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
II::Foreign(i) => II::Foreign(i.map(|i| fld.fold_foreign_item(i)))
};
let ii_parent = map.forest.inlined_items.alloc(InlinedParent {
path: parent_path,
ii: ii
});
let ii = map.forest.inlined_items.alloc(ii);
let ii_parent_id = fld.new_id(DUMMY_NODE_ID);
let mut collector =
NodeCollector::extend(
map.krate(),
ii_parent,
ii,
ii_parent_id,
parent_def_path,
parent_def_id,
mem::replace(&mut *map.map.borrow_mut(), vec![]),
mem::replace(&mut *map.definitions.borrow_mut(), Definitions::new()));
ii_parent.ii.visit(&mut collector);
ii.visit(&mut collector);
*map.map.borrow_mut() = collector.map;
*map.definitions.borrow_mut() = collector.definitions;
&ii_parent.ii
ii
}
pub trait NodePrinter {
@ -1033,9 +891,24 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
let id_str = format!(" (id={})", id);
let id_str = if include_id { &id_str[..] } else { "" };
let path_str = || {
// This functionality is used for debugging, try to use TyCtxt to get
// the user-friendly path, otherwise fall back to stringifying DefPath.
::ty::tls::with_opt(|tcx| {
if let Some(tcx) = tcx {
tcx.node_path_str(id)
} else if let Some(path) = map.def_path_from_id(id) {
path.data.into_iter().map(|elem| {
elem.data.to_string()
}).collect::<Vec<_>>().join("::")
} else {
String::from("<missing path>")
}
})
};
match map.find(id) {
Some(NodeItem(item)) => {
let path_str = map.path_to_str_with_name(id, item.name);
let item_str = match item.node {
ItemExternCrate(..) => "extern crate",
ItemUse(..) => "use",
@ -1051,30 +924,21 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
ItemImpl(..) => "impl",
ItemDefaultImpl(..) => "default impl",
};
format!("{} {}{}", item_str, path_str, id_str)
format!("{} {}{}", item_str, path_str(), id_str)
}
Some(NodeForeignItem(item)) => {
let path_str = map.path_to_str_with_name(id, item.name);
format!("foreign item {}{}", path_str, id_str)
Some(NodeForeignItem(_)) => {
format!("foreign item {}{}", path_str(), id_str)
}
Some(NodeImplItem(ii)) => {
match ii.node {
ImplItemKind::Const(..) => {
format!("assoc const {} in {}{}",
ii.name,
map.path_to_string(id),
id_str)
format!("assoc const {} in {}{}", ii.name, path_str(), id_str)
}
ImplItemKind::Method(..) => {
format!("method {} in {}{}",
ii.name,
map.path_to_string(id), id_str)
format!("method {} in {}{}", ii.name, path_str(), id_str)
}
ImplItemKind::Type(_) => {
format!("assoc type {} in {}{}",
ii.name,
map.path_to_string(id),
id_str)
format!("assoc type {} in {}{}", ii.name, path_str(), id_str)
}
}
}
@ -1085,16 +949,12 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
TypeTraitItem(..) => "assoc type",
};
format!("{} {} in {}{}",
kind,
ti.name,
map.path_to_string(id),
id_str)
format!("{} {} in {}{}", kind, ti.name, path_str(), id_str)
}
Some(NodeVariant(ref variant)) => {
format!("variant {} in {}{}",
variant.node.name,
map.path_to_string(id), id_str)
path_str(), id_str)
}
Some(NodeExpr(ref expr)) => {
format!("expr {}{}", pprust::expr_to_string(&expr), id_str)
@ -1112,7 +972,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
format!("block {}{}", pprust::block_to_string(&block), id_str)
}
Some(NodeStructCtor(_)) => {
format!("struct_ctor {}{}", map.path_to_string(id), id_str)
format!("struct_ctor {}{}", path_str(), id_str)
}
Some(NodeLifetime(ref l)) => {
format!("lifetime {}{}",

View File

@ -33,8 +33,10 @@ pub use self::ViewPath_::*;
pub use self::Visibility::*;
pub use self::PathParameters::*;
use intravisit::Visitor;
use std::collections::BTreeMap;
use hir::def::Def;
use hir::def_id::DefId;
use util::nodemap::{NodeMap, FnvHashSet};
use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
use syntax::abi::Abi;
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
@ -43,9 +45,7 @@ use syntax::attr::{ThinAttributes, ThinAttributesExt};
use syntax::parse::token::InternedString;
use syntax::ptr::P;
use print::pprust;
use util;
use std::collections::BTreeMap;
use std::fmt;
use std::hash::{Hash, Hasher};
use serialize::{Encodable, Decodable, Encoder, Decoder};
@ -63,9 +63,20 @@ macro_rules! hir_vec {
($($x:expr),*) => (
$crate::hir::HirVec::from(vec![$($x),*])
);
($($x:expr,)*) => (vec![$($x),*])
($($x:expr,)*) => (hir_vec![$($x),*])
}
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;
/// Identifier in HIR
#[derive(Clone, Copy, Eq)]
pub struct Ident {
@ -135,7 +146,7 @@ impl fmt::Debug for Lifetime {
write!(f,
"lifetime({}: {})",
self.id,
pprust::lifetime_to_string(self))
print::lifetime_to_string(self))
}
}
@ -161,13 +172,28 @@ pub struct Path {
impl fmt::Debug for Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "path({})", pprust::path_to_string(self))
write!(f, "path({})", print::path_to_string(self))
}
}
impl fmt::Display for Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", pprust::path_to_string(self))
write!(f, "{}", print::path_to_string(self))
}
}
impl Path {
/// Convert a span and an identifier to the corresponding
/// 1-segment path.
pub fn from_ident(s: Span, ident: Ident) -> Path {
Path {
span: s,
global: false,
segments: hir_vec![PathSegment {
identifier: ident,
parameters: PathParameters::none()
}],
}
}
}
@ -344,12 +370,25 @@ pub struct Generics {
}
impl Generics {
pub fn empty() -> Generics {
Generics {
lifetimes: HirVec::new(),
ty_params: HirVec::new(),
where_clause: WhereClause {
id: DUMMY_NODE_ID,
predicates: HirVec::new(),
},
}
}
pub fn is_lt_parameterized(&self) -> bool {
!self.lifetimes.is_empty()
}
pub fn is_type_parameterized(&self) -> bool {
!self.ty_params.is_empty()
}
pub fn is_parameterized(&self) -> bool {
self.is_lt_parameterized() || self.is_type_parameterized()
}
@ -434,7 +473,9 @@ impl Crate {
/// follows lexical scoping rules -- then you want a different
/// approach. You should override `visit_nested_item` in your
/// visitor and then call `intravisit::walk_crate` instead.
pub fn visit_all_items<'hir, V:Visitor<'hir>>(&'hir self, visitor: &mut V) {
pub fn visit_all_items<'hir, V>(&'hir self, visitor: &mut V)
where V: intravisit::Visitor<'hir>
{
for (_, item) in &self.items {
visitor.visit_item(item);
}
@ -479,7 +520,51 @@ pub struct Pat {
impl fmt::Debug for Pat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "pat({}: {})", self.id, pprust::pat_to_string(self))
write!(f, "pat({}: {})", self.id, print::pat_to_string(self))
}
}
impl Pat {
// FIXME(#19596) this is a workaround, but there should be a better way
fn walk_<G>(&self, it: &mut G) -> bool
where G: FnMut(&Pat) -> bool
{
if !it(self) {
return false;
}
match self.node {
PatKind::Ident(_, _, Some(ref p)) => p.walk_(it),
PatKind::Struct(_, ref fields, _) => {
fields.iter().all(|field| field.node.pat.walk_(it))
}
PatKind::TupleStruct(_, Some(ref s)) | PatKind::Tup(ref s) => {
s.iter().all(|p| p.walk_(it))
}
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
s.walk_(it)
}
PatKind::Vec(ref before, ref slice, ref after) => {
before.iter().all(|p| p.walk_(it)) &&
slice.iter().all(|p| p.walk_(it)) &&
after.iter().all(|p| p.walk_(it))
}
PatKind::Wild |
PatKind::Lit(_) |
PatKind::Range(_, _) |
PatKind::Ident(_, _, _) |
PatKind::TupleStruct(..) |
PatKind::Path(..) |
PatKind::QPath(_, _) => {
true
}
}
}
pub fn walk<F>(&self, mut it: F) -> bool
where F: FnMut(&Pat) -> bool
{
self.walk_(&mut it)
}
}
@ -597,6 +682,68 @@ pub enum BinOp_ {
BiGt,
}
impl BinOp_ {
pub fn as_str(self) -> &'static str {
match self {
BiAdd => "+",
BiSub => "-",
BiMul => "*",
BiDiv => "/",
BiRem => "%",
BiAnd => "&&",
BiOr => "||",
BiBitXor => "^",
BiBitAnd => "&",
BiBitOr => "|",
BiShl => "<<",
BiShr => ">>",
BiEq => "==",
BiLt => "<",
BiLe => "<=",
BiNe => "!=",
BiGe => ">=",
BiGt => ">",
}
}
pub fn is_lazy(self) -> bool {
match self {
BiAnd | BiOr => true,
_ => false,
}
}
pub fn is_shift(self) -> bool {
match self {
BiShl | BiShr => true,
_ => false,
}
}
pub fn is_comparison(self) -> bool {
match self {
BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true,
BiAnd |
BiOr |
BiAdd |
BiSub |
BiMul |
BiDiv |
BiRem |
BiBitXor |
BiBitAnd |
BiBitOr |
BiShl |
BiShr => false,
}
}
/// Returns `true` if the binary operator takes its arguments by value
pub fn is_by_value(self) -> bool {
!self.is_comparison()
}
}
pub type BinOp = Spanned<BinOp_>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@ -609,6 +756,24 @@ pub enum UnOp {
UnNeg,
}
impl UnOp {
pub fn as_str(self) -> &'static str {
match self {
UnDeref => "*",
UnNot => "!",
UnNeg => "-",
}
}
/// Returns `true` if the unary operator takes its argument by value
pub fn is_by_value(self) -> bool {
match self {
UnNeg | UnNot => true,
_ => false,
}
}
}
/// A statement
pub type Stmt = Spanned<Stmt_>;
@ -618,8 +783,8 @@ impl fmt::Debug for Stmt_ {
let spanned = codemap::dummy_spanned(self.clone());
write!(f,
"stmt({}: {})",
util::stmt_id(&spanned),
pprust::stmt_to_string(&spanned))
spanned.node.id(),
print::stmt_to_string(&spanned))
}
}
@ -643,6 +808,14 @@ impl Stmt_ {
StmtSemi(ref e, _) => e.attrs.as_attr_slice(),
}
}
pub fn id(&self) -> NodeId {
match *self {
StmtDecl(_, id) => id,
StmtExpr(_, id) => id,
StmtSemi(_, id) => id,
}
}
}
// FIXME (pending discussion of #1697, #2178...): local should really be
@ -722,7 +895,7 @@ pub struct Expr {
impl fmt::Debug for Expr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self))
write!(f, "expr({}: {})", self.id, print::expr_to_string(self))
}
}
@ -940,7 +1113,7 @@ pub struct Ty {
impl fmt::Debug for Ty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "type({})", pprust::ty_to_string(self))
write!(f, "type({})", print::ty_to_string(self))
}
}
@ -1456,3 +1629,24 @@ impl ForeignItem_ {
}
}
}
/// A free variable referred to in a function.
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct Freevar {
/// The variable being accessed free.
pub def: Def,
// First span where it is accessed (there can be multiple).
pub span: Span
}
pub type FreevarMap = NodeMap<Vec<Freevar>>;
pub type CaptureModeMap = NodeMap<CaptureClause>;
// Trait method resolution
pub type TraitMap = NodeMap<Vec<DefId>>;
// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = NodeMap<FnvHashSet<Name>>;

View File

@ -8,14 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use middle::def::*;
use middle::def_id::DefId;
use hir::def::*;
use hir::def_id::DefId;
use ty::TyCtxt;
use util::nodemap::FnvHashMap;
use syntax::ast;
use rustc_front::hir::{self, PatKind};
use rustc_front::util::walk_pat;
use hir::{self, PatKind};
use syntax::codemap::{respan, Span, Spanned, DUMMY_SP};
use std::cell::RefCell;
@ -115,7 +114,7 @@ pub fn pat_is_binding_or_wild(dm: &DefMap, pat: &hir::Pat) -> bool {
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>),
{
walk_pat(pat, |p| {
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));
@ -128,7 +127,7 @@ pub fn pat_bindings<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
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>),
{
walk_pat(pat, |p| {
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));
@ -143,7 +142,7 @@ pub fn pat_bindings_ident<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) wh
/// 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;
walk_pat(pat, |p| {
pat.walk(|p| {
if pat_is_binding(dm, p) {
contains_bindings = true;
false // there's at least one binding, can short circuit now.
@ -188,7 +187,7 @@ pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<
/// 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;
walk_pat(pat, |p| {
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.
@ -211,20 +210,14 @@ pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
}
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,
})
let name = tcx.item_name(id);
hir::Path::from_ident(DUMMY_SP, hir::Ident::from_name(name))
}
/// 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![];
walk_pat(pat, |p| {
pat.walk(|p| {
match p.node {
PatKind::TupleStruct(..) |
PatKind::Path(..) |

View File

@ -950,7 +950,7 @@ impl<'a> State<'a> {
pub fn print_variant(&mut self, v: &hir::Variant) -> io::Result<()> {
self.head("")?;
let generics = ::util::empty_generics();
let generics = hir::Generics::empty();
self.print_struct(&v.node.data, &generics, v.node.name, v.span, false)?;
match v.node.disr_expr {
Some(ref d) => {
@ -1285,12 +1285,12 @@ impl<'a> State<'a> {
-> io::Result<()> {
self.print_expr(lhs)?;
space(&mut self.s)?;
self.word_space(::util::binop_to_string(op.node))?;
self.word_space(op.node.as_str())?;
self.print_expr(rhs)
}
fn print_expr_unary(&mut self, op: hir::UnOp, expr: &hir::Expr) -> io::Result<()> {
word(&mut self.s, ::util::unop_to_string(op))?;
word(&mut self.s, op.as_str())?;
self.print_expr_maybe_paren(expr)
}
@ -1434,7 +1434,7 @@ impl<'a> State<'a> {
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
self.print_expr(&lhs)?;
space(&mut self.s)?;
word(&mut self.s, ::util::binop_to_string(op.node))?;
word(&mut self.s, op.node.as_str())?;
self.word_space("=")?;
self.print_expr(&rhs)?;
}

View File

@ -48,8 +48,8 @@
use std::fmt;
use std::hash::{Hash, SipHasher, Hasher};
use rustc_front::hir;
use rustc_front::intravisit as visit;
use hir;
use hir::intravisit as visit;
#[derive(Clone, PartialEq, Debug)]
pub struct Svh {
@ -134,10 +134,10 @@ mod svh_visitor {
use syntax::ast::{self, Name, NodeId};
use syntax::codemap::Span;
use syntax::parse::token;
use rustc_front::intravisit as visit;
use rustc_front::intravisit::{Visitor, FnKind};
use rustc_front::hir::*;
use rustc_front::hir;
use hir::intravisit as visit;
use hir::intravisit::{Visitor, FnKind};
use hir::*;
use hir;
use std::hash::{Hash, SipHasher};

View File

@ -73,13 +73,13 @@ use super::region_inference::SameRegions;
use std::collections::HashSet;
use front::map as ast_map;
use rustc_front::hir;
use rustc_front::print::pprust;
use hir::map as ast_map;
use hir;
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;
@ -587,13 +587,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
// Only external crates, if either is from a local
// module we could have false positives
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
let exp_path = self.tcx.with_path(did1,
|p| p.map(|x| x.to_string())
.collect::<Vec<_>>());
let found_path = self.tcx.with_path(did2,
|p| p.map(|x| x.to_string())
.collect::<Vec<_>>());
// We compare strings because PathMod and PathName can be different
let exp_path = self.tcx.item_path_str(did1);
let found_path = self.tcx.item_path_str(did2);
// We compare strings because DefPath can be different
// for imported and non-imported crates
if exp_path == found_path {
let crate_name = self.tcx.sess.cstore.crate_name(did1.krate);

View File

@ -18,8 +18,8 @@ pub use ty::IntVarValue;
pub use self::freshen::TypeFreshener;
pub use self::region_inference::{GenericKind, VerifyBound};
use middle::def_id::DefId;
use rustc_front::hir;
use hir::def_id::DefId;
use hir;
use middle::free_region::FreeRegionMap;
use middle::mem_categorization as mc;
use middle::mem_categorization::McResult;

View 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;

View File

@ -38,6 +38,7 @@
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(question_mark)]
#![cfg_attr(test, feature(test))]
@ -51,7 +52,6 @@ extern crate graphviz;
extern crate libc;
extern crate rbml;
extern crate rustc_back;
extern crate rustc_front;
extern crate rustc_data_structures;
extern crate serialize;
extern crate collections;
@ -72,19 +72,9 @@ mod macros;
// registered before they are used.
pub mod diagnostics;
pub mod back {
pub use rustc_back::rpath;
pub use rustc_back::svh;
}
pub mod cfg;
pub mod dep_graph;
pub mod front {
pub mod check_attr;
pub mod map;
}
pub mod hir;
pub mod infer;
pub mod lint;
@ -96,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;
@ -106,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;

View File

@ -39,16 +39,15 @@ use std::cell::RefCell;
use std::cmp;
use std::default::Default as StdDefault;
use std::mem;
use syntax::ast_util::{self, IdVisitingOperation};
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::Span;
use syntax::errors::DiagnosticBuilder;
use syntax::parse::token::InternedString;
use syntax::ast;
use syntax::attr::ThinAttributesExt;
use rustc_front::hir;
use rustc_front::util;
use rustc_front::intravisit as hir_visit;
use hir;
use hir::intravisit as hir_visit;
use hir::intravisit::{IdVisitor, IdVisitingOperation};
use syntax::visit as ast_visit;
/// Information about the registered lints.
@ -654,16 +653,6 @@ impl<'a> EarlyContext<'a> {
level_stack: vec![],
}
}
fn visit_ids<F>(&mut self, f: F)
where F: FnOnce(&mut ast_util::IdVisitor<EarlyContext>)
{
let mut v = ast_util::IdVisitor {
operation: self,
visited_outermost: false,
};
f(&mut v);
}
}
impl<'a, 'tcx> LateContext<'a, 'tcx> {
@ -685,9 +674,9 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
}
fn visit_ids<F>(&mut self, f: F)
where F: FnOnce(&mut util::IdVisitor<LateContext>)
where F: FnOnce(&mut IdVisitor<LateContext>)
{
let mut v = util::IdVisitor::new(self);
let mut v = IdVisitor::new(self);
f(&mut v);
}
}
@ -928,7 +917,6 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
fn visit_item(&mut self, it: &ast::Item) {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_item, early_passes, it);
cx.visit_ids(|v| v.visit_item(it));
ast_visit::walk_item(cx, it);
run_lints!(cx, check_item_post, early_passes, it);
})
@ -1042,7 +1030,6 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
self.with_lint_attrs(&trait_item.attrs, |cx| {
run_lints!(cx, check_trait_item, early_passes, trait_item);
cx.visit_ids(|v| v.visit_trait_item(trait_item));
ast_visit::walk_trait_item(cx, trait_item);
run_lints!(cx, check_trait_item_post, early_passes, trait_item);
});
@ -1051,7 +1038,6 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
self.with_lint_attrs(&impl_item.attrs, |cx| {
run_lints!(cx, check_impl_item, early_passes, impl_item);
cx.visit_ids(|v| v.visit_impl_item(impl_item));
ast_visit::walk_impl_item(cx, impl_item);
run_lints!(cx, check_impl_item_post, early_passes, impl_item);
});
@ -1099,18 +1085,6 @@ impl<'a, 'tcx> IdVisitingOperation for LateContext<'a, 'tcx> {
}
}
}
impl<'a> IdVisitingOperation for EarlyContext<'a> {
fn visit_id(&mut self, id: ast::NodeId) {
match self.sess.lints.borrow_mut().remove(&id) {
None => {}
Some(lints) => {
for (lint_id, span, msg) in lints {
self.span_lint(lint_id.lint, span, &msg[..])
}
}
}
}
}
// This lint pass is defined here because it touches parts of the `LateContext`
// that we don't want to expose. It records the lint level at certain AST
@ -1292,11 +1266,12 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
// Visit the whole crate.
cx.with_lint_attrs(&krate.attrs, |cx| {
cx.visit_id(ast::CRATE_NODE_ID);
cx.visit_ids(|v| {
v.visited_outermost = true;
ast_visit::walk_crate(v, krate);
});
// Lints may be assigned to the whole crate.
if let Some(lints) = cx.sess.lints.borrow_mut().remove(&ast::CRATE_NODE_ID) {
for (lint_id, span, msg) in lints {
cx.span_lint(lint_id.lint, span, &msg[..])
}
}
// since the root module isn't visited as an item (because it isn't an
// item), warn for it here.

View File

@ -34,10 +34,10 @@ pub use self::LintSource::*;
use std::hash;
use std::ascii::AsciiExt;
use syntax::codemap::Span;
use rustc_front::intravisit::FnKind;
use hir::intravisit::FnKind;
use syntax::visit as ast_visit;
use syntax::ast;
use rustc_front::hir;
use hir;
pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore,
raw_emit_lint, check_crate, check_ast_crate, gather_attrs,

View File

@ -14,11 +14,11 @@
* 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 rustc_front::hir as ast;
use hir as ast;
pub fn prohibit_type_params(tcx: &TyCtxt, segments: &[ast::PathSegment]) {
for segment in segments {

View 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::*;

View File

@ -22,12 +22,12 @@
// are *mostly* used as a part of that interface, but these should
// probably get a better home if someone can find one.
use back::svh::Svh;
use front::map as hir_map;
use middle::def::{self, Def};
use hir::svh::Svh;
use hir::map as hir_map;
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;
@ -38,15 +38,13 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::path::PathBuf;
use syntax::ast;
use syntax::ast_util::{IdVisitingOperation};
use syntax::attr;
use syntax::codemap::Span;
use syntax::ptr::P;
use syntax::parse::token::InternedString;
use rustc_back::target::Target;
use rustc_front::hir;
use rustc_front::intravisit::Visitor;
use rustc_front::util::IdVisitor;
use hir;
use hir::intravisit::{IdVisitor, IdVisitingOperation, Visitor};
pub use self::DefLike::{DlDef, DlField, DlImpl};
pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown};
@ -168,9 +166,7 @@ pub trait CrateStore<'tcx> : Any {
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr>;
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::TypeScheme<'tcx>;
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>;
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>;
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem>;
fn item_name(&self, def: DefId) -> ast::Name;
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx>;
@ -347,12 +343,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { bug!("repr_attrs") }
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::TypeScheme<'tcx> { bug!("item_type") }
fn relative_item_path(&self, def: DefId)
-> Vec<hir_map::PathElem> { bug!("relative_item_path") }
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
bug!("visible_parent_map")
}
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { bug!("extern_item_path") }
fn item_name(&self, def: DefId) -> ast::Name { bug!("item_name") }
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
@ -506,7 +499,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>;

View File

@ -21,13 +21,12 @@ use std::io;
use std::mem;
use std::usize;
use syntax::ast;
use syntax::ast_util::IdRange;
use syntax::print::pp;
use syntax::print::pprust::PrintState;
use util::nodemap::NodeMap;
use rustc_front::hir;
use rustc_front::intravisit;
use rustc_front::print::pprust;
use hir;
use hir::intravisit::{self, IdRange};
use hir::print as pprust;
#[derive(Copy, Clone, Debug)]

View File

@ -13,14 +13,14 @@
// from live codes are live, and everything else is dead.
use dep_graph::DepNode;
use front::map as ast_map;
use rustc_front::hir::{self, PatKind};
use rustc_front::intravisit::{self, Visitor};
use hir::map as ast_map;
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;

View File

@ -13,15 +13,15 @@
use self::RootUnsafeContext::*;
use dep_graph::DepNode;
use middle::def::Def;
use hir::def::Def;
use ty::{self, Ty, TyCtxt};
use ty::MethodCall;
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir;
use rustc_front::intravisit;
use rustc_front::intravisit::{FnKind, Visitor};
use hir;
use hir::intravisit;
use hir::intravisit::{FnKind, Visitor};
#[derive(Copy, Clone)]
struct UnsafeContext {

View File

@ -10,15 +10,15 @@
use dep_graph::DepNode;
use front::map as ast_map;
use middle::def_id::{CRATE_DEF_INDEX};
use hir::map as ast_map;
use hir::def_id::{CRATE_DEF_INDEX};
use session::{config, Session};
use syntax::ast::NodeId;
use syntax::attr;
use syntax::codemap::Span;
use syntax::entry::EntryPointType;
use rustc_front::hir::{Item, ItemFn};
use rustc_front::intravisit::Visitor;
use hir::{Item, ItemFn};
use hir::intravisit::Visitor;
struct EntryContext<'a, 'tcx: 'a> {
session: &'a Session,

View File

@ -19,14 +19,14 @@ pub use self::MatchMode::*;
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};
use rustc_front::hir::{self, PatKind};
use hir::{self, PatKind};
use syntax::ast;
use syntax::ptr::P;
@ -479,7 +479,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
}
hir::ExprUnary(op, ref lhs) => {
let pass_args = if ::rustc_front::util::is_by_value_unop(op) {
let pass_args = if op.is_by_value() {
PassArgs::ByValue
} else {
PassArgs::ByRef
@ -491,7 +491,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
}
hir::ExprBinary(op, ref lhs, ref rhs) => {
let pass_args = if ::rustc_front::util::is_by_value_binop(op.node) {
let pass_args = if op.node.is_by_value() {
PassArgs::ByValue
} else {
PassArgs::ByRef
@ -524,7 +524,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
// NB All our assignment operations take the RHS by value
assert!(::rustc_front::util::is_by_value_binop(op.node));
assert!(op.node.is_by_value());
if !self.walk_overloaded_operator(expr, lhs, vec![rhs], PassArgs::ByValue) {
self.mutate_expr(expr, &lhs, MutateMode::WriteAndRead);

View 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};
@ -20,8 +20,8 @@ use std::fmt;
use syntax::abi::Abi::RustIntrinsic;
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::intravisit::{self, Visitor, FnKind};
use rustc_front::hir;
use hir::intravisit::{self, Visitor, FnKind};
use hir;
pub fn check_crate(tcx: &TyCtxt) {
let mut visitor = IntrinsicCheckingVisitor {

View File

@ -22,10 +22,10 @@
pub use self::LangItem::*;
use dep_graph::DepNode;
use front::map as hir_map;
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;
@ -33,8 +33,8 @@ use util::nodemap::FnvHashMap;
use syntax::ast;
use syntax::attr::AttrMetaMethods;
use syntax::parse::token::InternedString;
use rustc_front::intravisit::Visitor;
use rustc_front::hir;
use hir::intravisit::Visitor;
use hir;
// The actual lang items defined come at the end of this file in one handy table.
// So you probably just want to nip down to the end.

View File

@ -110,8 +110,8 @@ use self::LiveNodeKind::*;
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;
@ -128,10 +128,10 @@ use syntax::codemap::{BytePos, original_sp, Span};
use syntax::parse::token::special_idents;
use syntax::ptr::P;
use rustc_front::hir::Expr;
use rustc_front::hir;
use rustc_front::print::pprust::{expr_to_string, block_to_string};
use rustc_front::intravisit::{self, Visitor, FnKind};
use hir::Expr;
use hir;
use hir::print::{expr_to_string, block_to_string};
use hir::intravisit::{self, Visitor, FnKind};
/// For use with `propagate_through_loop`.
enum LoopKind<'a> {
@ -484,7 +484,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
intravisit::walk_expr(ir, expr);
}
hir::ExprBinary(op, _, _) if ::rustc_front::util::lazy_binop(op.node) => {
hir::ExprBinary(op, _, _) if op.node.is_lazy() => {
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
intravisit::walk_expr(ir, expr);
}
@ -1142,7 +1142,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.propagate_through_exprs(&exprs[..], succ)
}
hir::ExprBinary(op, ref l, ref r) if ::rustc_front::util::lazy_binop(op.node) => {
hir::ExprBinary(op, ref l, ref r) if op.node.is_lazy() => {
let r_succ = self.propagate_through_expr(&r, succ);
let ln = self.live_node(expr.id, expr.span);

View File

@ -71,16 +71,16 @@ pub use self::deref_kind::*;
use self::Aliasability::*;
use middle::def_id::DefId;
use front::map as ast_map;
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};
use rustc_front::hir::{MutImmutable, MutMutable, PatKind};
use rustc_front::hir;
use hir::{MutImmutable, MutMutable, PatKind};
use hir;
use syntax::ast;
use syntax::codemap::Span;

View File

@ -16,9 +16,9 @@
// reachable as well.
use dep_graph::DepNode;
use front::map as ast_map;
use middle::def::Def;
use middle::def_id::DefId;
use hir::map as ast_map;
use hir::def::Def;
use hir::def_id::DefId;
use ty::{self, TyCtxt};
use middle::privacy;
use session::config;
@ -28,9 +28,9 @@ use std::collections::HashSet;
use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
use rustc_front::hir;
use rustc_front::intravisit::Visitor;
use rustc_front::intravisit;
use hir;
use hir::intravisit::Visitor;
use hir::intravisit;
// Returns true if the given set of generics implies that the item it's
// associated with must be inlined.

View File

@ -17,7 +17,7 @@
//! `middle/infer/region_inference/README.md`
use dep_graph::DepNode;
use front::map as ast_map;
use hir::map as ast_map;
use session::Session;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
use middle::cstore::InlinedItem;
@ -30,10 +30,9 @@ use std::mem;
use syntax::codemap::{self, Span};
use syntax::ast::{self, NodeId};
use rustc_front::hir;
use rustc_front::intravisit::{self, Visitor, FnKind};
use rustc_front::hir::{Block, Item, FnDecl, Arm, Pat, PatKind, Stmt, Expr, Local};
use rustc_front::util::stmt_id;
use hir;
use hir::intravisit::{self, Visitor, FnKind};
use hir::{Block, Item, FnDecl, Arm, Pat, PatKind, Stmt, Expr, Local};
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
RustcDecodable, Copy)]
@ -765,7 +764,7 @@ fn resolve_pat(visitor: &mut RegionResolutionVisitor, pat: &hir::Pat) {
}
fn resolve_stmt(visitor: &mut RegionResolutionVisitor, stmt: &hir::Stmt) {
let stmt_id = stmt_id(stmt);
let stmt_id = stmt.node.id();
debug!("resolve_stmt(stmt.id={:?})", stmt_id);
// Every statement will clean up the temporaries created during

View File

@ -19,9 +19,9 @@ pub use self::DefRegion::*;
use self::ScopeChain::*;
use dep_graph::DepNode;
use front::map::Map;
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;
@ -32,9 +32,9 @@ use syntax::codemap::Span;
use syntax::parse::token::special_idents;
use util::nodemap::NodeMap;
use rustc_front::hir;
use rustc_front::print::pprust::lifetime_to_string;
use rustc_front::intravisit::{self, Visitor, FnKind};
use hir;
use hir::print::lifetime_to_string;
use hir::intravisit::{self, Visitor, FnKind};
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
pub enum DefRegion {

View File

@ -14,12 +14,12 @@
pub use self::StabilityLevel::*;
use dep_graph::DepNode;
use front::map as hir_map;
use hir::map as hir_map;
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;
@ -30,9 +30,9 @@ use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods};
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
use rustc_front::hir;
use rustc_front::hir::{Item, Generics, StructField, Variant, PatKind};
use rustc_front::intravisit::{self, Visitor};
use hir;
use hir::{Item, Generics, StructField, Variant, PatKind};
use hir::intravisit::{self, Visitor};
use std::mem::replace;
use std::cmp::Ordering;

View File

@ -18,9 +18,9 @@ use middle::lang_items;
use syntax::ast;
use syntax::codemap::Span;
use syntax::parse::token::InternedString;
use rustc_front::intravisit::Visitor;
use rustc_front::intravisit;
use rustc_front::hir;
use hir::intravisit::Visitor;
use hir::intravisit;
use hir;
use std::collections::HashSet;

View File

@ -11,12 +11,12 @@
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;
use rustc_back::slice;
use rustc_front::hir::InlineAsm;
use hir::InlineAsm;
use std::ascii;
use std::borrow::{Cow};
use std::fmt::{self, Debug, Formatter, Write};

View File

@ -17,7 +17,7 @@ use mir::repr::*;
use ty::subst::{Subst, Substs};
use ty::{self, AdtDef, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_front::hir;
use hir;
#[derive(Copy, Clone, Debug)]
pub enum LvalueTy<'tcx> {

View 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::*;

View 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};

View File

@ -24,7 +24,7 @@ use super::{
};
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;

View File

@ -15,7 +15,7 @@ pub use self::FulfillmentErrorCode::*;
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};

View 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};

View File

@ -23,7 +23,7 @@ use super::VtableClosureData;
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};

View File

@ -36,7 +36,7 @@ use super::{VtableImplData, VtableObjectData, VtableBuiltinData,
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};
@ -49,7 +49,7 @@ use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use syntax::abi::Abi;
use rustc_front::hir;
use hir;
use util::common::ErrorReported;
use util::nodemap::FnvHashMap;

View File

@ -21,7 +21,7 @@ use super::{SelectionContext, FulfillmentContext};
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};

View File

@ -14,7 +14,7 @@ use std::rc::Rc;
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};

View 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};

View File

@ -17,7 +17,7 @@ use ty::LvaluePreference::{NoPreference};
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir;
use hir;
#[derive(Copy, Clone)]
pub enum AutoAdjustment<'tcx> {

View 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;

View File

@ -11,13 +11,13 @@
//! type context book-keeping
use dep_graph::{DepGraph, DepTrackingMap};
use front::map as ast_map;
use hir::map as ast_map;
use session::Session;
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;
@ -27,7 +27,7 @@ use traits;
use ty::{self, TraitRef, Ty, TypeAndMut};
use ty::{TyS, TypeVariants};
use ty::{AdtDef, ClosureSubsts, ExistentialBounds, Region};
use ty::{FreevarMap};
use hir::FreevarMap;
use ty::{BareFnTy, InferTy, ParamTy, ProjectionTy, TraitTy};
use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid};
use ty::TypeVariants::*;
@ -45,7 +45,7 @@ use syntax::ast::{self, Name, NodeId};
use syntax::attr;
use syntax::parse::token::{self, special_idents};
use rustc_front::hir;
use hir;
/// Internal storage
pub struct CtxtArenas<'tcx> {

View 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};
@ -19,7 +19,7 @@ use syntax::ast::{self, Name};
use syntax::codemap::Span;
use syntax::errors::DiagnosticBuilder;
use rustc_front::hir;
use hir;
#[derive(Clone, Copy, Debug)]
pub struct ExpectedFound<T> {

View 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;

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use front::map::DefPathData;
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;
@ -24,6 +24,11 @@ impl<'tcx> TyCtxt<'tcx> {
buffer.into_string()
}
/// Returns a string identifying this local node-id.
pub fn node_path_str(&self, id: ast::NodeId) -> String {
self.item_path_str(self.map.local_def_id(id))
}
/// Returns a string identifying this def-id. This string is
/// suitable for user output. It always begins with a crate identifier.
pub fn absolute_item_path_str(&self, def_id: DefId) -> String {

View 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;

View File

@ -19,12 +19,11 @@ pub use self::LvaluePreference::*;
pub use self::fold::TypeFoldable;
use dep_graph::{self, DepNode};
use front::map as ast_map;
use front::map::LinkedPath;
use hir::map as ast_map;
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;
@ -33,7 +32,7 @@ use ty::fold::TypeFolder;
use ty::subst::{Subst, Substs, VecPerParamSpace};
use ty::walk::TypeWalker;
use util::common::MemoizationMap;
use util::nodemap::{NodeMap, NodeSet};
use util::nodemap::NodeSet;
use util::nodemap::FnvHashMap;
use serialize::{Encodable, Encoder, Decodable, Decoder};
@ -44,7 +43,6 @@ use std::iter;
use std::rc::Rc;
use std::slice;
use std::vec::IntoIter;
use std::collections::{HashMap, HashSet};
use syntax::ast::{self, CrateNum, Name, NodeId};
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::{DUMMY_SP, Span};
@ -52,9 +50,9 @@ use syntax::parse::token::InternedString;
use rustc_const_math::ConstInt;
use rustc_front::hir;
use rustc_front::hir::{ItemImpl, ItemTrait, PatKind};
use rustc_front::intravisit::Visitor;
use hir;
use hir::{ItemImpl, ItemTrait, PatKind};
use hir::intravisit::Visitor;
pub use self::sty::{Binder, DebruijnIndex};
pub use self::sty::{BuiltinBound, BuiltinBounds, ExistentialBounds};
@ -115,7 +113,7 @@ pub struct CrateAnalysis<'a> {
pub access_levels: middle::privacy::AccessLevels,
pub reachable: NodeSet,
pub name: &'a str,
pub glob_map: Option<GlobMap>,
pub glob_map: Option<hir::GlobMap>,
}
#[derive(Copy, Clone)]
@ -2232,39 +2230,9 @@ impl<'tcx> TyCtxt<'tcx> {
}
}
pub fn with_path<T, F>(&self, id: DefId, f: F) -> T where
F: FnOnce(ast_map::PathElems) -> T,
{
if let Some(id) = self.map.as_local_node_id(id) {
self.map.with_path(id, f)
} else {
let mut path: Vec<_>;
if let Some(extern_crate) = self.sess.cstore.extern_crate(id.krate) {
if !extern_crate.direct {
// this comes from some crate that we don't have a direct
// path to; we'll settle for just prepending the name of
// the crate.
path = self.sess.cstore.extern_item_path(id)
} else {
// start with the path to the extern crate, then
// add the relative path to the actual item
fn collector(elems: ast_map::PathElems) -> Vec<ast_map::PathElem> {
elems.collect()
}
path = self.with_path(extern_crate.def_id, collector);
path.extend(self.sess.cstore.relative_item_path(id));
}
} else {
// if this was injected, just make a path with name of crate
path = self.sess.cstore.extern_item_path(id);
}
f(path.iter().cloned().chain(LinkedPath::empty()))
}
}
pub fn item_name(&self, id: DefId) -> ast::Name {
if let Some(id) = self.map.as_local_node_id(id) {
self.map.get_path_elem(id).name()
self.map.name(id)
} else {
self.sess.cstore.item_name(id)
}
@ -2724,30 +2692,9 @@ pub enum ExplicitSelfCategory {
ByBox,
}
/// A free variable referred to in a function.
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct Freevar {
/// The variable being accessed free.
pub def: Def,
// First span where it is accessed (there can be multiple).
pub span: Span
}
pub type FreevarMap = NodeMap<Vec<Freevar>>;
pub type CaptureModeMap = NodeMap<hir::CaptureClause>;
// Trait method resolution
pub type TraitMap = NodeMap<Vec<DefId>>;
// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = HashMap<NodeId, HashSet<Name>>;
impl<'tcx> TyCtxt<'tcx> {
pub fn with_freevars<T, F>(&self, fid: NodeId, f: F) -> T where
F: FnOnce(&[Freevar]) -> T,
F: FnOnce(&[hir::Freevar]) -> T,
{
match self.freevars.borrow().get(&fid) {
None => f(&[]),

View File

@ -13,13 +13,13 @@
//! 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};
use std::rc::Rc;
use syntax::abi;
use rustc_front::hir as ast;
use hir as ast;
pub type RelateResult<'tcx, T> = Result<T, TypeError<'tcx>>;

View File

@ -17,7 +17,7 @@ use std::rc::Rc;
use syntax::abi;
use syntax::ptr::P;
use rustc_front::hir;
use hir;
///////////////////////////////////////////////////////////////////////////
// Lift implementations

View 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;
@ -28,7 +28,7 @@ use syntax::parse::token::special_idents;
use serialize::{Decodable, Decoder};
use rustc_front::hir;
use hir;
use self::FnOutput::*;
use self::InferTy::*;

View 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};

View 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;
@ -17,7 +17,7 @@ use ty::{Ty, TyCtxt, TraitRef};
use std::borrow::{Borrow};
use std::cell::{Cell, Ref, RefCell};
use syntax::ast::Name;
use rustc_front::hir;
use hir;
use util::nodemap::FnvHashMap;
/// As `TypeScheme` but for a trait ref.

View File

@ -10,11 +10,11 @@
//! misc. type-system utilities too small to deserve their own file
use back::svh::Svh;
use middle::def_id::DefId;
use hir::svh::Svh;
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};
@ -28,7 +28,7 @@ use syntax::ast::{self, Name};
use syntax::attr::{self, AttrMetaMethods, SignedInt, UnsignedInt};
use syntax::codemap::Span;
use rustc_front::hir;
use hir;
pub trait IntTypeExt {
fn to_ty<'tcx>(&self, cx: &TyCtxt<'tcx>) -> Ty<'tcx>;

View 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;

View File

@ -19,9 +19,9 @@ use std::iter::repeat;
use std::path::Path;
use std::time::Instant;
use rustc_front::hir;
use rustc_front::intravisit;
use rustc_front::intravisit::Visitor;
use hir;
use hir::intravisit;
use hir::intravisit::Visitor;
// The name of the associated type for `Fn` return types
pub const FN_OUTPUT_NAME: &'static str = "Output";

View 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;

View 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};
@ -23,7 +23,7 @@ use std::fmt;
use syntax::abi::Abi;
use syntax::parse::token;
use syntax::ast::CRATE_NODE_ID;
use rustc_front::hir;
use hir;
pub fn verbose() -> bool {
ty::tls::with(|tcx| tcx.sess.verbose())

View File

@ -11,7 +11,6 @@ crate-type = ["dylib"]
[dependencies]
syntax = { path = "../libsyntax" }
serialize = { path = "../libserialize" }
rustc_front = { path = "../librustc_front" }
log = { path = "../liblog" }
[features]

View File

@ -45,13 +45,11 @@
extern crate syntax;
extern crate libc;
extern crate serialize;
extern crate rustc_front;
#[macro_use] extern crate log;
pub mod tempdir;
pub mod rpath;
pub mod sha2;
pub mod svh;
pub mod target;
pub mod slice;
pub mod dynamic_lib;

View File

@ -13,5 +13,4 @@ log = { path = "../liblog" }
syntax = { path = "../libsyntax" }
graphviz = { path = "../libgraphviz" }
rustc = { path = "../librustc" }
rustc_front = { path = "../librustc_front" }
rustc_mir = { path = "../librustc_mir" }

View File

@ -30,7 +30,7 @@ use rustc::ty::{self, TyCtxt};
use rustc::traits::ProjectionMode;
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir;
use rustc::hir;
use std::rc::Rc;

View File

@ -20,7 +20,7 @@ use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend};
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;

View File

@ -23,7 +23,7 @@ use rustc::ty;
use std::rc::Rc;
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir::{self, PatKind};
use rustc::hir::{self, PatKind};
struct GatherMoveInfo<'tcx> {
id: ast::NodeId,

View File

@ -29,10 +29,10 @@ use rustc::traits::ProjectionMode;
use syntax::ast;
use syntax::codemap::Span;
use syntax::ast::NodeId;
use rustc_front::hir;
use rustc_front::hir::Expr;
use rustc_front::intravisit;
use rustc_front::intravisit::Visitor;
use rustc::hir;
use rustc::hir::Expr;
use rustc::hir::intravisit;
use rustc::hir::intravisit::Visitor;
use self::restrictions::RestrictionResult;

View File

@ -16,7 +16,7 @@ use rustc::ty;
use syntax::ast;
use syntax::codemap;
use syntax::errors::DiagnosticBuilder;
use rustc_front::hir;
use rustc::hir;
pub struct MoveErrorCollector<'tcx> {
errors: Vec<MoveError<'tcx>>

View File

@ -13,8 +13,8 @@ use borrowck::BorrowckCtxt;
use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir;
use rustc_front::intravisit::{FnKind};
use rustc::hir;
use rustc::hir::intravisit::{FnKind};
use rustc::mir::repr::{BasicBlock, BasicBlockData, Mir, Statement, Terminator};

View File

@ -21,14 +21,14 @@ pub use self::MovedValueUseKind::*;
use self::InteriorKind::*;
use rustc::dep_graph::DepNode;
use rustc::front::map as hir_map;
use rustc::front::map::blocks::FnParts;
use rustc::hir::map as hir_map;
use rustc::hir::map::blocks::FnParts;
use rustc::cfg;
use rustc::middle::dataflow::DataFlowContext;
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;
@ -44,11 +44,10 @@ use syntax::attr::AttrMetaMethods;
use syntax::codemap::Span;
use syntax::errors::DiagnosticBuilder;
use rustc_front::hir;
use rustc_front::hir::{FnDecl, Block};
use rustc_front::intravisit;
use rustc_front::intravisit::{Visitor, FnKind};
use rustc_front::util as hir_util;
use rustc::hir;
use rustc::hir::{FnDecl, Block};
use rustc::hir::intravisit;
use rustc::hir::intravisit::{Visitor, FnKind};
use rustc::mir::mir_map::MirMap;
@ -210,7 +209,7 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
{
// Check the body of fn items.
let tcx = this.tcx;
let id_range = hir_util::compute_id_range_for_fn_body(fk, decl, body, sp, id);
let id_range = intravisit::compute_id_range_for_fn_body(fk, decl, body, sp, id);
let (all_loans, move_data) =
gather_loans::gather_loans_in_fn(this, id, decl, body);

View File

@ -28,9 +28,9 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::usize;
use syntax::ast;
use syntax::ast_util;
use syntax::codemap::Span;
use rustc_front::hir;
use rustc::hir;
use rustc::hir::intravisit::IdRange;
#[path="fragments.rs"]
pub mod fragments;
@ -602,7 +602,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
pub fn new(move_data: MoveData<'tcx>,
tcx: &'a TyCtxt<'tcx>,
cfg: &cfg::CFG,
id_range: ast_util::IdRange,
id_range: IdRange,
decl: &hir::FnDecl,
body: &hir::Block)
-> FlowedMoveData<'a, 'tcx> {

View File

@ -34,7 +34,6 @@
extern crate graphviz as dot;
#[macro_use]
extern crate rustc;
extern crate rustc_front;
extern crate rustc_mir;
extern crate core; // for NonZero

View File

@ -12,7 +12,6 @@ crate-type = ["dylib"]
log = { path = "../liblog" }
serialize = { path = "../libserialize" }
rustc = { path = "../librustc" }
rustc_front = { path = "../librustc_front" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
syntax = { path = "../libsyntax" }

View File

@ -17,14 +17,14 @@ use rustc::middle::const_val::ConstVal;
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;
@ -32,17 +32,15 @@ use std::cmp::Ordering;
use std::fmt;
use std::iter::{FromIterator, IntoIterator, repeat};
use rustc_front::hir;
use rustc_front::hir::{Pat, PatKind};
use rustc_front::intravisit::{self, Visitor, FnKind};
use rustc_front::util as front_util;
use rustc::hir;
use rustc::hir::{Pat, PatKind};
use rustc::hir::intravisit::{self, IdVisitor, IdVisitingOperation, Visitor, FnKind};
use rustc_back::slice;
use syntax::ast::{self, DUMMY_NODE_ID, NodeId};
use syntax::ast_util;
use syntax::codemap::{Span, Spanned, DUMMY_SP};
use rustc_front::fold::{Folder, noop_fold_pat};
use rustc_front::print::pprust::pat_to_string;
use rustc::hir::fold::{Folder, noop_fold_pat};
use rustc::hir::print::pat_to_string;
use syntax::ptr::P;
use rustc::util::nodemap::FnvHashMap;
@ -241,7 +239,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
}
fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) {
front_util::walk_pat(pat, |p| {
pat.walk(|p| {
match p.node {
PatKind::Ident(hir::BindByValue(hir::MutImmutable), ident, None) => {
let pat_ty = cx.tcx.pat_ty(p);
@ -274,7 +272,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
// Check that we do not match against a static NaN (#6804)
fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) {
front_util::walk_pat(pat, |p| {
pat.walk(|p| {
if let PatKind::Lit(ref expr) = p.node {
match eval_const_expr_partial(cx.tcx, &expr, ExprTypeChecked, None) {
Ok(ConstVal::Float(f)) if f.is_nan() => {
@ -461,7 +459,7 @@ struct RenamingRecorder<'map> {
renaming_map: &'map mut FnvHashMap<(NodeId, Span), NodeId>
}
impl<'map> ast_util::IdVisitingOperation for RenamingRecorder<'map> {
impl<'map> IdVisitingOperation for RenamingRecorder<'map> {
fn visit_id(&mut self, node_id: NodeId) {
let key = (node_id, self.origin_span);
self.renaming_map.insert(key, self.substituted_node_id);
@ -518,7 +516,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
renaming_map: renaming_map,
};
let mut id_visitor = front_util::IdVisitor::new(&mut renaming_recorder);
let mut id_visitor = IdVisitor::new(&mut renaming_recorder);
id_visitor.visit_expr(const_expr);
}
@ -1100,7 +1098,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
};
for pat in pats {
front_util::walk_pat(&pat, |p| {
pat.walk(|p| {
if pat_is_binding(&def_map.borrow(), &p) {
match p.node {
PatKind::Ident(hir::BindByValue(_), _, ref sub) => {

View File

@ -15,13 +15,13 @@ use rustc::middle::const_val::ConstVal;
use self::ErrKind::*;
use self::EvalHint::*;
use rustc::front::map as ast_map;
use rustc::front::map::blocks::FnLikeNode;
use rustc::hir::map as ast_map;
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;
@ -31,9 +31,9 @@ use rustc::lint;
use graphviz::IntoCow;
use syntax::ast;
use rustc_front::hir::{Expr, PatKind};
use rustc_front::hir;
use rustc_front::intravisit::FnKind;
use rustc::hir::{Expr, PatKind};
use rustc::hir;
use rustc::hir::intravisit::FnKind;
use syntax::codemap::Span;
use syntax::ptr::P;
use syntax::codemap;

View File

@ -33,7 +33,6 @@
#[macro_use] extern crate syntax;
#[macro_use] extern crate log;
#[macro_use] extern crate rustc;
extern crate rustc_front;
extern crate rustc_back;
extern crate rustc_const_math;
extern crate graphviz;

View File

@ -17,7 +17,6 @@ rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_borrowck = { path = "../librustc_borrowck" }
rustc_const_eval = { path = "../librustc_const_eval" }
rustc_front = { path = "../librustc_front" }
rustc_lint = { path = "../librustc_lint" }
rustc_llvm = { path = "../librustc_llvm" }
rustc_mir = { path = "../librustc_mir" }

View File

@ -9,8 +9,8 @@
// except according to those terms.
use rustc::dep_graph::DepGraph;
use rustc::front;
use rustc::front::map as hir_map;
use rustc::hir;
use rustc::hir::map as hir_map;
use rustc_mir as mir;
use rustc::mir::mir_map::MirMap;
use rustc::session::{Session, CompileResult, compile_result_from_err_count};
@ -35,8 +35,7 @@ use rustc_typeck as typeck;
use rustc_privacy;
use rustc_plugin::registry::Registry;
use rustc_plugin as plugin;
use rustc_front::hir;
use rustc_front::lowering::{lower_crate, LoweringContext};
use rustc::hir::lowering::{lower_crate, LoweringContext};
use rustc_passes::{no_asm, loops, consts, const_fn, rvalues, static_recursion};
use rustc_const_eval::check_match;
use super::Compilation;
@ -155,7 +154,7 @@ pub fn compile_input(sess: &Session,
}
time(sess.time_passes(), "attribute checking", || {
front::check_attr::check_crate(sess, &expanded_crate);
hir::check_attr::check_crate(sess, &expanded_crate);
});
time(sess.time_passes(),

View File

@ -42,7 +42,6 @@ extern crate rustc_back;
extern crate rustc_borrowck;
extern crate rustc_const_eval;
extern crate rustc_passes;
extern crate rustc_front;
extern crate rustc_lint;
extern crate rustc_plugin;
extern crate rustc_privacy;

View File

@ -50,11 +50,11 @@ use std::option;
use std::path::PathBuf;
use std::str::FromStr;
use rustc::front::map as hir_map;
use rustc::front::map::{blocks, NodePrinter};
use rustc_front::hir;
use rustc_front::lowering::{lower_crate, LoweringContext};
use rustc_front::print::pprust as pprust_hir;
use rustc::hir::map as hir_map;
use rustc::hir::map::{blocks, NodePrinter};
use rustc::hir;
use rustc::hir::lowering::{lower_crate, LoweringContext};
use rustc::hir::print as pprust_hir;
use rustc::mir::mir_map::MirMap;
@ -256,6 +256,15 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
/// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.)
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn;
/// Computes an user-readable representation of a path, if possible.
fn node_path(&self, id: ast::NodeId) -> Option<String> {
self.ast_map().and_then(|map| map.def_path_from_id(id)).map(|path| {
path.data.into_iter().map(|elem| {
elem.data.to_string()
}).collect::<Vec<_>>().join("::")
})
}
}
struct NoAnn<'ast> {
@ -452,6 +461,10 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn {
self
}
fn node_path(&self, id: ast::NodeId) -> Option<String> {
Some(self.tcx.node_path_str(id))
}
}
impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
@ -794,7 +807,7 @@ pub fn pretty_print_input(sess: Session,
|annotation, (out,uii), _| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
let ast_map = annotation.ast_map().expect("--pretty missing ast_map");
let ast_map = annotation.ast_map().expect("--unpretty missing HIR map");
let mut pp_state =
pprust_hir::State::new_from_input(sess.codemap(),
sess.diagnostic(),
@ -808,7 +821,9 @@ pub fn pretty_print_input(sess: Session,
let node = ast_map.get(node_id);
pp_state.print_node(&node)?;
pp::space(&mut pp_state.s)?;
pp_state.synth_comment(ast_map.path_to_string(node_id))?;
let path = annotation.node_path(node_id)
.expect("--unpretty missing node paths");
pp_state.synth_comment(path)?;
pp::hardbreak(&mut pp_state.s)?;
}
pp::eof(&mut pp_state.s)

View File

@ -27,7 +27,7 @@ use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::ty::relate::TypeRelation;
use rustc::infer::{self, InferOk, InferResult, TypeOrigin};
use rustc_metadata::cstore::CStore;
use rustc::front::map as hir_map;
use rustc::hir::map as hir_map;
use rustc::session::{self, config};
use std::rc::Rc;
use syntax::ast;
@ -39,8 +39,8 @@ use syntax::errors::{Level, RenderSpan};
use syntax::parse::token;
use syntax::feature_gate::UnstableFeatures;
use rustc_front::lowering::{lower_crate, LoweringContext};
use rustc_front::hir;
use rustc::hir::lowering::{lower_crate, LoweringContext};
use rustc::hir;
struct Env<'a, 'tcx: 'a> {
infcx: &'a infer::InferCtxt<'a, 'tcx>,

View File

@ -1,15 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc_front"
version = "0.0.0"
[lib]
name = "rustc_front"
path = "lib.rs"
crate-type = ["dylib"]
[dependencies]
log = { path = "../liblog" }
syntax = { path = "../libsyntax" }
serialize = { path = "../libserialize" }
rustc_bitflags = { path = "../librustc_bitflags" }

View File

@ -1,58 +0,0 @@
// Copyright 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.
//! The Rust compiler.
//!
//! # Note
//!
//! This API is completely unstable and subject to change.
#![crate_name = "rustc_front"]
#![unstable(feature = "rustc_private", issue = "27812")]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(str_char)]
#![feature(question_mark)]
extern crate serialize;
#[macro_use]
extern crate log;
#[macro_use]
extern crate syntax;
#[macro_use]
#[no_link]
extern crate rustc_bitflags;
extern crate serialize as rustc_serialize; // used by deriving
#[macro_use]
pub mod hir;
pub mod lowering;
pub mod fold;
pub mod intravisit;
pub mod util;
pub mod print {
pub mod pprust;
}

View File

@ -1,362 +0,0 @@
// Copyright 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 hir;
use hir::*;
use intravisit::{self, Visitor, FnKind};
use syntax::ast_util;
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID};
use syntax::codemap::Span;
use syntax::ptr::P;
pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool
where F: FnMut(&Pat) -> bool
{
// FIXME(#19596) this is a workaround, but there should be a better way
fn walk_pat_<G>(pat: &Pat, it: &mut G) -> bool
where G: FnMut(&Pat) -> bool
{
if !it(pat) {
return false;
}
match pat.node {
PatKind::Ident(_, _, Some(ref p)) => walk_pat_(&p, it),
PatKind::Struct(_, ref fields, _) => {
fields.iter().all(|field| walk_pat_(&field.node.pat, it))
}
PatKind::TupleStruct(_, Some(ref s)) | PatKind::Tup(ref s) => {
s.iter().all(|p| walk_pat_(&p, it))
}
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
walk_pat_(&s, it)
}
PatKind::Vec(ref before, ref slice, ref after) => {
before.iter().all(|p| walk_pat_(&p, it)) &&
slice.iter().all(|p| walk_pat_(&p, it)) &&
after.iter().all(|p| walk_pat_(&p, it))
}
PatKind::Wild |
PatKind::Lit(_) |
PatKind::Range(_, _) |
PatKind::Ident(_, _, _) |
PatKind::TupleStruct(..) |
PatKind::Path(..) |
PatKind::QPath(_, _) => {
true
}
}
}
walk_pat_(pat, &mut it)
}
pub fn binop_to_string(op: BinOp_) -> &'static str {
match op {
BiAdd => "+",
BiSub => "-",
BiMul => "*",
BiDiv => "/",
BiRem => "%",
BiAnd => "&&",
BiOr => "||",
BiBitXor => "^",
BiBitAnd => "&",
BiBitOr => "|",
BiShl => "<<",
BiShr => ">>",
BiEq => "==",
BiLt => "<",
BiLe => "<=",
BiNe => "!=",
BiGe => ">=",
BiGt => ">",
}
}
pub fn stmt_id(s: &Stmt) -> NodeId {
match s.node {
StmtDecl(_, id) => id,
StmtExpr(_, id) => id,
StmtSemi(_, id) => id,
}
}
pub fn lazy_binop(b: BinOp_) -> bool {
match b {
BiAnd => true,
BiOr => true,
_ => false,
}
}
pub fn is_shift_binop(b: BinOp_) -> bool {
match b {
BiShl => true,
BiShr => true,
_ => false,
}
}
pub fn is_comparison_binop(b: BinOp_) -> bool {
match b {
BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true,
BiAnd |
BiOr |
BiAdd |
BiSub |
BiMul |
BiDiv |
BiRem |
BiBitXor |
BiBitAnd |
BiBitOr |
BiShl |
BiShr => false,
}
}
/// Returns `true` if the binary operator takes its arguments by value
pub fn is_by_value_binop(b: BinOp_) -> bool {
!is_comparison_binop(b)
}
/// Returns `true` if the unary operator takes its argument by value
pub fn is_by_value_unop(u: UnOp) -> bool {
match u {
UnNeg | UnNot => true,
_ => false,
}
}
pub fn unop_to_string(op: UnOp) -> &'static str {
match op {
UnDeref => "*",
UnNot => "!",
UnNeg => "-",
}
}
pub struct IdVisitor<'a, O: 'a> {
operation: &'a mut O,
// In general, the id visitor visits the contents of an item, but
// not including nested trait/impl items, nor other nested items.
// The base visitor itself always skips nested items, but not
// trait/impl items. This means in particular that if you start by
// visiting a trait or an impl, you should not visit the
// trait/impl items respectively. This is handled by setting
// `skip_members` to true when `visit_item` is on the stack. This
// way, if the user begins by calling `visit_trait_item`, we will
// visit the trait item, but if they begin with `visit_item`, we
// won't visit the (nested) trait items.
skip_members: bool,
}
impl<'a, O: ast_util::IdVisitingOperation> IdVisitor<'a, O> {
pub fn new(operation: &'a mut O) -> IdVisitor<'a, O> {
IdVisitor { operation: operation, skip_members: false }
}
fn visit_generics_helper(&mut self, generics: &Generics) {
for type_parameter in generics.ty_params.iter() {
self.operation.visit_id(type_parameter.id)
}
for lifetime in &generics.lifetimes {
self.operation.visit_id(lifetime.lifetime.id)
}
}
}
impl<'a, 'v, O: ast_util::IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
fn visit_mod(&mut self, module: &Mod, _: Span, node_id: NodeId) {
self.operation.visit_id(node_id);
intravisit::walk_mod(self, module)
}
fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
self.operation.visit_id(foreign_item.id);
intravisit::walk_foreign_item(self, foreign_item)
}
fn visit_item(&mut self, item: &Item) {
assert!(!self.skip_members);
self.skip_members = true;
self.operation.visit_id(item.id);
match item.node {
ItemUse(ref view_path) => {
match view_path.node {
ViewPathSimple(_, _) |
ViewPathGlob(_) => {}
ViewPathList(_, ref paths) => {
for path in paths {
self.operation.visit_id(path.node.id())
}
}
}
}
_ => {}
}
intravisit::walk_item(self, item);
self.skip_members = false;
}
fn visit_local(&mut self, local: &Local) {
self.operation.visit_id(local.id);
intravisit::walk_local(self, local)
}
fn visit_block(&mut self, block: &Block) {
self.operation.visit_id(block.id);
intravisit::walk_block(self, block)
}
fn visit_stmt(&mut self, statement: &Stmt) {
self.operation.visit_id(stmt_id(statement));
intravisit::walk_stmt(self, statement)
}
fn visit_pat(&mut self, pattern: &Pat) {
self.operation.visit_id(pattern.id);
intravisit::walk_pat(self, pattern)
}
fn visit_expr(&mut self, expression: &Expr) {
self.operation.visit_id(expression.id);
intravisit::walk_expr(self, expression)
}
fn visit_ty(&mut self, typ: &Ty) {
self.operation.visit_id(typ.id);
intravisit::walk_ty(self, typ)
}
fn visit_generics(&mut self, generics: &Generics) {
self.visit_generics_helper(generics);
intravisit::walk_generics(self, generics)
}
fn visit_fn(&mut self,
function_kind: FnKind<'v>,
function_declaration: &'v FnDecl,
block: &'v Block,
span: Span,
node_id: NodeId) {
self.operation.visit_id(node_id);
match function_kind {
FnKind::ItemFn(_, generics, _, _, _, _, _) => {
self.visit_generics_helper(generics)
}
FnKind::Method(_, sig, _, _) => {
self.visit_generics_helper(&sig.generics)
}
FnKind::Closure(_) => {}
}
for argument in &function_declaration.inputs {
self.operation.visit_id(argument.id)
}
intravisit::walk_fn(self, function_kind, function_declaration, block, span);
}
fn visit_struct_field(&mut self, struct_field: &StructField) {
self.operation.visit_id(struct_field.id);
intravisit::walk_struct_field(self, struct_field)
}
fn visit_variant_data(&mut self,
struct_def: &VariantData,
_: Name,
_: &hir::Generics,
_: NodeId,
_: Span) {
self.operation.visit_id(struct_def.id());
intravisit::walk_struct_def(self, struct_def);
}
fn visit_trait_item(&mut self, ti: &hir::TraitItem) {
if !self.skip_members {
self.operation.visit_id(ti.id);
intravisit::walk_trait_item(self, ti);
}
}
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
if !self.skip_members {
self.operation.visit_id(ii.id);
intravisit::walk_impl_item(self, ii);
}
}
fn visit_lifetime(&mut self, lifetime: &Lifetime) {
self.operation.visit_id(lifetime.id);
}
fn visit_lifetime_def(&mut self, def: &LifetimeDef) {
self.visit_lifetime(&def.lifetime);
}
fn visit_trait_ref(&mut self, trait_ref: &TraitRef) {
self.operation.visit_id(trait_ref.ref_id);
intravisit::walk_trait_ref(self, trait_ref);
}
}
/// Computes the id range for a single fn body, ignoring nested items.
pub fn compute_id_range_for_fn_body(fk: FnKind,
decl: &FnDecl,
body: &Block,
sp: Span,
id: NodeId)
-> ast_util::IdRange {
let mut visitor = ast_util::IdRangeComputingVisitor { result: ast_util::IdRange::max() };
let mut id_visitor = IdVisitor::new(&mut visitor);
id_visitor.visit_fn(fk, decl, body, sp, id);
id_visitor.operation.result
}
pub fn is_path(e: P<Expr>) -> bool {
match e.node {
ExprPath(..) => true,
_ => false,
}
}
pub fn empty_generics() -> Generics {
Generics {
lifetimes: HirVec::new(),
ty_params: HirVec::new(),
where_clause: WhereClause {
id: DUMMY_NODE_ID,
predicates: HirVec::new(),
},
}
}
// convert a span and an identifier to the corresponding
// 1-segment path
pub fn ident_to_path(s: Span, ident: Ident) -> Path {
hir::Path {
span: s,
global: false,
segments: hir_vec![hir::PathSegment {
identifier: ident,
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
lifetimes: HirVec::new(),
types: HirVec::new(),
bindings: HirVec::new(),
}),
}],
}
}

View File

@ -13,5 +13,4 @@ log = { path = "../liblog" }
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_eval = { path = "../librustc_const_eval" }
rustc_front = { path = "../librustc_front" }
syntax = { path = "../libsyntax" }

View 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};
@ -17,8 +17,8 @@ use syntax::ast;
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::Span;
use rustc_front::hir::{self, PatKind};
use rustc_front::intravisit::FnKind;
use rustc::hir::{self, PatKind};
use rustc::hir::intravisit::FnKind;
#[derive(PartialEq)]
pub enum MethodLateContext {

View File

@ -28,16 +28,16 @@
//! 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;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::adjustment;
use rustc::traits::{self, ProjectionMode};
use rustc::front::map as hir_map;
use rustc::hir::map as hir_map;
use util::nodemap::{NodeSet};
use lint::{Level, LateContext, LintContext, LintArray, Lint};
use lint::{LintPass, LateLintPass};
@ -48,8 +48,8 @@ use syntax::{ast};
use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::{self, Span};
use rustc_front::hir::{self, PatKind};
use rustc_front::intravisit::FnKind;
use rustc::hir::{self, PatKind};
use rustc::hir::intravisit::FnKind;
use bad_style::{MethodLateContext, method_context};
@ -1087,10 +1087,7 @@ impl LateLintPass for MutableTransmutes {
ty::TyFnDef(_, _, ref bfty) if bfty.abi == RustIntrinsic => (),
_ => return false
}
cx.tcx.with_path(def_id, |path| match path.last() {
Some(ref last) => last.name().as_str() == "transmute",
_ => false
})
cx.tcx.item_name(def_id).as_str() == "transmute"
}
}
}

Some files were not shown because too many files have changed in this diff Show More