From 8b0937293bdb70ab4a5efed02b90a71af2b234f6 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 29 Mar 2016 08:50:44 +0300 Subject: [PATCH 1/8] rustc: move rustc_front to rustc::hir. --- mk/crates.mk | 31 +++++----- src/librustc/Cargo.toml | 1 - src/librustc/cfg/construct.rs | 4 +- src/librustc/cfg/graphviz.rs | 2 +- src/librustc/cfg/mod.rs | 2 +- src/librustc/dep_graph/mod.rs | 4 +- src/librustc/{front => hir}/check_attr.rs | 0 src/{librustc_front => librustc/hir}/fold.rs | 0 .../hir}/intravisit.rs | 0 .../hir}/lowering.rs | 0 src/librustc/{front => hir}/map/blocks.rs | 8 +-- src/librustc/{front => hir}/map/collector.rs | 5 +- .../{front => hir}/map/definitions.rs | 0 src/librustc/{front => hir}/map/mod.rs | 7 +-- .../hir.rs => librustc/hir/mod.rs} | 33 ++++++----- .../print/pprust.rs => librustc/hir/print.rs} | 8 +-- src/{librustc_back => librustc/hir}/svh.rs | 12 ++-- src/{librustc_front => librustc/hir}/util.rs | 2 +- src/librustc/infer/error_reporting.rs | 6 +- src/librustc/infer/mod.rs | 2 +- src/librustc/lib.rs | 14 +---- src/librustc/lint/context.rs | 6 +- src/librustc/lint/mod.rs | 4 +- src/librustc/middle/astconv_util.rs | 2 +- src/librustc/middle/cstore.rs | 10 ++-- src/librustc/middle/dataflow.rs | 6 +- src/librustc/middle/dead.rs | 6 +- src/librustc/middle/def.rs | 2 +- src/librustc/middle/effect.rs | 6 +- src/librustc/middle/entry.rs | 6 +- src/librustc/middle/expr_use_visitor.rs | 8 +-- src/librustc/middle/intrinsicck.rs | 4 +- src/librustc/middle/lang_items.rs | 6 +- src/librustc/middle/liveness.rs | 12 ++-- src/librustc/middle/mem_categorization.rs | 6 +- src/librustc/middle/pat_util.rs | 4 +- src/librustc/middle/reachable.rs | 8 +-- src/librustc/middle/region.rs | 10 ++-- src/librustc/middle/resolve_lifetime.rs | 8 +-- src/librustc/middle/stability.rs | 8 +-- src/librustc/middle/weak_lang_items.rs | 6 +- src/librustc/mir/repr.rs | 2 +- src/librustc/mir/tcx.rs | 2 +- src/librustc/traits/select.rs | 2 +- src/librustc/ty/adjustment.rs | 2 +- src/librustc/ty/context.rs | 4 +- src/librustc/ty/error.rs | 2 +- src/librustc/ty/item_path.rs | 2 +- src/librustc/ty/mod.rs | 10 ++-- src/librustc/ty/relate.rs | 2 +- src/librustc/ty/structural_impls.rs | 2 +- src/librustc/ty/sty.rs | 2 +- src/librustc/ty/trait_def.rs | 2 +- src/librustc/ty/util.rs | 4 +- src/librustc/util/common.rs | 6 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_back/Cargo.toml | 1 - src/librustc_back/lib.rs | 2 - src/librustc_borrowck/Cargo.toml | 1 - src/librustc_borrowck/borrowck/check_loans.rs | 2 +- .../borrowck/gather_loans/gather_moves.rs | 2 +- .../borrowck/gather_loans/mod.rs | 8 +-- .../borrowck/gather_loans/move_error.rs | 2 +- src/librustc_borrowck/borrowck/mir/mod.rs | 4 +- src/librustc_borrowck/borrowck/mod.rs | 14 ++--- src/librustc_borrowck/borrowck/move_data.rs | 2 +- src/librustc_borrowck/lib.rs | 1 - src/librustc_const_eval/Cargo.toml | 1 - src/librustc_const_eval/check_match.rs | 12 ++-- src/librustc_const_eval/eval.rs | 10 ++-- src/librustc_const_eval/lib.rs | 1 - src/librustc_driver/Cargo.toml | 1 - src/librustc_driver/driver.rs | 9 ++- src/librustc_driver/lib.rs | 1 - src/librustc_driver/pretty.rs | 10 ++-- src/librustc_driver/test.rs | 6 +- src/librustc_front/Cargo.toml | 15 ----- src/librustc_front/lib.rs | 58 ------------------- src/librustc_lint/Cargo.toml | 1 - src/librustc_lint/bad_style.rs | 4 +- src/librustc_lint/builtin.rs | 6 +- src/librustc_lint/lib.rs | 1 - src/librustc_lint/types.rs | 4 +- src/librustc_lint/unused.rs | 4 +- src/librustc_metadata/Cargo.toml | 1 - src/librustc_metadata/astencode.rs | 14 ++--- src/librustc_metadata/creader.rs | 8 +-- src/librustc_metadata/csearch.rs | 8 +-- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/decoder.rs | 6 +- src/librustc_metadata/encoder.rs | 12 ++-- src/librustc_metadata/lib.rs | 1 - src/librustc_metadata/loader.rs | 2 +- src/librustc_metadata/tydecode.rs | 2 +- src/librustc_metadata/tyencode.rs | 2 +- src/librustc_mir/Cargo.toml | 1 - src/librustc_mir/build/block.rs | 2 +- src/librustc_mir/build/mod.rs | 2 +- src/librustc_mir/hair/cx/block.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 6 +- src/librustc_mir/hair/cx/mod.rs | 2 +- src/librustc_mir/hair/cx/pattern.rs | 2 +- src/librustc_mir/hair/cx/to_ref.rs | 2 +- src/librustc_mir/hair/mod.rs | 2 +- src/librustc_mir/lib.rs | 1 - src/librustc_mir/mir_map.rs | 5 +- src/librustc_passes/Cargo.toml | 1 - src/librustc_passes/consts.rs | 4 +- src/librustc_passes/lib.rs | 1 - src/librustc_passes/loops.rs | 6 +- src/librustc_passes/rvalues.rs | 4 +- src/librustc_passes/static_recursion.rs | 6 +- src/librustc_plugin/Cargo.toml | 1 - src/librustc_plugin/build.rs | 6 +- src/librustc_plugin/lib.rs | 1 - src/librustc_privacy/Cargo.toml | 1 - src/librustc_privacy/lib.rs | 7 +-- src/librustc_resolve/Cargo.toml | 1 - src/librustc_resolve/build_reduced_graph.rs | 18 +++--- src/librustc_resolve/check_unused.rs | 6 +- src/librustc_resolve/lib.rs | 39 ++++++------- src/librustc_save_analysis/Cargo.toml | 1 - src/librustc_save_analysis/dump_visitor.rs | 2 +- src/librustc_save_analysis/lib.rs | 7 +-- src/librustc_trans/Cargo.toml | 1 - src/librustc_trans/_match.rs | 4 +- src/librustc_trans/abi.rs | 2 +- src/librustc_trans/asm.rs | 2 +- src/librustc_trans/assert_dep_graph.rs | 4 +- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/back/symbol_names.rs | 2 +- src/librustc_trans/base.rs | 9 ++- src/librustc_trans/callee.rs | 4 +- src/librustc_trans/closure.rs | 2 +- src/librustc_trans/collector.rs | 6 +- src/librustc_trans/common.rs | 2 +- src/librustc_trans/consts.rs | 4 +- src/librustc_trans/controlflow.rs | 4 +- .../debuginfo/create_scope_map.rs | 5 +- src/librustc_trans/debuginfo/metadata.rs | 4 +- src/librustc_trans/debuginfo/mod.rs | 7 +-- src/librustc_trans/debuginfo/namespace.rs | 2 +- src/librustc_trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/expr.rs | 7 +-- src/librustc_trans/inline.rs | 2 +- src/librustc_trans/intrinsic.rs | 2 +- src/librustc_trans/lib.rs | 3 +- src/librustc_trans/mir/rvalue.rs | 2 +- src/librustc_trans/monomorphize.rs | 4 +- src/librustc_trans/symbol_names_test.rs | 4 +- src/librustc_trans/tvec.rs | 2 +- src/librustc_typeck/Cargo.toml | 1 - src/librustc_typeck/astconv.rs | 4 +- src/librustc_typeck/check/_match.rs | 6 +- src/librustc_typeck/check/callee.rs | 2 +- src/librustc_typeck/check/cast.rs | 2 +- src/librustc_typeck/check/closure.rs | 2 +- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/demand.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 10 ++-- src/librustc_typeck/check/mod.rs | 10 ++-- src/librustc_typeck/check/op.rs | 4 +- src/librustc_typeck/check/regionck.rs | 6 +- src/librustc_typeck/check/upvar.rs | 4 +- src/librustc_typeck/check/wfcheck.rs | 4 +- src/librustc_typeck/check/writeback.rs | 8 +-- src/librustc_typeck/coherence/mod.rs | 8 +-- src/librustc_typeck/coherence/orphan.rs | 4 +- src/librustc_typeck/coherence/overlap.rs | 4 +- src/librustc_typeck/coherence/unsafety.rs | 4 +- src/librustc_typeck/collect.rs | 8 +-- src/librustc_typeck/lib.rs | 6 +- src/librustc_typeck/variance/constraints.rs | 6 +- src/librustc_typeck/variance/terms.rs | 4 +- src/librustdoc/Cargo.toml | 1 - src/librustdoc/clean/inline.rs | 4 +- src/librustdoc/clean/mod.rs | 12 ++-- src/librustdoc/core.rs | 4 +- src/librustdoc/doctree.rs | 2 +- src/librustdoc/html/format.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/lib.rs | 1 - src/librustdoc/passes.rs | 2 +- src/librustdoc/test.rs | 6 +- src/librustdoc/visit_ast.rs | 4 +- src/rustc/Cargo.lock | 24 -------- src/test/auxiliary/dummy_mir_pass.rs | 1 - src/test/auxiliary/lint_for_crate.rs | 3 +- src/test/auxiliary/lint_group_plugin_test.rs | 4 +- src/test/run-make/execution-engine/test.rs | 5 +- 194 files changed, 419 insertions(+), 566 deletions(-) rename src/librustc/{front => hir}/check_attr.rs (100%) rename src/{librustc_front => librustc/hir}/fold.rs (100%) rename src/{librustc_front => librustc/hir}/intravisit.rs (100%) rename src/{librustc_front => librustc/hir}/lowering.rs (100%) rename src/librustc/{front => hir}/map/blocks.rs (98%) rename src/librustc/{front => hir}/map/collector.rs (99%) rename src/librustc/{front => hir}/map/definitions.rs (100%) rename src/librustc/{front => hir}/map/mod.rs (99%) rename src/{librustc_front/hir.rs => librustc/hir/mod.rs} (98%) rename src/{librustc_front/print/pprust.rs => librustc/hir/print.rs} (99%) rename src/{librustc_back => librustc/hir}/svh.rs (98%) rename src/{librustc_front => librustc/hir}/util.rs (99%) delete mode 100644 src/librustc_front/Cargo.toml delete mode 100644 src/librustc_front/lib.rs diff --git a/mk/crates.mk b/mk/crates.mk index 8c80335e772bb..4c06afcae0c42 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -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 diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index e7aaaef45a1c0..d77268219fcec 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -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" } diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index cd1e3b5f30e9c..4fc0a0926133e 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -16,7 +16,7 @@ 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 hir::util::lazy_binop(op.node) => { // // [pred] // | diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index c867ec94b2510..c651baae28224 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -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); diff --git a/src/librustc/cfg/mod.rs b/src/librustc/cfg/mod.rs index 8df4dc5fce596..e86bf6ebc589a 100644 --- a/src/librustc/cfg/mod.rs +++ b/src/librustc/cfg/mod.rs @@ -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; diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index 731c33868dfbf..70e7f675fcea9 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -12,8 +12,8 @@ use self::thread::{DepGraphThreadData, DepMessage}; use middle::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; diff --git a/src/librustc/front/check_attr.rs b/src/librustc/hir/check_attr.rs similarity index 100% rename from src/librustc/front/check_attr.rs rename to src/librustc/hir/check_attr.rs diff --git a/src/librustc_front/fold.rs b/src/librustc/hir/fold.rs similarity index 100% rename from src/librustc_front/fold.rs rename to src/librustc/hir/fold.rs diff --git a/src/librustc_front/intravisit.rs b/src/librustc/hir/intravisit.rs similarity index 100% rename from src/librustc_front/intravisit.rs rename to src/librustc/hir/intravisit.rs diff --git a/src/librustc_front/lowering.rs b/src/librustc/hir/lowering.rs similarity index 100% rename from src/librustc_front/lowering.rs rename to src/librustc/hir/lowering.rs diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/hir/map/blocks.rs similarity index 98% rename from src/librustc/front/map/blocks.rs rename to src/librustc/hir/map/blocks.rs index 2eb3d56bb5e4e..7b1c692d54b5e 100644 --- a/src/librustc/front/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -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). diff --git a/src/librustc/front/map/collector.rs b/src/librustc/hir/map/collector.rs similarity index 99% rename from src/librustc/front/map/collector.rs rename to src/librustc/hir/map/collector.rs index 4ae03b1b9d722..7036822217256 100644 --- a/src/librustc/front/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -11,9 +11,8 @@ use super::*; use super::MapEntry::*; -use rustc_front::hir::*; -use rustc_front::util; -use rustc_front::intravisit::{self, Visitor}; +use hir::*; +use hir::intravisit::Visitor; use middle::def_id::{CRATE_DEF_INDEX, DefId, DefIndex}; use std::iter::repeat; use syntax::ast::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID}; diff --git a/src/librustc/front/map/definitions.rs b/src/librustc/hir/map/definitions.rs similarity index 100% rename from src/librustc/front/map/definitions.rs rename to src/librustc/hir/map/definitions.rs diff --git a/src/librustc/front/map/mod.rs b/src/librustc/hir/map/mod.rs similarity index 99% rename from src/librustc/front/map/mod.rs rename to src/librustc/hir/map/mod.rs index 817bec5840797..4325be9b9a43b 100644 --- a/src/librustc/front/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -27,10 +27,9 @@ 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; diff --git a/src/librustc_front/hir.rs b/src/librustc/hir/mod.rs similarity index 98% rename from src/librustc_front/hir.rs rename to src/librustc/hir/mod.rs index 86f8635f58d9a..eaf59af2cc359 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc/hir/mod.rs @@ -33,8 +33,6 @@ pub use self::ViewPath_::*; pub use self::Visibility::*; pub use self::PathParameters::*; -use intravisit::Visitor; -use std::collections::BTreeMap; 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 +41,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}; @@ -66,6 +62,15 @@ macro_rules! hir_vec { ($($x:expr,)*) => (vec![$($x),*]) } +pub mod check_attr; +pub mod fold; +pub mod intravisit; +pub mod lowering; +pub mod map; +pub mod print; +pub mod svh; +pub mod util; + /// Identifier in HIR #[derive(Clone, Copy, Eq)] pub struct Ident { @@ -135,7 +140,7 @@ impl fmt::Debug for Lifetime { write!(f, "lifetime({}: {})", self.id, - pprust::lifetime_to_string(self)) + print::lifetime_to_string(self)) } } @@ -161,13 +166,13 @@ 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)) } } @@ -434,7 +439,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 +486,7 @@ 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)) } } @@ -619,7 +626,7 @@ impl fmt::Debug for Stmt_ { write!(f, "stmt({}: {})", util::stmt_id(&spanned), - pprust::stmt_to_string(&spanned)) + print::stmt_to_string(&spanned)) } } @@ -722,7 +729,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 +947,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)) } } diff --git a/src/librustc_front/print/pprust.rs b/src/librustc/hir/print.rs similarity index 99% rename from src/librustc_front/print/pprust.rs rename to src/librustc/hir/print.rs index 3b8e6763de011..568986f39c527 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc/hir/print.rs @@ -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::util::empty_generics(); 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(hir::util::binop_to_string(op.node))?; 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, hir::util::unop_to_string(op))?; 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, hir::util::binop_to_string(op.node))?; self.word_space("=")?; self.print_expr(&rhs)?; } diff --git a/src/librustc_back/svh.rs b/src/librustc/hir/svh.rs similarity index 98% rename from src/librustc_back/svh.rs rename to src/librustc/hir/svh.rs index ec607314f45c0..7ae20f68ad0c2 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc/hir/svh.rs @@ -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}; diff --git a/src/librustc_front/util.rs b/src/librustc/hir/util.rs similarity index 99% rename from src/librustc_front/util.rs rename to src/librustc/hir/util.rs index f4f9cb75eaf36..7745c320e7681 100644 --- a/src/librustc_front/util.rs +++ b/src/librustc/hir/util.rs @@ -10,7 +10,7 @@ use hir; use hir::*; -use intravisit::{self, Visitor, FnKind}; +use hir::intravisit::{Visitor, FnKind}; use syntax::ast_util; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID}; use syntax::codemap::Span; diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 8079a6d1bbcaf..c0c63ac5042fb 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -73,9 +73,9 @@ 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; diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index e22fb98890438..427ff88b8f24b 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -19,7 +19,7 @@ pub use self::freshen::TypeFreshener; pub use self::region_inference::{GenericKind, VerifyBound}; use middle::def_id::DefId; -use rustc_front::hir; +use hir; use middle::free_region::FreeRegionMap; use middle::mem_categorization as mc; use middle::mem_categorization::McResult; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 03a08231c7433..291eab30decbf 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -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; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index e78ff513ac473..8324435276926 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -46,9 +46,9 @@ 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::util; +use hir::intravisit as hir_visit; use syntax::visit as ast_visit; /// Information about the registered lints. diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 133d0163a8c9b..28994e1a7c48d 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -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, diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index b86d74545cb8e..871440a7e54ff 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -18,7 +18,7 @@ use middle::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 { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 4efb40abdb0a3..59a3ab44645d9 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -22,8 +22,8 @@ // 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 hir::svh::Svh; +use hir::map as hir_map; use middle::def::{self, Def}; use middle::lang_items; use ty::{self, Ty, TyCtxt, VariantKind}; @@ -44,9 +44,9 @@ 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::Visitor; +use hir::util::IdVisitor; pub use self::DefLike::{DlDef, DlField, DlImpl}; pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown}; diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 6468187e219bf..99b512141a493 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -25,9 +25,9 @@ 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; +use hir::print as pprust; #[derive(Copy, Clone, Debug)] diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 18bea745858a3..b7b6279270cb4 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -13,9 +13,9 @@ // 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, PatKind}; +use hir::intravisit::{self, Visitor}; use middle::{pat_util, privacy}; use ty::{self, TyCtxt}; diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index e6ea000936cab..ee6e747a85554 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -12,7 +12,7 @@ use middle::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 { diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index fa949073f4e2b..e4c93dfdb9319 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -19,9 +19,9 @@ 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 { diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 67e96816abf96..4a64980fcdd5a 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -10,15 +10,15 @@ use dep_graph::DepNode; -use front::map as ast_map; +use hir::map as ast_map; use middle::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, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index bfc96005bc8a4..47ec7ab5ff05a 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -26,7 +26,7 @@ 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 hir::util::is_by_value_unop(op) { 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 hir::util::is_by_value_binop(op.node) { 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!(hir::util::is_by_value_binop(op.node)); if !self.walk_overloaded_operator(expr, lhs, vec![rhs], PassArgs::ByValue) { self.mutate_expr(expr, &lhs, MutateMode::WriteAndRead); diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index fd74ccac97596..354a6c5e13bca 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -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 { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index bb0b8ed91df86..7aad106c4ed44 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -22,7 +22,7 @@ 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; @@ -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. diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 4451e7ac472e5..8d429ff238420 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -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 hir::util::lazy_binop(op.node) => { 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 hir::util::lazy_binop(op.node) => { let r_succ = self.propagate_through_expr(&r, succ); let ln = self.live_node(expr.id, expr.span); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index ef031ad13f16c..7260bdde3ee71 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -72,15 +72,15 @@ pub use self::deref_kind::*; use self::Aliasability::*; use middle::def_id::DefId; -use front::map as ast_map; +use hir::map as ast_map; use infer; use middle::const_qualif::ConstQualif; use middle::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; diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index b2b1344c4bb75..3cd69603b5bfd 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -14,8 +14,8 @@ 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 hir::util::walk_pat; use syntax::codemap::{respan, Span, Spanned, DUMMY_SP}; use std::cell::RefCell; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 149e895717c00..8c44594c1f783 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -16,7 +16,7 @@ // reachable as well. use dep_graph::DepNode; -use front::map as ast_map; +use hir::map as ast_map; use middle::def::Def; use middle::def_id::DefId; use ty::{self, TyCtxt}; @@ -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. diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2cde6ce93208f..99ebf5ccb845c 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -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,10 @@ 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}; +use hir::util::stmt_id; #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable, RustcDecodable, Copy)] diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index d3757629d30de..1275753a3406b 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -19,7 +19,7 @@ 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 middle::region; @@ -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 { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index e589743222b72..ffb4a791363c4 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -14,7 +14,7 @@ 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}; @@ -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; diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 6059d7ee74e39..74bb41785cbe1 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -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; diff --git a/src/librustc/mir/repr.rs b/src/librustc/mir/repr.rs index a33ee6bd204eb..1b24b4f6210bb 100644 --- a/src/librustc/mir/repr.rs +++ b/src/librustc/mir/repr.rs @@ -16,7 +16,7 @@ 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}; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index ecac5d2f73f63..d710417bf20d8 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -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> { diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index f68386feddb59..97c9caadd5237 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -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; diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 90ccdeea92890..41008823c8512 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -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> { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2074339f2e629..fa5a7f3ca692d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -11,7 +11,7 @@ //! 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; @@ -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> { diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 9ab4850582853..e6b7b49ea573c 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -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 { diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index caf7e6fe62938..0648450d8331b 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -8,7 +8,7 @@ // 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 ty::{self, Ty, TyCtxt}; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index edfad09ae1fa1..69a6a6aa920f3 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -19,8 +19,8 @@ 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 hir::map::LinkedPath; use middle; use middle::cstore::{self, CrateStore, LOCAL_CRATE}; use middle::def::{self, Def, ExportMap}; @@ -52,9 +52,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}; diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index b39cb5ef939e5..b1bff9b43ccce 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -19,7 +19,7 @@ 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>; diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 82cc9e7f2e3db..bbf6d0329b4ee 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -17,7 +17,7 @@ use std::rc::Rc; use syntax::abi; use syntax::ptr::P; -use rustc_front::hir; +use hir; /////////////////////////////////////////////////////////////////////////// // Lift implementations diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index fee0aaff44593..101c8501bd3dd 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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::*; diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 3ebf2ba4c849f..0eb70f93bed30 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -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. diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 6e8363f629b69..710cd2e301c09 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -10,7 +10,7 @@ //! misc. type-system utilities too small to deserve their own file -use back::svh::Svh; +use hir::svh::Svh; use middle::def_id::DefId; use ty::subst; use infer; @@ -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>; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 888a623b24a83..bdfb97549d5d5 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -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"; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 20f16a1d255c7..c386a670ba256 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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()) diff --git a/src/librustc_back/Cargo.toml b/src/librustc_back/Cargo.toml index 2cf6cbc4bcfa1..85e861b405a9f 100644 --- a/src/librustc_back/Cargo.toml +++ b/src/librustc_back/Cargo.toml @@ -11,7 +11,6 @@ crate-type = ["dylib"] [dependencies] syntax = { path = "../libsyntax" } serialize = { path = "../libserialize" } -rustc_front = { path = "../librustc_front" } log = { path = "../liblog" } [features] diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index 80dec2cd28153..25edaf4b8e4e9 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -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; diff --git a/src/librustc_borrowck/Cargo.toml b/src/librustc_borrowck/Cargo.toml index fdb97bd8d2d18..6da87f97fb79f 100644 --- a/src/librustc_borrowck/Cargo.toml +++ b/src/librustc_borrowck/Cargo.toml @@ -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" } diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index aa2b7ed2cdeea..d79ba213aca14 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -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; diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 489c8be4e3862..c85d69fa8a60d 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -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, diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index c759722c24b9a..893c27f0ede32 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -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; diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index f5e3bc4f6fb3a..3d94f5b186f0f 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -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> diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index d1335811858b8..672faea58f501 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -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}; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 1dfa4da46aa99..fec327f4aa030 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -21,8 +21,8 @@ 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; @@ -44,11 +44,11 @@ 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::hir::util as hir_util; use rustc::mir::mir_map::MirMap; diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index b31f74c64760c..292cfcfeac19c 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -30,7 +30,7 @@ use std::usize; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; -use rustc_front::hir; +use rustc::hir; #[path="fragments.rs"] pub mod fragments; diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 6f21fcd9230cd..e38677de6625f 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -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 diff --git a/src/librustc_const_eval/Cargo.toml b/src/librustc_const_eval/Cargo.toml index f38c60cd1fae3..c572284a6bb37 100644 --- a/src/librustc_const_eval/Cargo.toml +++ b/src/librustc_const_eval/Cargo.toml @@ -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" } diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index a46d72840b728..70781184f74a4 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -32,17 +32,17 @@ 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, Visitor, FnKind}; +use rustc::hir::util as front_util; 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; diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 5a00b4573decf..dba31ddef95dd 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -15,8 +15,8 @@ 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; @@ -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; diff --git a/src/librustc_const_eval/lib.rs b/src/librustc_const_eval/lib.rs index b74fc121e391d..085888dc21f64 100644 --- a/src/librustc_const_eval/lib.rs +++ b/src/librustc_const_eval/lib.rs @@ -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; diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 0d2ae14d7d174..bac5900f3edaf 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -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" } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 4255d4fc8b011..f661b2a38b655 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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(), diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3444b770cc8b1..b4b53d30e3c04 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -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; diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 31345cfdc41ab..cda5595c1024e 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -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; diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index ce0d42203b987..fc12d546288b4 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -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>, diff --git a/src/librustc_front/Cargo.toml b/src/librustc_front/Cargo.toml deleted file mode 100644 index bf40cdbd330e1..0000000000000 --- a/src/librustc_front/Cargo.toml +++ /dev/null @@ -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" } diff --git a/src/librustc_front/lib.rs b/src/librustc_front/lib.rs deleted file mode 100644 index b9e3b71cf1ad7..0000000000000 --- a/src/librustc_front/lib.rs +++ /dev/null @@ -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 or the MIT license -// , 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; -} diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 4821a72327978..3f0cd397e769c 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -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" } diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index ca189d0b51961..ed9c66a188275 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -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 { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 339c969b01fcd..6f11ebafa86ec 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -37,7 +37,7 @@ 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}; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 0780e4cd04834..2075bd5edcaeb 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -44,7 +44,6 @@ extern crate syntax; extern crate rustc; #[macro_use] extern crate log; -extern crate rustc_front; extern crate rustc_back; extern crate rustc_const_eval; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 6eeadc77698a0..b094bca84103e 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -29,8 +29,8 @@ use syntax::abi::Abi; use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{self, Span}; -use rustc_front::hir; -use rustc_front::util::is_shift_binop; +use rustc::hir; +use rustc::hir::util::is_shift_binop; register_long_diagnostics! { E0519: r##" diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 9840cd4256fcf..f531628601b0f 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -24,8 +24,8 @@ use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType}; use syntax::ptr::P; use rustc_back::slice; -use rustc_front::hir; -use rustc_front::intravisit::FnKind; +use rustc::hir; +use rustc::hir::intravisit::FnKind; declare_lint! { pub UNUSED_MUT, diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 65c2c2d1480a8..697cbe39c67fc 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -16,7 +16,6 @@ rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_bitflags = { path = "../librustc_bitflags" } rustc_const_math = { path = "../librustc_const_math" } -rustc_front = { path = "../librustc_front" } rustc_llvm = { path = "../librustc_llvm" } serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 505619d31d735..98e73f2902b74 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -12,12 +12,12 @@ // FIXME: remove this after snapshot, and Results are handled #![allow(unused_must_use)] -use rustc::front::map as ast_map; +use rustc::hir::map as ast_map; use rustc::session::Session; -use rustc_front::hir; -use rustc_front::fold; -use rustc_front::fold::Folder; +use rustc::hir; +use rustc::hir::fold; +use rustc::hir::fold::Folder; use common as c; use cstore; @@ -55,8 +55,8 @@ use serialize::EncoderHelpers; #[cfg(test)] use std::io::Cursor; #[cfg(test)] use syntax::parse; #[cfg(test)] use syntax::ast::NodeId; -#[cfg(test)] use rustc_front::print::pprust; -#[cfg(test)] use rustc_front::lowering::{lower_item, LoweringContext}; +#[cfg(test)] use rustc::hir::print as pprust; +#[cfg(test)] use rustc::hir::lowering::{lower_item, LoweringContext}; struct DecodeContext<'a, 'b, 'tcx: 'a> { tcx: &'a TyCtxt<'tcx>, @@ -168,7 +168,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, copy_item_types(dcx, ii, orig_did); if let InlinedItem::Item(ref i) = *ii { debug!(">>> DECODED ITEM >>>\n{}\n<<< DECODED ITEM <<<", - ::rustc_front::print::pprust::item_to_string(&i)); + ::rustc::hir::print::item_to_string(&i)); } ii diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index edabf43a15074..df9072835b9e8 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -17,13 +17,13 @@ use cstore::{self, CStore, CrateSource, MetadataBlob}; use decoder; use loader::{self, CratePaths}; -use rustc::back::svh::Svh; +use rustc::hir::svh::Svh; use rustc::dep_graph::DepNode; use rustc::session::{config, Session}; use rustc::session::search_paths::PathKind; use rustc::middle::cstore::{CrateStore, validate_crate_name, ExternCrate}; use rustc::util::nodemap::FnvHashMap; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use std::cell::{RefCell, Cell}; use std::path::PathBuf; @@ -37,8 +37,8 @@ use syntax::parse; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; -use rustc_front::intravisit::Visitor; -use rustc_front::hir; +use rustc::hir::intravisit::Visitor; +use rustc::hir; use log; pub struct LocalCrateReader<'a, 'b:'a> { diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index c11d9865516b9..c9e661dec510e 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -20,7 +20,7 @@ use middle::lang_items; use rustc::ty::{self, Ty, TyCtxt, VariantKind}; use middle::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::mir::repr::Mir; use rustc::mir::mir_map::MirMap; use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap}; @@ -31,9 +31,9 @@ use std::path::PathBuf; use syntax::ast; use syntax::attr; use syntax::parse::token; -use rustc_back::svh::Svh; +use rustc::hir::svh::Svh; use rustc_back::target::Target; -use rustc_front::hir; +use rustc::hir; impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn stability(&self, def: DefId) -> Option @@ -552,7 +552,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let mut visible_parent_map = self.visible_parent_map.borrow_mut(); if !visible_parent_map.is_empty() { return visible_parent_map; } - use rustc_front::hir; + use rustc::hir; use rustc::middle::cstore::{CrateStore, ChildItem}; use std::collections::vec_deque::VecDeque; use std::collections::hash_map::Entry; diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 5637301724bbc..3a6cd4d832b9a 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -20,7 +20,7 @@ use decoder; use index; use loader; -use rustc::back::svh::Svh; +use rustc::hir::svh::Svh; use rustc::middle::cstore::{ExternCrate}; use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap}; use rustc::middle::def_id::DefId; diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index e85fdb05ca890..5aafd015f9a1c 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -22,10 +22,10 @@ use index; use tls_context; use tydecode::TyDecoder; -use rustc::back::svh::Svh; -use rustc::front::map as hir_map; +use rustc::hir::svh::Svh; +use rustc::hir::map as hir_map; use rustc::util::nodemap::FnvHashMap; -use rustc_front::hir; +use rustc::hir; use middle::cstore::{LOCAL_CRATE, FoundAst, InlinedItem, LinkagePreference}; use middle::cstore::{DefLike, DlDef, DlField, DlImpl, tls}; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 30eabb7e8f396..dc21ebcbcfcbd 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -30,9 +30,9 @@ use rustc::traits::specialization_graph; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::util::IntTypeExt; -use rustc::back::svh::Svh; -use rustc::front::map::{LinkedPath, PathElem, PathElems}; -use rustc::front::map as ast_map; +use rustc::hir::svh::Svh; +use rustc::hir::map::{LinkedPath, PathElem, PathElems}; +use rustc::hir::map as ast_map; use rustc::mir::mir_map::MirMap; use rustc::session::config; use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet}; @@ -52,9 +52,9 @@ use syntax::errors::Handler; use syntax; use rbml::writer::Encoder; -use rustc_front::hir::{self, PatKind}; -use rustc_front::intravisit::Visitor; -use rustc_front::intravisit; +use rustc::hir::{self, PatKind}; +use rustc::hir::intravisit::Visitor; +use rustc::hir::intravisit; pub struct EncodeContext<'a, 'tcx: 'a> { pub diag: &'a Handler, diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index c927f53eccd6f..139462d41bf1f 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -36,7 +36,6 @@ extern crate serialize; #[macro_use] extern crate rustc; extern crate rustc_back; -extern crate rustc_front; extern crate rustc_llvm; extern crate rustc_const_math; diff --git a/src/librustc_metadata/loader.rs b/src/librustc_metadata/loader.rs index 87e86e221f18e..c7cd8ae2dd7f3 100644 --- a/src/librustc_metadata/loader.rs +++ b/src/librustc_metadata/loader.rs @@ -216,7 +216,7 @@ use cstore::{MetadataBlob, MetadataVec, MetadataArchive}; use decoder; use encoder; -use rustc::back::svh::Svh; +use rustc::hir::svh::Svh; use rustc::session::Session; use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch}; use rustc::session::search_paths::PathKind; diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index 28985c75a912d..cd63b58372b32 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -16,7 +16,7 @@ #![allow(non_camel_case_types)] -use rustc_front::hir; +use rustc::hir; use middle::def_id::{DefId, DefIndex}; use middle::region; diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index ffaf7e2d465db..b5079256487de 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -25,7 +25,7 @@ use rustc::ty::ParamTy; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FnvHashMap; -use rustc_front::hir; +use rustc::hir; use syntax::abi::Abi; use syntax::ast; diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index f136618b1c9e2..1c41ca6f416e1 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -16,5 +16,4 @@ rustc_back = { path = "../librustc_back" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_const_math = { path = "../librustc_const_math" } rustc_data_structures = { path = "../librustc_data_structures" } -rustc_front = { path = "../librustc_front" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index ef48a408e79a7..8c98408e2390a 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -11,7 +11,7 @@ use build::{BlockAnd, BlockAndExtension, Builder}; use hair::*; use rustc::mir::repr::*; -use rustc_front::hir; +use rustc::hir; impl<'a,'tcx> Builder<'a,'tcx> { pub fn ast_block(&mut self, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 51069c3885704..2e5b6a952b72d 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -13,7 +13,7 @@ use rustc::middle::region::{CodeExtent, CodeExtentData}; use rustc::ty::{FnOutput, Ty}; use rustc::mir::repr::*; use rustc_data_structures::fnv::FnvHashMap; -use rustc_front::hir; +use rustc::hir; use std::ops::{Index, IndexMut}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index c7af42b776f0c..f0ed25902f715 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -12,7 +12,7 @@ use hair::*; use hair::cx::Cx; use hair::cx::to_ref::ToRef; use rustc::middle::region::{BlockRemainder, CodeExtentData}; -use rustc_front::hir; +use rustc::hir; use syntax::ast; impl<'tcx> Mirror<'tcx> for &'tcx hir::Block { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 7e16883e7542c..475ae459fefd5 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -14,7 +14,7 @@ use rustc_const_math::ConstInt; use hair::cx::Cx; use hair::cx::block; use hair::cx::to_ref::ToRef; -use rustc::front::map; +use rustc::hir::map; use rustc::middle::def::Def; use rustc::middle::const_val::ConstVal; use rustc_const_eval as const_eval; @@ -22,8 +22,8 @@ use rustc::middle::region::CodeExtent; use rustc::middle::pat_util; use rustc::ty::{self, VariantDef, Ty}; use rustc::mir::repr::*; -use rustc_front::hir; -use rustc_front::util as hir_util; +use rustc::hir; +use rustc::hir::util as hir_util; use syntax::ptr::P; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 05448a7deab36..f0c6887802d63 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -25,7 +25,7 @@ use rustc::infer::InferCtxt; use rustc::ty::subst::{Subst, Substs}; use rustc::ty::{self, Ty, TyCtxt}; use syntax::parse::token; -use rustc_front::hir; +use rustc::hir; use rustc_const_math::{ConstInt, ConstUsize}; #[derive(Copy, Clone)] diff --git a/src/librustc_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index 8ec8cd4bf814c..673d12c33167a 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -16,7 +16,7 @@ use rustc::middle::def::Def; use rustc::middle::pat_util::{pat_is_resolved_const, pat_is_binding}; use rustc::ty::{self, Ty}; use rustc::mir::repr::*; -use rustc_front::hir::{self, PatKind}; +use rustc::hir::{self, PatKind}; use syntax::ast; use syntax::codemap::Span; use syntax::ptr::P; diff --git a/src/librustc_mir/hair/cx/to_ref.rs b/src/librustc_mir/hair/cx/to_ref.rs index 24fcc2f4fcd56..63dbde474380a 100644 --- a/src/librustc_mir/hair/cx/to_ref.rs +++ b/src/librustc_mir/hair/cx/to_ref.rs @@ -10,7 +10,7 @@ use hair::*; -use rustc_front::hir; +use rustc::hir; use syntax::ptr::P; pub trait ToRef { diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index affc187298715..0ea8dece47c7b 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -21,7 +21,7 @@ use rustc::middle::def_id::DefId; use rustc::middle::region::CodeExtent; use rustc::ty::subst::Substs; use rustc::ty::{self, AdtDef, ClosureSubsts, Region, Ty}; -use rustc_front::hir; +use rustc::hir; use syntax::ast; use syntax::codemap::Span; use self::cx::Cx; diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index dd81895ebeccb..ced73f34e0d92 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -30,7 +30,6 @@ extern crate graphviz as dot; #[macro_use] extern crate rustc; extern crate rustc_data_structures; -extern crate rustc_front; extern crate rustc_back; extern crate syntax; extern crate rustc_const_math; diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 9ec88c1b59a69..40334f652eed3 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -17,7 +17,6 @@ //! - `#[rustc_mir(pretty="file.mir")]` extern crate syntax; -extern crate rustc_front; use build; use rustc::dep_graph::DepNode; @@ -31,8 +30,8 @@ use rustc::traits::ProjectionMode; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::common::ErrorReported; use rustc::util::nodemap::NodeMap; -use rustc_front::hir; -use rustc_front::intravisit::{self, Visitor}; +use rustc::hir; +use rustc::hir::intravisit::{self, Visitor}; use syntax::abi::Abi; use syntax::ast; use syntax::attr::AttrMetaMethods; diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 02303aa7130ea..fa6bd3dfb67dd 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -12,5 +12,4 @@ crate-type = ["dylib"] log = { path = "../liblog" } rustc = { path = "../librustc" } rustc_const_eval = { path = "../librustc_const_eval" } -rustc_front = { path = "../librustc_front" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index ba5d8ef45b621..38784191a7828 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -42,11 +42,11 @@ use rustc::util::nodemap::NodeMap; use rustc::middle::const_qualif::ConstQualif; use rustc::lint::builtin::CONST_ERR; -use rustc_front::hir::{self, PatKind}; +use rustc::hir::{self, PatKind}; use syntax::ast; use syntax::codemap::Span; use syntax::feature_gate::UnstableFeatures; -use rustc_front::intravisit::{self, FnKind, Visitor}; +use rustc::hir::intravisit::{self, FnKind, Visitor}; use std::collections::hash_map::Entry; use std::cmp::Ordering; diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 44bcdcdb36495..53ae1b30f7c17 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -29,7 +29,6 @@ extern crate core; #[macro_use] extern crate rustc; -extern crate rustc_front; extern crate rustc_const_eval; #[macro_use] extern crate log; diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index a89627aea82fb..9a58a704c52cc 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -12,9 +12,9 @@ use self::Context::*; use rustc::session::Session; use rustc::dep_graph::DepNode; -use rustc::front::map::Map; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir; +use rustc::hir::map::Map; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir; use syntax::codemap::Span; #[derive(Clone, Copy, PartialEq)] diff --git a/src/librustc_passes/rvalues.rs b/src/librustc_passes/rvalues.rs index 98502f5a16e78..754d5ef8f528d 100644 --- a/src/librustc_passes/rvalues.rs +++ b/src/librustc_passes/rvalues.rs @@ -18,8 +18,8 @@ use rustc::middle::mem_categorization as mc; use rustc::ty::{self, TyCtxt, ParameterEnvironment}; use rustc::traits::ProjectionMode; -use rustc_front::hir; -use rustc_front::intravisit; +use rustc::hir; +use rustc::hir::intravisit; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_passes/static_recursion.rs b/src/librustc_passes/static_recursion.rs index 2230283c9777e..2766d13d7b8ab 100644 --- a/src/librustc_passes/static_recursion.rs +++ b/src/librustc_passes/static_recursion.rs @@ -12,7 +12,7 @@ // recursively. use rustc::dep_graph::DepNode; -use rustc::front::map as ast_map; +use rustc::hir::map as ast_map; use rustc::session::{Session, CompileResult}; use rustc::middle::def::{Def, DefMap}; use rustc::util::nodemap::NodeMap; @@ -20,8 +20,8 @@ use rustc::util::nodemap::NodeMap; use syntax::{ast}; use syntax::codemap::Span; use syntax::feature_gate::{GateIssue, emit_feature_err}; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir; use std::cell::RefCell; diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml index 89fa0df0306fb..e9a32e53a9fe6 100644 --- a/src/librustc_plugin/Cargo.toml +++ b/src/librustc_plugin/Cargo.toml @@ -13,7 +13,6 @@ log = { path = "../liblog" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_bitflags = { path = "../librustc_bitflags" } -rustc_front = { path = "../librustc_front" } rustc_metadata = { path = "../librustc_metadata" } rustc_mir = { path = "../librustc_mir" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_plugin/build.rs b/src/librustc_plugin/build.rs index fe83b60933449..4c7755b1b0937 100644 --- a/src/librustc_plugin/build.rs +++ b/src/librustc_plugin/build.rs @@ -15,9 +15,9 @@ use syntax::attr; use syntax::codemap::Span; use syntax::errors; use rustc::dep_graph::DepNode; -use rustc::front::map::Map; -use rustc_front::intravisit::Visitor; -use rustc_front::hir; +use rustc::hir::map::Map; +use rustc::hir::intravisit::Visitor; +use rustc::hir; struct RegistrarFinder { registrars: Vec<(ast::NodeId, Span)> , diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 8de2608391068..5fa29771c57fb 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -69,7 +69,6 @@ extern crate rustc; extern crate rustc_back; -extern crate rustc_front; extern crate rustc_metadata; extern crate rustc_mir; diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 56d6ca5543a0e..0553e54e3aa9b 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -11,5 +11,4 @@ crate-type = ["dylib"] [dependencies] log = { path = "../liblog" } rustc = { path = "../librustc" } -rustc_front = { path = "../librustc_front" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 80df21e85f6f5..908a7869c4297 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -25,13 +25,12 @@ #[macro_use] extern crate syntax; #[macro_use] extern crate rustc; -extern crate rustc_front; use std::cmp; use std::mem::replace; -use rustc_front::hir::{self, PatKind}; -use rustc_front::intravisit::{self, Visitor}; +use rustc::hir::{self, PatKind}; +use rustc::hir::intravisit::{self, Visitor}; use rustc::dep_graph::DepNode; use rustc::lint; @@ -41,7 +40,7 @@ use rustc::middle::def_id::DefId; use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::ty::{self, TyCtxt}; use rustc::util::nodemap::NodeSet; -use rustc::front::map as ast_map; +use rustc::hir::map as ast_map; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 82e952d2beef8..cf477c2a956aa 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -13,5 +13,4 @@ log = { path = "../liblog" } syntax = { path = "../libsyntax" } rustc = { path = "../librustc" } rustc_bitflags = { path = "../librustc_bitflags" } -rustc_front = { path = "../librustc_front" } arena = { path = "../libarena" } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index f36a8269dc002..470fd88025e4e 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -33,15 +33,15 @@ use syntax::attr::AttrMetaMethods; use syntax::parse::token::{special_idents, SELF_KEYWORD_NAME, SUPER_KEYWORD_NAME}; use syntax::codemap::{Span, DUMMY_SP}; -use rustc_front::hir; -use rustc_front::hir::{Block, DeclItem}; -use rustc_front::hir::{ForeignItem, ForeignItemFn, ForeignItemStatic}; -use rustc_front::hir::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn}; -use rustc_front::hir::{ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; -use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; -use rustc_front::hir::{PathListIdent, PathListMod, StmtDecl}; -use rustc_front::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple}; -use rustc_front::intravisit::{self, Visitor}; +use rustc::hir; +use rustc::hir::{Block, DeclItem}; +use rustc::hir::{ForeignItem, ForeignItemFn, ForeignItemStatic}; +use rustc::hir::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn}; +use rustc::hir::{ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; +use rustc::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; +use rustc::hir::{PathListIdent, PathListMod, StmtDecl}; +use rustc::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple}; +use rustc::hir::intravisit::{self, Visitor}; trait ToNameBinding<'a> { fn to_name_binding(self) -> NameBinding<'a>; diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index ea197109cabc4..4046c8c7783b8 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -26,9 +26,9 @@ use rustc::lint; use syntax::ast; use syntax::codemap::{Span, DUMMY_SP}; -use rustc_front::hir; -use rustc_front::hir::{ViewPathGlob, ViewPathList, ViewPathSimple}; -use rustc_front::intravisit::Visitor; +use rustc::hir; +use rustc::hir::{ViewPathGlob, ViewPathList, ViewPathSimple}; +use rustc::hir::intravisit::Visitor; struct UnusedImportCheckVisitor<'a, 'b: 'a, 'tcx: 'b> { resolver: &'a mut Resolver<'b, 'tcx>, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 98e40d7313327..bbf8796436efd 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -31,7 +31,6 @@ extern crate arena; #[macro_use] #[no_link] extern crate rustc_bitflags; -extern crate rustc_front; #[macro_use] extern crate rustc; @@ -49,7 +48,7 @@ use self::ParentLink::*; use self::FallbackChecks::*; use rustc::dep_graph::DepNode; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::session::Session; use rustc::lint; use rustc::middle::cstore::CrateStore; @@ -68,24 +67,24 @@ use syntax::errors::DiagnosticBuilder; use syntax::parse::token::{self, special_names, special_idents}; use syntax::util::lev_distance::find_best_match_for_name; -use rustc_front::intravisit::{self, FnKind, Visitor}; -use rustc_front::hir; -use rustc_front::hir::{Arm, BindByRef, BindByValue, BindingMode, Block}; -use rustc_front::hir::Crate; -use rustc_front::hir::{Expr, ExprAgain, ExprBreak, ExprCall, ExprField}; -use rustc_front::hir::{ExprLoop, ExprWhile, ExprMethodCall}; -use rustc_front::hir::{ExprPath, ExprStruct, FnDecl}; -use rustc_front::hir::{ForeignItemFn, ForeignItemStatic, Generics}; -use rustc_front::hir::{ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate}; -use rustc_front::hir::{ItemFn, ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; -use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; -use rustc_front::hir::Local; -use rustc_front::hir::{Pat, PatKind, Path, PrimTy}; -use rustc_front::hir::{PathSegment, PathParameters}; -use rustc_front::hir::HirVec; -use rustc_front::hir::{TraitRef, Ty, TyBool, TyChar, TyFloat, TyInt}; -use rustc_front::hir::{TyRptr, TyStr, TyUint, TyPath, TyPtr}; -use rustc_front::util::walk_pat; +use rustc::hir::intravisit::{self, FnKind, Visitor}; +use rustc::hir; +use rustc::hir::{Arm, BindByRef, BindByValue, BindingMode, Block}; +use rustc::hir::Crate; +use rustc::hir::{Expr, ExprAgain, ExprBreak, ExprCall, ExprField}; +use rustc::hir::{ExprLoop, ExprWhile, ExprMethodCall}; +use rustc::hir::{ExprPath, ExprStruct, FnDecl}; +use rustc::hir::{ForeignItemFn, ForeignItemStatic, Generics}; +use rustc::hir::{ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate}; +use rustc::hir::{ItemFn, ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; +use rustc::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; +use rustc::hir::Local; +use rustc::hir::{Pat, PatKind, Path, PrimTy}; +use rustc::hir::{PathSegment, PathParameters}; +use rustc::hir::HirVec; +use rustc::hir::{TraitRef, Ty, TyBool, TyChar, TyFloat, TyInt}; +use rustc::hir::{TyRptr, TyStr, TyUint, TyPath, TyPtr}; +use rustc::hir::util::walk_pat; use std::collections::{HashMap, HashSet}; use std::cell::{Cell, RefCell}; diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index a0cf70b57a9d4..52fa91934723d 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -11,5 +11,4 @@ crate-type = ["dylib"] [dependencies] log = { path = "../liblog" } rustc = { path = "../librustc" } -rustc_front = { path = "../librustc_front" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 35ca2a9b0149a..310747c89914a 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -42,7 +42,7 @@ use syntax::visit::{self, Visitor}; use syntax::print::pprust::{path_to_string, ty_to_string}; use syntax::ptr::P; -use rustc_front::lowering::{lower_expr, LoweringContext}; +use rustc::hir::lowering::{lower_expr, LoweringContext}; use super::{escape, generated_code, SaveContext, PathCollector}; use super::data::*; diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 36b94731e45ab..e65bf5be25648 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -23,13 +23,12 @@ #![feature(staged_api)] #[macro_use] extern crate rustc; -extern crate rustc_front; #[macro_use] extern crate log; #[macro_use] extern crate syntax; -use rustc_front::{hir, lowering}; -use rustc::front::map::NodeItem; +use rustc::hir::{self, lowering}; +use rustc::hir::map::NodeItem; use rustc::middle::def::Def; use rustc::middle::def_id::DefId; use rustc::session::config::CrateType::CrateTypeExecutable; @@ -278,7 +277,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { match item.node { hir::ItemImpl(_, _, _, _, ref ty, _) => { let mut result = String::from("<"); - result.push_str(&rustc_front::print::pprust::ty_to_string(&ty)); + result.push_str(&rustc::hir::print::ty_to_string(&ty)); match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) { Some(def_id) => { diff --git a/src/librustc_trans/Cargo.toml b/src/librustc_trans/Cargo.toml index fb5a8e4a90eb5..ea4cef03b707a 100644 --- a/src/librustc_trans/Cargo.toml +++ b/src/librustc_trans/Cargo.toml @@ -18,7 +18,6 @@ rustc_back = { path = "../librustc_back" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_const_math = { path = "../librustc_const_math" } rustc_data_structures = { path = "../librustc_data_structures" } -rustc_front = { path = "../librustc_front" } rustc_llvm = { path = "../librustc_llvm" } rustc_mir = { path = "../librustc_mir" } rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" } diff --git a/src/librustc_trans/_match.rs b/src/librustc_trans/_match.rs index b27929c80c2d8..3bbead9847bdd 100644 --- a/src/librustc_trans/_match.rs +++ b/src/librustc_trans/_match.rs @@ -229,10 +229,10 @@ use std::cell::RefCell; use std::cmp::Ordering; use std::fmt; use std::rc::Rc; -use rustc_front::hir::{self, PatKind}; +use rustc::hir::{self, PatKind}; use syntax::ast::{self, DUMMY_NODE_ID, NodeId}; use syntax::codemap::Span; -use rustc_front::fold::Folder; +use rustc::hir::fold::Folder; use syntax::ptr::P; #[derive(Copy, Clone, Debug)] diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 6edc26c70097a..961a32170d0df 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -26,7 +26,7 @@ use machine::{llalign_of_min, llsize_of, llsize_of_real}; use type_::Type; use type_of; -use rustc_front::hir; +use rustc::hir; use rustc::ty::{self, Ty}; use libc::c_uint; diff --git a/src/librustc_trans/asm.rs b/src/librustc_trans/asm.rs index 41f1f4ae5f8ba..e27bec683757a 100644 --- a/src/librustc_trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -18,7 +18,7 @@ use datum::{Datum, Lvalue}; use type_of; use type_::Type; -use rustc_front::hir as ast; +use rustc::hir as ast; use std::ffi::CString; use syntax::ast::AsmDialect; use libc::{c_uint, c_char}; diff --git a/src/librustc_trans/assert_dep_graph.rs b/src/librustc_trans/assert_dep_graph.rs index bd98b3950d44c..ecbb504944330 100644 --- a/src/librustc_trans/assert_dep_graph.rs +++ b/src/librustc_trans/assert_dep_graph.rs @@ -43,8 +43,8 @@ use rustc::middle::def_id::DefId; use rustc::ty::TyCtxt; use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet}; use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex}; -use rustc_front::hir; -use rustc_front::intravisit::Visitor; +use rustc::hir; +use rustc::hir::intravisit::Visitor; use graphviz::IntoCow; use std::env; use std::fs::File; diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 7aef1d912ecce..130499603e7a7 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -43,7 +43,7 @@ use syntax::ast; use syntax::codemap::Span; use syntax::attr::AttrMetaMethods; -use rustc_front::hir; +use rustc::hir; // RLIB LLVM-BYTECODE OBJECT LAYOUT // Version 1 diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index a458307da4070..949a10297c1e2 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -105,7 +105,7 @@ use rustc::middle::cstore; use rustc::middle::def_id::DefId; use rustc::ty::{self, TypeFoldable}; use rustc::ty::item_path::{ItemPathBuffer, RootMode}; -use rustc::front::map::definitions::{DefPath, DefPathData}; +use rustc::hir::map::definitions::{DefPath, DefPathData}; use std::fmt::Write; use syntax::parse::token::{self, InternedString}; diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index e5667e06b4411..d2fc20fd8375f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -46,7 +46,7 @@ use rustc::traits; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::dep_graph::DepNode; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::util::common::time; use rustc::mir::mir_map::MirMap; use session::config::{self, NoDebugInfo, FullDebugInfo}; @@ -106,9 +106,8 @@ use syntax::codemap::{Span, DUMMY_SP}; use syntax::parse::token::InternedString; use syntax::attr::AttrMetaMethods; use syntax::attr; -use rustc_front; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir; use syntax::ast; thread_local! { @@ -713,7 +712,7 @@ fn cast_shift_rhs(op: hir::BinOp_, G: FnOnce(ValueRef, Type) -> ValueRef { // Shifts may have any size int on the rhs - if rustc_front::util::is_shift_binop(op) { + if hir::util::is_shift_binop(op) { let mut rhs_llty = val_ty(rhs); let mut lhs_llty = val_ty(lhs); if rhs_llty.kind() == Vector { diff --git a/src/librustc_trans/callee.rs b/src/librustc_trans/callee.rs index 6b0945b2bb248..2da9acf325089 100644 --- a/src/librustc_trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -26,7 +26,7 @@ use rustc::infer; use rustc::ty::subst; use rustc::ty::subst::{Substs}; use rustc::traits; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use abi::{Abi, FnType}; use adt; use attributes; @@ -54,7 +54,7 @@ use type_of; use value::Value; use Disr; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; -use rustc_front::hir; +use rustc::hir; use syntax::codemap::DUMMY_SP; use syntax::errors; diff --git a/src/librustc_trans/closure.rs b/src/librustc_trans/closure.rs index cb94c9dfeb8d9..579848919ecb9 100644 --- a/src/librustc_trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -35,7 +35,7 @@ use session::config::FullDebugInfo; use syntax::ast; -use rustc_front::hir; +use rustc::hir; use libc::c_uint; diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 1c18f3ca393c2..4f197dbee1315 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -188,10 +188,10 @@ //! this is not implemented however: a translation item will be produced //! regardless of whether it is actually needed or not. -use rustc_front::hir; -use rustc_front::intravisit as hir_visit; +use rustc::hir; +use rustc::hir::intravisit as hir_visit; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::middle::def_id::DefId; use rustc::middle::lang_items::{ExchangeFreeFnLangItem, ExchangeMallocFnLangItem}; use rustc::traits; diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 589e6f3266e8e..1f48eb916039b 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -40,7 +40,7 @@ use value::Value; use rustc::ty::{self, Ty, TyCtxt}; use rustc::traits::{self, SelectionContext, ProjectionMode}; use rustc::ty::fold::{TypeFolder, TypeFoldable}; -use rustc_front::hir; +use rustc::hir; use util::nodemap::NodeMap; use arena::TypedArena; diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 3e516c0eec418..7945639f86b32 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -17,7 +17,7 @@ use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, lookup_const_by_id, use rustc_const_eval::eval_repeat_count; use middle::def::Def; use middle::def_id::DefId; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use {abi, adt, closure, debuginfo, expr, machine}; use base::{self, exported_name, imported_name, push_ctxt}; use callee::Callee; @@ -41,7 +41,7 @@ use rustc::ty::cast::{CastTy,IntTy}; use util::nodemap::NodeMap; use rustc_const_math::{ConstInt, ConstMathErr, ConstUsize, ConstIsize}; -use rustc_front::hir; +use rustc::hir; use std::ffi::{CStr, CString}; use std::borrow::Cow; diff --git a/src/librustc_trans/controlflow.rs b/src/librustc_trans/controlflow.rs index 6d4b02f076c87..60ae91a8c5f7c 100644 --- a/src/librustc_trans/controlflow.rs +++ b/src/librustc_trans/controlflow.rs @@ -25,8 +25,8 @@ use debuginfo::{DebugLoc, ToDebugLoc}; use expr; use machine; -use rustc_front::hir; -use rustc_front::util as ast_util; +use rustc::hir; +use rustc::hir::util as ast_util; use syntax::ast; use syntax::parse::token::InternedString; diff --git a/src/librustc_trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs index a7f2bf4a5fa23..477dc0b4b52b1 100644 --- a/src/librustc_trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -21,8 +21,7 @@ use libc::c_uint; use syntax::codemap::{Span, Pos}; use syntax::{ast, codemap}; -use rustc_front; -use rustc_front::hir::{self, PatKind}; +use rustc::hir::{self, PatKind}; // This procedure builds the *scope map* for a given function, which maps any // given ast::NodeId in the function's AST to the correct DIScope metadata instance. @@ -117,7 +116,7 @@ fn walk_block(cx: &CrateContext, // The interesting things here are statements and the concluding expression. for statement in &block.stmts { - scope_map.insert(rustc_front::util::stmt_id(statement), + scope_map.insert(hir::util::stmt_id(statement), scope_stack.last().unwrap().scope_metadata); match statement.node { diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 5690b18bc8ede..acfafc6e3297d 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -27,8 +27,8 @@ use middle::def_id::DefId; use rustc::infer; use middle::pat_util; use rustc::ty::subst; -use rustc::front::map as hir_map; -use rustc_front::hir::{self, PatKind}; +use rustc::hir::map as hir_map; +use rustc::hir::{self, PatKind}; use {type_of, adt, machine, monomorphize}; use common::{self, CrateContext, FunctionContext, Block}; use _match::{BindingInfo, TransBindingMode}; diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 6b92989cf4648..f671c2b79636c 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -29,8 +29,7 @@ use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArr use middle::def_id::DefId; use rustc::infer::normalize_associated_type; use rustc::ty::subst::{self, Substs}; -use rustc_front; -use rustc_front::hir; +use rustc::hir; use abi::Abi; use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block}; @@ -39,7 +38,7 @@ use rustc::infer; use rustc::ty::{self, Ty}; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet}; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use libc::c_uint; use std::cell::{Cell, RefCell}; @@ -239,7 +238,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, return FunctionDebugContext::FunctionWithoutDebugInfo; } - let empty_generics = rustc_front::util::empty_generics(); + let empty_generics = hir::util::empty_generics(); let fnitem = cx.tcx().map.get(fn_ast_id); diff --git a/src/librustc_trans/debuginfo/namespace.rs b/src/librustc_trans/debuginfo/namespace.rs index 445f85c52fc75..1feb47a3a7d99 100644 --- a/src/librustc_trans/debuginfo/namespace.rs +++ b/src/librustc_trans/debuginfo/namespace.rs @@ -15,7 +15,7 @@ use super::utils::{DIB, debug_context}; use llvm; use llvm::debuginfo::DIScope; use rustc::middle::def_id::DefId; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use common::CrateContext; use std::ffi::CString; diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index a6aa8df92db29..f5bb1677f29ba 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -18,7 +18,7 @@ use rustc::infer; use rustc::ty::subst; use rustc::ty::{self, Ty}; -use rustc_front::hir; +use rustc::hir; // Compute the name of the type as it should be stored in debuginfo. Does not do // any caching, i.e. calling the function twice with the same type will also do diff --git a/src/librustc_trans/expr.rs b/src/librustc_trans/expr.rs index 5e193b962783b..7c2557fb09023 100644 --- a/src/librustc_trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -80,8 +80,7 @@ use util::common::indenter; use machine::{llsize_of, llsize_of_alloc}; use type_::Type; -use rustc_front; -use rustc_front::hir; +use rustc::hir; use syntax::{ast, codemap}; use syntax::parse::token::InternedString; @@ -1181,7 +1180,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // if not overloaded, would be RvalueDatumExpr let lhs = unpack_datum!(bcx, trans(bcx, &lhs)); let mut rhs = unpack_datum!(bcx, trans(bcx, &rhs_expr)); - if !rustc_front::util::is_by_value_binop(op.node) { + if !hir::util::is_by_value_binop(op.node) { rhs = unpack_datum!(bcx, auto_ref(bcx, rhs, rhs_expr)); } @@ -1205,7 +1204,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, span_bug!( expr.span, "augmented assignment `{}=` should always be a rvalue_stmt", - rustc_front::util::binop_to_string(op.node)) + hir::util::binop_to_string(op.node)) } _ => { span_bug!( diff --git a/src/librustc_trans/inline.rs b/src/librustc_trans/inline.rs index 4d18e3bd4958f..36dfbec115e79 100644 --- a/src/librustc_trans/inline.rs +++ b/src/librustc_trans/inline.rs @@ -17,7 +17,7 @@ use callee::Callee; use common::*; use rustc::dep_graph::DepNode; -use rustc_front::hir; +use rustc::hir; fn instantiate_inline(ccx: &CrateContext, fn_id: DefId) -> Option { debug!("instantiate_inline({:?})", fn_id); diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 28d5d9ac176ff..355de31bf590d 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -40,7 +40,7 @@ use rustc::ty::{self, Ty, TypeFoldable}; use Disr; use rustc::ty::subst::Substs; use rustc::dep_graph::DepNode; -use rustc_front::hir; +use rustc::hir; use syntax::ast; use syntax::ptr::P; use syntax::parse::token; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 8c6a68cfcf110..19a172e7f102b 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -46,7 +46,6 @@ extern crate libc; #[macro_use] extern crate rustc; extern crate rustc_back; extern crate rustc_data_structures; -extern crate rustc_front; pub extern crate rustc_llvm as llvm; extern crate rustc_mir; extern crate rustc_platform_intrinsics as intrinsics; @@ -67,7 +66,7 @@ pub use disr::Disr; pub mod back { pub use rustc_back::rpath; - pub use rustc_back::svh; + pub use rustc::hir::svh; pub mod archive; pub mod linker; diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 3f7a6c5f18045..8e5d220b4f4e8 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -134,7 +134,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { _ => { // FIXME Shouldn't need to manually trigger closure instantiations. if let mir::AggregateKind::Closure(def_id, substs) = *kind { - use rustc_front::hir; + use rustc::hir; use syntax::ast::DUMMY_NODE_ID; use syntax::codemap::DUMMY_SP; use syntax::ptr::P; diff --git a/src/librustc_trans/monomorphize.rs b/src/librustc_trans/monomorphize.rs index 554e1948fe9de..de66951d09129 100644 --- a/src/librustc_trans/monomorphize.rs +++ b/src/librustc_trans/monomorphize.rs @@ -23,10 +23,10 @@ use base; use common::*; use declare; use Disr; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::util::ppaux; -use rustc_front::hir; +use rustc::hir; use syntax::attr; use syntax::errors; diff --git a/src/librustc_trans/symbol_names_test.rs b/src/librustc_trans/symbol_names_test.rs index a75b6f736eee2..2e3355968dffa 100644 --- a/src/librustc_trans/symbol_names_test.rs +++ b/src/librustc_trans/symbol_names_test.rs @@ -15,8 +15,8 @@ //! paths etc in all kinds of annoying scenarios. use back::symbol_names; -use rustc_front::hir; -use rustc_front::intravisit::{self, Visitor}; +use rustc::hir; +use rustc::hir::intravisit::{self, Visitor}; use syntax::ast; use syntax::attr::AttrMetaMethods; diff --git a/src/librustc_trans/tvec.rs b/src/librustc_trans/tvec.rs index b9af02ac529f5..f5b9bef5313f2 100644 --- a/src/librustc_trans/tvec.rs +++ b/src/librustc_trans/tvec.rs @@ -29,7 +29,7 @@ use type_of; use value::Value; use rustc::ty::{self, Ty}; -use rustc_front::hir; +use rustc::hir; use rustc_const_eval::eval_repeat_count; use syntax::ast; diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index 6f46686feb5c8..e9dabf16eaece 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -17,5 +17,4 @@ rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_const_math = { path = "../librustc_const_math" } -rustc_front = { path = "../librustc_front" } rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index d925ff9fa3cf6..a52b8cad1083a 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -74,8 +74,8 @@ use syntax::errors::DiagnosticBuilder; use syntax::feature_gate::{GateIssue, emit_feature_err}; use syntax::parse::token; -use rustc_front::print::pprust; -use rustc_front::hir; +use rustc::hir::print as pprust; +use rustc::hir; use rustc_back::slice; pub trait AstConv<'tcx> { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 55c3a5add37bb..5c93c17059082 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -30,9 +30,9 @@ use syntax::ast; use syntax::codemap::{Span, Spanned}; use syntax::ptr::P; -use rustc_front::hir::{self, PatKind}; -use rustc_front::print::pprust; -use rustc_front::util as hir_util; +use rustc::hir::{self, PatKind}; +use rustc::hir::print as pprust; +use rustc::hir::util as hir_util; pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx hir::Pat, diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index bedf4753313fd..460230c60c60a 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -34,7 +34,7 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::ptr::P; -use rustc_front::hir; +use rustc::hir; /// Check that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index d743a036040d5..00a73a062fe18 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -48,7 +48,7 @@ use middle::def_id::DefId; use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::cast::{CastKind, CastTy}; use syntax::codemap::Span; -use rustc_front::hir; +use rustc::hir; use syntax::ast; diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 9333b10d27e4a..7bca570411ceb 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -17,7 +17,7 @@ use rustc::ty::subst; use rustc::ty::{self, ToPolyTraitRef, Ty}; use std::cmp; use syntax::abi::Abi; -use rustc_front::hir; +use rustc::hir; pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expr: &hir::Expr, diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index cafd0519c2821..f1c6868efd210 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -76,7 +76,7 @@ use util::common::indent; use std::cell::RefCell; use std::collections::VecDeque; -use rustc_front::hir; +use rustc::hir; struct Coerce<'a, 'tcx: 'a> { fcx: &'a FnCtxt<'a, 'tcx>, diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index bc2ef9aafee59..5b163eb7de452 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -14,7 +14,7 @@ use rustc::ty::Ty; use rustc::infer::{InferOk, TypeOrigin}; use syntax::codemap::Span; -use rustc_front::hir; +use rustc::hir; // Requires that the two types unify, and prints an error message if // they don't. diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 3c43e0d521743..eae0cfb0f2267 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -26,7 +26,7 @@ use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; use syntax::parse::token; -use rustc_front::hir; +use rustc::hir; fn equate_intrinsic_type<'a, 'tcx>(tcx: &TyCtxt<'tcx>, it: &hir::ForeignItem, n_tps: usize, diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index f90a569653972..cc12b2e05152d 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -21,7 +21,7 @@ use rustc::ty::fold::TypeFoldable; use rustc::infer; use rustc::infer::{InferCtxt, TypeOrigin}; use syntax::codemap::Span; -use rustc_front::hir; +use rustc::hir; struct ConfirmContext<'a, 'tcx:'a> { fcx: &'a FnCtxt<'a, 'tcx>, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 43a18d2c1024f..72ca73aac940e 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -23,7 +23,7 @@ use rustc::infer; use syntax::ast; use syntax::codemap::Span; -use rustc_front::hir; +use rustc::hir; pub use self::MethodError::*; pub use self::CandidateSource::*; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 2e15ac0e13084..c907a6dc64020 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -24,7 +24,7 @@ use rustc::ty::{self, NoPreference, Ty, TyCtxt, ToPolyTraitRef, TraitRef, TypeFo use rustc::infer::{self, InferCtxt, InferOk, TypeOrigin}; use syntax::ast; use syntax::codemap::{Span, DUMMY_SP}; -use rustc_front::hir; +use rustc::hir; use std::collections::HashSet; use std::mem; use std::rc::Rc; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 32b5a63817ea5..620863a7a2e11 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -15,7 +15,7 @@ use CrateCtxt; use astconv::AstConv; use check::{self, FnCtxt, UnresolvedTypeAction, autoderef}; -use front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TypeFoldable}; use middle::cstore::{self, CrateStore}; use middle::def::Def; @@ -30,9 +30,9 @@ use util::nodemap::{FnvHashSet}; use syntax::ast; use syntax::codemap::Span; use syntax::errors::DiagnosticBuilder; -use rustc_front::print::pprust; -use rustc_front::hir; -use rustc_front::hir::Expr_; +use rustc::hir::print as pprust; +use rustc::hir; +use rustc::hir::Expr_; use std::cell; use std::cmp::Ordering; @@ -436,7 +436,7 @@ impl Ord for TraitInfo { /// Retrieve all traits in this crate and any dependent crates. pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> { if ccx.all_traits.borrow().is_none() { - use rustc_front::intravisit; + use rustc::hir::intravisit; let mut traits = vec![]; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e485fbe1621c8..20b9a75e0e555 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -124,10 +124,10 @@ use syntax::parse::token::{self, InternedString, special_idents}; use syntax::ptr::P; use syntax::util::lev_distance::find_best_match_for_name; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir; -use rustc_front::hir::{Visibility, PatKind}; -use rustc_front::print::pprust; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir; +use rustc::hir::{Visibility, PatKind}; +use rustc::hir::print as pprust; use rustc_back::slice; use rustc_const_eval::eval_repeat_count; @@ -3987,7 +3987,7 @@ fn check_block_with_expected<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let mut any_err = false; for s in &blk.stmts { check_stmt(fcx, s); - let s_id = ::rustc_front::util::stmt_id(s); + let s_id = hir::util::stmt_id(s); let s_ty = fcx.node_ty(s_id); if any_diverges && !warned && match s.node { hir::StmtDecl(ref decl, _) => { diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 494135ee3ffb1..1af015cdebf90 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -22,8 +22,8 @@ use middle::def_id::DefId; use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue}; use syntax::ast; use syntax::parse::token; -use rustc_front::hir; -use rustc_front::util as hir_util; +use rustc::hir; +use rustc::hir::util as hir_util; /// Check a `a = b` pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 15bf6671de501..ed9372acba952 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -100,9 +100,9 @@ use rustc::ty::wf::ImpliedBound; use std::mem; use syntax::ast; use syntax::codemap::Span; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir::{self, PatKind}; -use rustc_front::util as hir_util; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir::{self, PatKind}; +use rustc::hir::util as hir_util; use self::SubjectNode::Subject; diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 7d51d5ec7f744..40481cda76290 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -51,8 +51,8 @@ use rustc::infer::{InferCtxt, UpvarRegion}; use std::collections::HashSet; use syntax::ast; use syntax::codemap::Span; -use rustc_front::hir; -use rustc_front::intravisit::{self, Visitor}; +use rustc::hir; +use rustc::hir::intravisit::{self, Visitor}; /////////////////////////////////////////////////////////////////////////// // PUBLIC ENTRY POINTS diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 68c9816b48c3e..0ed0b64b9704f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -25,8 +25,8 @@ use syntax::ast; use syntax::codemap::{Span}; use syntax::errors::DiagnosticBuilder; use syntax::parse::token::{special_idents}; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::hir; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir; pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> { ccx: &'ccx CrateCtxt<'ccx, 'tcx>, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 7ede85454e90f..6ac6f1d6e17d1 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -28,10 +28,10 @@ use std::cell::Cell; use syntax::ast; use syntax::codemap::{DUMMY_SP, Span}; -use rustc_front::print::pprust::pat_to_string; -use rustc_front::intravisit::{self, Visitor}; -use rustc_front::util as hir_util; -use rustc_front::hir; +use rustc::hir::print::pat_to_string; +use rustc::hir::intravisit::{self, Visitor}; +use rustc::hir::util as hir_util; +use rustc::hir; /////////////////////////////////////////////////////////////////////////// // Entry point functions diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index f9a4cfadc0b11..1f7fc45327965 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -39,10 +39,10 @@ use syntax::codemap::Span; use syntax::errors::DiagnosticBuilder; use util::nodemap::{DefIdMap, FnvHashMap}; use rustc::dep_graph::DepNode; -use rustc::front::map as hir_map; -use rustc_front::intravisit; -use rustc_front::hir::{Item, ItemImpl}; -use rustc_front::hir; +use rustc::hir::map as hir_map; +use rustc::hir::intravisit; +use rustc::hir::{Item, ItemImpl}; +use rustc::hir; mod orphan; mod overlap; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index eba3e56c72207..0821d5582bded 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -18,8 +18,8 @@ use rustc::ty::{self, TyCtxt}; use syntax::ast; use syntax::codemap::Span; use rustc::dep_graph::DepNode; -use rustc_front::intravisit; -use rustc_front::hir; +use rustc::hir::intravisit; +use rustc::hir; pub fn check(tcx: &TyCtxt) { let mut orphan = OrphanChecker { tcx: tcx }; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index d7d4560a4eac3..d99c5d52f4a67 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -19,8 +19,8 @@ use rustc::infer; use rustc::ty::{self, TyCtxt}; use syntax::ast; use rustc::dep_graph::DepNode; -use rustc_front::hir; -use rustc_front::intravisit; +use rustc::hir; +use rustc::hir::intravisit; use util::nodemap::DefIdMap; use lint; diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 6d77200daa384..b042e23e0ac04 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -12,8 +12,8 @@ //! crate or pertains to a type defined in this crate. use rustc::ty::TyCtxt; -use rustc_front::intravisit; -use rustc_front::hir; +use rustc::hir::intravisit; +use rustc::hir; pub fn check(tcx: &TyCtxt) { let mut orphan = UnsafetyChecker { tcx: tcx }; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 59546f619c0ac..53126d3494ab1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -77,7 +77,7 @@ use rustc::ty::fold::{TypeFolder}; use rustc::ty::util::IntTypeExt; use rscope::*; use rustc::dep_graph::DepNode; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use util::common::{ErrorReported, MemoizationMap}; use util::nodemap::{FnvHashMap, FnvHashSet}; use write_ty_to_tcx; @@ -94,9 +94,9 @@ use syntax::attr; use syntax::codemap::Span; use syntax::parse::token::special_idents; use syntax::ptr::P; -use rustc_front::hir::{self, PatKind}; -use rustc_front::intravisit; -use rustc_front::print::pprust; +use rustc::hir::{self, PatKind}; +use rustc::hir::intravisit; +use rustc::hir::print as pprust; /////////////////////////////////////////////////////////////////////////// // Main entry point diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index fa23445fe630d..af32026d47e46 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -90,20 +90,19 @@ extern crate arena; extern crate fmt_macros; #[macro_use] extern crate rustc; extern crate rustc_platform_intrinsics as intrinsics; -extern crate rustc_front; extern crate rustc_back; extern crate rustc_const_math; extern crate rustc_const_eval; pub use rustc::dep_graph; -pub use rustc::front; +pub use rustc::hir; pub use rustc::lint; pub use rustc::middle; pub use rustc::session; pub use rustc::util; use dep_graph::DepNode; -use front::map as hir_map; +use hir::map as hir_map; use middle::def::Def; use rustc::infer::{self, TypeOrigin}; use rustc::ty::subst::Substs; @@ -111,7 +110,6 @@ use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::traits::ProjectionMode; use session::{config, CompileResult}; use util::common::time; -use rustc_front::hir; use syntax::codemap::Span; use syntax::ast; diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 50c99e33b4455..fa3ee80c6dac8 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -20,10 +20,10 @@ use rustc::ty::subst; use rustc::ty::subst::ParamSpace; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::maps::ItemVariances; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use syntax::ast; -use rustc_front::hir; -use rustc_front::intravisit::Visitor; +use rustc::hir; +use rustc::hir::intravisit::Visitor; use super::terms::*; use super::terms::VarianceTerm::*; diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index c6f82ba42e6be..413dc83e638f2 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -27,8 +27,8 @@ use rustc::ty::maps::ItemVariances; use std::fmt; use std::rc::Rc; use syntax::ast; -use rustc_front::hir; -use rustc_front::intravisit::Visitor; +use rustc::hir; +use rustc::hir::intravisit::Visitor; use util::nodemap::NodeMap; use self::VarianceTerm::*; diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 228eb099a047c..9d76dd81e5f76 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -15,7 +15,6 @@ rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_driver = { path = "../librustc_driver" } -rustc_front = { path = "../librustc_front" } rustc_lint = { path = "../librustc_lint" } rustc_metadata = { path = "../librustc_metadata" } rustc_resolve = { path = "../librustc_resolve" } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 3e4ba47ce4cd2..2f080dae37084 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -14,7 +14,7 @@ use std::collections::HashSet; use syntax::ast; use syntax::attr::AttrMetaMethods; -use rustc_front::hir; +use rustc::hir; use rustc::middle::cstore::{self, CrateStore}; use rustc::middle::def::Def; @@ -484,7 +484,7 @@ fn build_module(cx: &DocContext, tcx: &TyCtxt, fn build_const(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Constant { - use rustc_front::print::pprust; + use rustc::hir::print as pprust; let (expr, ty) = lookup_const_by_id(tcx, did, None).unwrap_or_else(|| { panic!("expected lookup_const_by_id to succeed for {:?}", did); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7437d6087718a..715d0e759c3b7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -41,7 +41,7 @@ use rustc::ty::subst::{self, ParamSpace, VecPerParamSpace}; use rustc::ty; use rustc::middle::stability; -use rustc_front::hir; +use rustc::hir; use std::collections::{HashMap, HashSet}; use std::path::PathBuf; @@ -563,7 +563,7 @@ pub enum TyParamBound { impl TyParamBound { fn maybe_sized(cx: &DocContext) -> TyParamBound { - use rustc_front::hir::TraitBoundModifier as TBM; + use rustc::hir::TraitBoundModifier as TBM; let mut sized_bound = ty::BoundSized.clean(cx); if let TyParamBound::TraitBound(_, ref mut tbm) = sized_bound { *tbm = TBM::Maybe @@ -572,7 +572,7 @@ impl TyParamBound { } fn is_sized_bound(&self, cx: &DocContext) -> bool { - use rustc_front::hir::TraitBoundModifier as TBM; + use rustc::hir::TraitBoundModifier as TBM; if let Some(tcx) = cx.tcx_opt() { if let TyParamBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self { if trait_.def_id() == tcx.lang_items.sized_trait() { @@ -1609,7 +1609,7 @@ impl PrimitiveType { impl Clean for hir::Ty { fn clean(&self, cx: &DocContext) -> Type { - use rustc_front::hir::*; + use rustc::hir::*; match self.node { TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), TyRptr(ref l, ref m) => @@ -1826,7 +1826,7 @@ pub struct VariantStruct { pub fields_stripped: bool, } -impl Clean for ::rustc_front::hir::VariantData { +impl Clean for ::rustc::hir::VariantData { fn clean(&self, cx: &DocContext) -> VariantStruct { VariantStruct { struct_type: doctree::struct_type_from_def(self), @@ -2554,7 +2554,7 @@ fn lit_to_string(lit: &ast::Lit) -> String { } fn name_from_pat(p: &hir::Pat) -> String { - use rustc_front::hir::*; + use rustc::hir::*; debug!("Trying to get a name from pattern: {:?}", p); match p.node { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 15a10a84e4362..4686e60be872a 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -16,11 +16,11 @@ use rustc::session::{self, config}; use rustc::middle::def_id::DefId; use rustc::middle::privacy::AccessLevels; use rustc::ty::{self, TyCtxt}; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::lint; use rustc_trans::back::link; use rustc_resolve as resolve; -use rustc_front::lowering::{lower_crate, LoweringContext}; +use rustc::hir::lowering::{lower_crate, LoweringContext}; use rustc_metadata::cstore::CStore; use syntax::{ast, codemap, errors}; diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index fc0422b3a3f03..2db4b779eed98 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -20,7 +20,7 @@ use syntax::ast; use syntax::ast::{Name, NodeId}; use syntax::attr; use syntax::ptr::P; -use rustc_front::hir; +use rustc::hir; pub struct Module { pub name: Option, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index e9a883d6d7a01..9f0b636227ff6 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -21,7 +21,7 @@ use std::iter::repeat; use rustc::middle::cstore::LOCAL_CRATE; use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; use syntax::abi::Abi; -use rustc_front::hir; +use rustc::hir; use clean; use html::item_type::ItemType; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 1427dfcbaf178..f97d4fee05391 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -60,7 +60,7 @@ use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability; use rustc::session::config::get_unstable_features_setting; -use rustc_front::hir; +use rustc::hir; use clean::{self, SelfTy, Attributes, GetDefId}; use doctree; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a35fe20b6b6f4..9439c258318ae 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -41,7 +41,6 @@ extern crate rustc_driver; extern crate rustc_resolve; extern crate rustc_lint; extern crate rustc_back; -extern crate rustc_front; extern crate rustc_metadata; extern crate serialize; #[macro_use] extern crate syntax; diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index f93ecb46228c2..31f00caee436f 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -14,7 +14,7 @@ use rustc::util::nodemap::DefIdSet; use std::cmp; use std::string::String; use std::usize; -use rustc_front::hir; +use rustc::hir; use clean::{self, Attributes, GetDefId}; use clean::Item; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 5bd3b9c4f59e7..3810fb87acf6a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -24,11 +24,11 @@ use std::sync::{Arc, Mutex}; use testing; use rustc_lint; use rustc::dep_graph::DepGraph; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::session::{self, config}; use rustc::session::config::{get_unstable_features_setting, OutputType}; use rustc::session::search_paths::{SearchPaths, PathKind}; -use rustc_front::lowering::{lower_crate, LoweringContext}; +use rustc::hir::lowering::{lower_crate, LoweringContext}; use rustc_back::dynamic_lib::DynamicLibrary; use rustc_back::tempdir::TempDir; use rustc_driver::{driver, Compilation}; @@ -141,7 +141,7 @@ pub fn run(input: &str, } // Look for #![doc(test(no_crate_inject))], used by crates in the std facade -fn scrape_test_config(krate: &::rustc_front::hir::Crate) -> TestOptions { +fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions { use syntax::attr::AttrMetaMethods; use syntax::print::pprust; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index e4ef0c1a4d630..45c7969ef7c39 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -20,10 +20,10 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; -use rustc::front::map as hir_map; +use rustc::hir::map as hir_map; use rustc::middle::stability; -use rustc_front::hir; +use rustc::hir; use core; use clean::{Clean, Attributes}; diff --git a/src/rustc/Cargo.lock b/src/rustc/Cargo.lock index 3f0d5086a1787..4b5c2850dab08 100644 --- a/src/rustc/Cargo.lock +++ b/src/rustc/Cargo.lock @@ -75,7 +75,6 @@ dependencies = [ "rustc_bitflags 0.0.0", "rustc_const_eval 0.0.0", "rustc_data_structures 0.0.0", - "rustc_front 0.0.0", "serialize 0.0.0", "syntax 0.0.0", ] @@ -85,7 +84,6 @@ name = "rustc_back" version = "0.0.0" dependencies = [ "log 0.0.0", - "rustc_front 0.0.0", "serialize 0.0.0", "syntax 0.0.0", ] @@ -101,7 +99,6 @@ dependencies = [ "graphviz 0.0.0", "log 0.0.0", "rustc 0.0.0", - "rustc_front 0.0.0", "rustc_mir 0.0.0", "syntax 0.0.0", ] @@ -134,7 +131,6 @@ dependencies = [ "rustc 0.0.0", "rustc_back 0.0.0", "rustc_borrowck 0.0.0", - "rustc_front 0.0.0", "rustc_lint 0.0.0", "rustc_llvm 0.0.0", "rustc_metadata 0.0.0", @@ -151,16 +147,6 @@ dependencies = [ "syntax_ext 0.0.0", ] -[[package]] -name = "rustc_front" -version = "0.0.0" -dependencies = [ - "log 0.0.0", - "rustc_bitflags 0.0.0", - "serialize 0.0.0", - "syntax 0.0.0", -] - [[package]] name = "rustc_lint" version = "0.0.0" @@ -168,7 +154,6 @@ dependencies = [ "log 0.0.0", "rustc 0.0.0", "rustc_back 0.0.0", - "rustc_front 0.0.0", "syntax 0.0.0", ] @@ -192,7 +177,6 @@ dependencies = [ "rustc_back 0.0.0", "rustc_bitflags 0.0.0", "rustc_const_eval 0.0.0", - "rustc_front 0.0.0", "rustc_llvm 0.0.0", "serialize 0.0.0", "syntax 0.0.0", @@ -208,7 +192,6 @@ dependencies = [ "rustc_back 0.0.0", "rustc_const_eval 0.0.0", "rustc_data_structures 0.0.0", - "rustc_front 0.0.0", "syntax 0.0.0", ] @@ -218,7 +201,6 @@ version = "0.0.0" dependencies = [ "log 0.0.0", "rustc 0.0.0", - "rustc_front 0.0.0", "syntax 0.0.0", ] @@ -234,7 +216,6 @@ dependencies = [ "rustc 0.0.0", "rustc_back 0.0.0", "rustc_bitflags 0.0.0", - "rustc_front 0.0.0", "rustc_metadata 0.0.0", "rustc_mir 0.0.0", "syntax 0.0.0", @@ -246,7 +227,6 @@ version = "0.0.0" dependencies = [ "log 0.0.0", "rustc 0.0.0", - "rustc_front 0.0.0", "syntax 0.0.0", ] @@ -258,7 +238,6 @@ dependencies = [ "log 0.0.0", "rustc 0.0.0", "rustc_bitflags 0.0.0", - "rustc_front 0.0.0", "syntax 0.0.0", ] @@ -284,7 +263,6 @@ dependencies = [ "rustc_back 0.0.0", "rustc_const_eval 0.0.0", "rustc_data_structures 0.0.0", - "rustc_front 0.0.0", "rustc_llvm 0.0.0", "rustc_mir 0.0.0", "rustc_platform_intrinsics 0.0.0", @@ -302,7 +280,6 @@ dependencies = [ "rustc 0.0.0", "rustc_back 0.0.0", "rustc_const_eval 0.0.0", - "rustc_front 0.0.0", "rustc_platform_intrinsics 0.0.0", "syntax 0.0.0", ] @@ -318,7 +295,6 @@ dependencies = [ "rustc 0.0.0", "rustc_back 0.0.0", "rustc_driver 0.0.0", - "rustc_front 0.0.0", "rustc_lint 0.0.0", "rustc_metadata 0.0.0", "rustc_resolve 0.0.0", diff --git a/src/test/auxiliary/dummy_mir_pass.rs b/src/test/auxiliary/dummy_mir_pass.rs index fc1ef4d41a855..b5234af937b0c 100644 --- a/src/test/auxiliary/dummy_mir_pass.rs +++ b/src/test/auxiliary/dummy_mir_pass.rs @@ -14,7 +14,6 @@ #![feature(box_syntax)] #[macro_use] extern crate rustc; -extern crate rustc_front; extern crate rustc_plugin; extern crate rustc_const_math; extern crate syntax; diff --git a/src/test/auxiliary/lint_for_crate.rs b/src/test/auxiliary/lint_for_crate.rs index 1933188ccbf02..a424517da12f0 100644 --- a/src/test/auxiliary/lint_for_crate.rs +++ b/src/test/auxiliary/lint_for_crate.rs @@ -14,13 +14,12 @@ #![feature(box_syntax)] #[macro_use] extern crate rustc; -extern crate rustc_front; extern crate rustc_plugin; extern crate syntax; use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray}; use rustc_plugin::Registry; -use rustc_front::hir; +use rustc::hir; use syntax::attr; declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]"); diff --git a/src/test/auxiliary/lint_group_plugin_test.rs b/src/test/auxiliary/lint_group_plugin_test.rs index 98ed86bb390f3..1e9a77724a8eb 100644 --- a/src/test/auxiliary/lint_group_plugin_test.rs +++ b/src/test/auxiliary/lint_group_plugin_test.rs @@ -13,14 +13,12 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -extern crate rustc_front; - // Load rustc as a plugin to get macros #[macro_use] extern crate rustc; extern crate rustc_plugin; -use rustc_front::hir; +use rustc::hir; use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray}; use rustc_plugin::Registry; diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index 81ad276ca6874..91b4f5f30ad0d 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -14,7 +14,6 @@ extern crate libc; extern crate rustc; extern crate rustc_driver; -extern crate rustc_front; extern crate rustc_lint; extern crate rustc_llvm as llvm; extern crate rustc_metadata; @@ -28,13 +27,13 @@ use std::rc::Rc; use std::thread::Builder; use rustc::dep_graph::DepGraph; -use rustc::front::map as ast_map; +use rustc::hir::map as ast_map; use rustc::middle::cstore::{CrateStore, LinkagePreference}; use rustc::ty; use rustc::session::config::{self, basic_options, build_configuration, Input, Options}; use rustc::session::build_session; use rustc_driver::{driver, abort_on_err}; -use rustc_front::lowering::{lower_crate, LoweringContext}; +use rustc::hir::lowering::{lower_crate, LoweringContext}; use rustc_resolve::MakeGlobMap; use rustc_metadata::cstore::CStore; use libc::c_void; From ef4c7241f82c08848938b8b2dafed01535559ec0 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 29 Mar 2016 09:32:58 +0300 Subject: [PATCH 2/8] rustc: dismantle hir::util, mostly moving functions to methods. --- src/librustc/cfg/construct.rs | 2 +- src/librustc/hir/intravisit.rs | 183 +++++++++ src/librustc/hir/map/collector.rs | 2 +- src/librustc/hir/mod.rs | 165 +++++++- src/librustc/hir/print.rs | 8 +- src/librustc/hir/util.rs | 362 ------------------ src/librustc/lint/context.rs | 6 +- src/librustc/middle/cstore.rs | 3 +- src/librustc/middle/expr_use_visitor.rs | 6 +- src/librustc/middle/liveness.rs | 4 +- src/librustc/middle/pat_util.rs | 11 +- src/librustc/middle/region.rs | 3 +- src/librustc_borrowck/borrowck/mod.rs | 3 +- src/librustc_const_eval/check_match.rs | 11 +- src/librustc_lint/types.rs | 3 +- src/librustc_mir/hair/cx/expr.rs | 5 +- src/librustc_resolve/lib.rs | 3 +- src/librustc_trans/base.rs | 2 +- src/librustc_trans/controlflow.rs | 5 +- .../debuginfo/create_scope_map.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 2 +- src/librustc_trans/expr.rs | 4 +- src/librustc_typeck/check/_match.rs | 3 +- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/check/op.rs | 9 +- src/librustc_typeck/check/regionck.rs | 5 +- src/librustc_typeck/check/writeback.rs | 5 +- 27 files changed, 393 insertions(+), 426 deletions(-) delete mode 100644 src/librustc/hir/util.rs diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 4fc0a0926133e..13c3e3895b5d0 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -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 hir::util::lazy_binop(op.node) => { + hir::ExprBinary(op, ref l, ref r) if op.node.is_lazy() => { // // [pred] // | diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index be1cc528d889e..90fba0c8985dc 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -27,6 +27,7 @@ use syntax::abi::Abi; use syntax::ast::{NodeId, CRATE_NODE_ID, Name, Attribute}; +use syntax::ast_util; use syntax::attr::ThinAttributesExt; use syntax::codemap::Span; use hir::*; @@ -835,3 +836,185 @@ 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); } + +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); + 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) + -> 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 +} diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 7036822217256..62c80c9c8bbc3 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -304,7 +304,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; diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index eaf59af2cc359..cb3cdd0b8258d 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -59,7 +59,7 @@ 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; @@ -69,7 +69,6 @@ pub mod lowering; pub mod map; pub mod print; pub mod svh; -pub mod util; /// Identifier in HIR #[derive(Clone, Copy, Eq)] @@ -176,6 +175,21 @@ impl fmt::Display for Path { } } +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() + }], + } + } +} + /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] @@ -349,12 +363,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() } @@ -490,6 +517,50 @@ impl fmt::Debug for Pat { } } +impl Pat { + // FIXME(#19596) this is a workaround, but there should be a better way + fn walk_(&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(&self, mut it: F) -> bool + where F: FnMut(&Pat) -> bool + { + self.walk_(&mut it) + } +} + /// A single field in a struct pattern /// /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` @@ -604,6 +675,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; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] @@ -616,6 +749,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; @@ -625,7 +776,7 @@ impl fmt::Debug for Stmt_ { let spanned = codemap::dummy_spanned(self.clone()); write!(f, "stmt({}: {})", - util::stmt_id(&spanned), + spanned.node.id(), print::stmt_to_string(&spanned)) } } @@ -650,6 +801,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 diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 568986f39c527..cd2dfd4463952 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -950,7 +950,7 @@ impl<'a> State<'a> { pub fn print_variant(&mut self, v: &hir::Variant) -> io::Result<()> { self.head("")?; - let generics = hir::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(hir::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, hir::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, hir::util::binop_to_string(op.node))?; + word(&mut self.s, op.node.as_str())?; self.word_space("=")?; self.print_expr(&rhs)?; } diff --git a/src/librustc/hir/util.rs b/src/librustc/hir/util.rs deleted file mode 100644 index 7745c320e7681..0000000000000 --- a/src/librustc/hir/util.rs +++ /dev/null @@ -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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use hir; -use hir::*; -use hir::intravisit::{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(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_(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) -> 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(), - }), - }], - } -} diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 8324435276926..18c8220192487 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -47,8 +47,8 @@ use syntax::parse::token::InternedString; use syntax::ast; use syntax::attr::ThinAttributesExt; use hir; -use hir::util; use hir::intravisit as hir_visit; +use hir::intravisit::IdVisitor; use syntax::visit as ast_visit; /// Information about the registered lints. @@ -685,9 +685,9 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { } fn visit_ids(&mut self, f: F) - where F: FnOnce(&mut util::IdVisitor) + where F: FnOnce(&mut IdVisitor) { - let mut v = util::IdVisitor::new(self); + let mut v = IdVisitor::new(self); f(&mut v); } } diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 59a3ab44645d9..3ac2c3841346a 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -45,8 +45,7 @@ use syntax::ptr::P; use syntax::parse::token::InternedString; use rustc_back::target::Target; use hir; -use hir::intravisit::Visitor; -use hir::util::IdVisitor; +use hir::intravisit::{IdVisitor, Visitor}; pub use self::DefLike::{DlDef, DlField, DlImpl}; pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown}; diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 47ec7ab5ff05a..1b9673773041b 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -479,7 +479,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { } hir::ExprUnary(op, ref lhs) => { - let pass_args = if hir::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 hir::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!(hir::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); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 8d429ff238420..72d3c9414a408 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -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 hir::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 hir::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); diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 3cd69603b5bfd..3c60d5442285f 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -15,7 +15,6 @@ use util::nodemap::FnvHashMap; use syntax::ast; use hir::{self, PatKind}; -use hir::util::walk_pat; 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(dm: &RefCell, pat: &hir::Pat, mut it: I) where I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned), { - 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(dm: &RefCell, pat: &hir::Pat, mut it: I) where pub fn pat_bindings_ident(dm: &RefCell, pat: &hir::Pat, mut it: I) where I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned), { - 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(dm: &RefCell, 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, 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. @@ -224,7 +223,7 @@ pub fn def_to_path(tcx: &TyCtxt, id: DefId) -> hir::Path { /// Return variants that are necessary to exist for the pattern to match. pub fn necessary_variants(dm: &DefMap, pat: &hir::Pat) -> Vec { let mut variants = vec![]; - walk_pat(pat, |p| { + pat.walk(|p| { match p.node { PatKind::TupleStruct(..) | PatKind::Path(..) | diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 99ebf5ccb845c..f8c0b63bf11bd 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -33,7 +33,6 @@ use syntax::ast::{self, NodeId}; use hir; use hir::intravisit::{self, Visitor, FnKind}; use hir::{Block, Item, FnDecl, Arm, Pat, PatKind, Stmt, Expr, Local}; -use hir::util::stmt_id; #[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 diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index fec327f4aa030..789d7dd9fefb0 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -48,7 +48,6 @@ use rustc::hir; use rustc::hir::{FnDecl, Block}; use rustc::hir::intravisit; use rustc::hir::intravisit::{Visitor, FnKind}; -use rustc::hir::util as hir_util; 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); diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 70781184f74a4..d290652576d84 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -34,8 +34,7 @@ use std::iter::{FromIterator, IntoIterator, repeat}; use rustc::hir; use rustc::hir::{Pat, PatKind}; -use rustc::hir::intravisit::{self, Visitor, FnKind}; -use rustc::hir::util as front_util; +use rustc::hir::intravisit::{self, IdVisitor, Visitor, FnKind}; use rustc_back::slice; use syntax::ast::{self, DUMMY_NODE_ID, NodeId}; @@ -241,7 +240,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 +273,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() => { @@ -518,7 +517,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 +1099,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) => { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index b094bca84103e..574c7af4cfc28 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -30,7 +30,6 @@ use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{self, Span}; use rustc::hir; -use rustc::hir::util::is_shift_binop; register_long_diagnostics! { E0519: r##" @@ -130,7 +129,7 @@ impl LateLintPass for TypeLimits { "comparison is useless due to type limits"); } - if is_shift_binop(binop.node) { + if binop.node.is_shift() { let opt_ty_bits = match cx.tcx.node_id_to_type(l.id).sty { ty::TyInt(t) => Some(int_ty_bits(t, cx.sess().target.int_type)), ty::TyUint(t) => Some(uint_ty_bits(t, cx.sess().target.uint_type)), diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 475ae459fefd5..790833f99ca8a 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -23,7 +23,6 @@ use rustc::middle::pat_util; use rustc::ty::{self, VariantDef, Ty}; use rustc::mir::repr::*; use rustc::hir; -use rustc::hir::util as hir_util; use syntax::ptr::P; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { @@ -150,7 +149,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { hir::ExprAssignOp(op, ref lhs, ref rhs) => { if cx.tcx.is_method_call(self.id) { - let pass_args = if hir_util::is_by_value_binop(op.node) { + let pass_args = if op.node.is_by_value() { PassArgs::ByValue } else { PassArgs::ByRef @@ -172,7 +171,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { hir::ExprBinary(op, ref lhs, ref rhs) => { if cx.tcx.is_method_call(self.id) { - let pass_args = if hir_util::is_by_value_binop(op.node) { + let pass_args = if op.node.is_by_value() { PassArgs::ByValue } else { PassArgs::ByRef diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index bbf8796436efd..c0b8aad1c0913 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -84,7 +84,6 @@ use rustc::hir::{PathSegment, PathParameters}; use rustc::hir::HirVec; use rustc::hir::{TraitRef, Ty, TyBool, TyChar, TyFloat, TyInt}; use rustc::hir::{TyRptr, TyStr, TyUint, TyPath, TyPtr}; -use rustc::hir::util::walk_pat; use std::collections::{HashMap, HashSet}; use std::cell::{Cell, RefCell}; @@ -2244,7 +2243,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // pattern that binds them bindings_list: &mut HashMap) { let pat_id = pattern.id; - walk_pat(pattern, |pattern| { + pattern.walk(|pattern| { match pattern.node { PatKind::Ident(binding_mode, ref path1, ref at_rhs) => { // The meaning of PatKind::Ident with no type parameters diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index d2fc20fd8375f..6714f6440ee4f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -712,7 +712,7 @@ fn cast_shift_rhs(op: hir::BinOp_, G: FnOnce(ValueRef, Type) -> ValueRef { // Shifts may have any size int on the rhs - if hir::util::is_shift_binop(op) { + if op.is_shift() { let mut rhs_llty = val_ty(rhs); let mut lhs_llty = val_ty(lhs); if rhs_llty.kind() == Vector { diff --git a/src/librustc_trans/controlflow.rs b/src/librustc_trans/controlflow.rs index 60ae91a8c5f7c..f3cb4d5001aa5 100644 --- a/src/librustc_trans/controlflow.rs +++ b/src/librustc_trans/controlflow.rs @@ -26,7 +26,6 @@ use expr; use machine; use rustc::hir; -use rustc::hir::util as ast_util; use syntax::ast; use syntax::parse::token::InternedString; @@ -49,7 +48,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, let mut bcx = cx; - let id = ast_util::stmt_id(s); + let id = s.node.id(); let cleanup_debug_loc = debuginfo::get_cleanup_debug_loc_for_ast_node(bcx.ccx(), id, s.span, false); fcx.push_ast_cleanup_scope(cleanup_debug_loc); @@ -70,7 +69,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, } } - bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, ast_util::stmt_id(s)); + bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, s.node.id()); return bcx; } diff --git a/src/librustc_trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs index 477dc0b4b52b1..b98b98813507a 100644 --- a/src/librustc_trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -116,7 +116,7 @@ fn walk_block(cx: &CrateContext, // The interesting things here are statements and the concluding expression. for statement in &block.stmts { - scope_map.insert(hir::util::stmt_id(statement), + scope_map.insert(statement.node.id(), scope_stack.last().unwrap().scope_metadata); match statement.node { diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index f671c2b79636c..7e9c8228f29f4 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -238,7 +238,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, return FunctionDebugContext::FunctionWithoutDebugInfo; } - let empty_generics = hir::util::empty_generics(); + let empty_generics = hir::Generics::empty(); let fnitem = cx.tcx().map.get(fn_ast_id); diff --git a/src/librustc_trans/expr.rs b/src/librustc_trans/expr.rs index 7c2557fb09023..fce8656fb93d8 100644 --- a/src/librustc_trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -1180,7 +1180,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // if not overloaded, would be RvalueDatumExpr let lhs = unpack_datum!(bcx, trans(bcx, &lhs)); let mut rhs = unpack_datum!(bcx, trans(bcx, &rhs_expr)); - if !hir::util::is_by_value_binop(op.node) { + if !op.node.is_by_value() { rhs = unpack_datum!(bcx, auto_ref(bcx, rhs, rhs_expr)); } @@ -1204,7 +1204,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, span_bug!( expr.span, "augmented assignment `{}=` should always be a rvalue_stmt", - hir::util::binop_to_string(op.node)) + op.node.as_str()) } _ => { span_bug!( diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 5c93c17059082..eaf8479585f8d 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -32,7 +32,6 @@ use syntax::ptr::P; use rustc::hir::{self, PatKind}; use rustc::hir::print as pprust; -use rustc::hir::util as hir_util; pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx hir::Pat, @@ -197,7 +196,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, } } PatKind::Ident(_, ref path, _) => { - let path = hir_util::ident_to_path(path.span, path.node); + let path = hir::Path::from_ident(path.span, path.node); check_pat_enum(pcx, pat, &path, Some(&[]), expected, false); } PatKind::TupleStruct(ref path, ref subpats) => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 20b9a75e0e555..c3a42826dbc41 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3987,7 +3987,7 @@ fn check_block_with_expected<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let mut any_err = false; for s in &blk.stmts { check_stmt(fcx, s); - let s_id = hir::util::stmt_id(s); + let s_id = s.node.id(); let s_ty = fcx.node_ty(s_id); if any_diverges && !warned && match s.node { hir::StmtDecl(ref decl, _) => { diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 1af015cdebf90..f7f40e6077f4a 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -23,7 +23,6 @@ use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue}; use syntax::ast; use syntax::parse::token; use rustc::hir; -use rustc::hir::util as hir_util; /// Check a `a = b` pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, @@ -184,12 +183,12 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, if let IsAssign::Yes = is_assign { span_err!(fcx.tcx().sess, lhs_expr.span, E0368, "binary assignment operation `{}=` cannot be applied to type `{}`", - hir_util::binop_to_string(op.node), + op.node.as_str(), lhs_ty); } else { let mut err = struct_span_err!(fcx.tcx().sess, lhs_expr.span, E0369, "binary operation `{}` cannot be applied to type `{}`", - hir_util::binop_to_string(op.node), + op.node.as_str(), lhs_ty); let missing_trait = match op.node { hir::BiAdd => Some("std::ops::Add"), @@ -235,7 +234,7 @@ pub fn check_user_unop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, op: hir::UnOp) -> Ty<'tcx> { - assert!(hir_util::is_by_value_unop(op)); + assert!(op.is_by_value()); match lookup_op_method(fcx, ex, operand_ty, vec![], token::intern(mname), trait_did, operand_expr) { @@ -272,7 +271,7 @@ fn name_and_trait_def_id(fcx: &FnCtxt, hir::BiOr => { span_bug!(op.span, "impossible assignment operation: {}=", - hir_util::binop_to_string(op.node)) + op.node.as_str()) } } } else { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index ed9372acba952..02114c170c44b 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -102,7 +102,6 @@ use syntax::ast; use syntax::codemap::Span; use rustc::hir::intravisit::{self, Visitor}; use rustc::hir::{self, PatKind}; -use rustc::hir::util as hir_util; use self::SubjectNode::Subject; @@ -689,7 +688,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { }, hir::ExprBinary(op, ref lhs, ref rhs) if has_method_map => { - let implicitly_ref_args = !hir_util::is_by_value_binop(op.node); + let implicitly_ref_args = !op.node.is_by_value(); // As `expr_method_call`, but the call is via an // overloaded op. Note that we (sadly) currently use an @@ -716,7 +715,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { } hir::ExprUnary(op, ref lhs) if has_method_map => { - let implicitly_ref_args = !hir_util::is_by_value_unop(op); + let implicitly_ref_args = !op.is_by_value(); // As above. constrain_call(rcx, expr, Some(&lhs), diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 6ac6f1d6e17d1..50f2f27b3d2a2 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -30,7 +30,6 @@ use syntax::ast; use syntax::codemap::{DUMMY_SP, Span}; use rustc::hir::print::pat_to_string; use rustc::hir::intravisit::{self, Visitor}; -use rustc::hir::util as hir_util; use rustc::hir; /////////////////////////////////////////////////////////////////////////// @@ -112,7 +111,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // system. match e.node { hir::ExprBinary(..) => { - if !hir_util::is_by_value_binop(op.node) { + if !op.node.is_by_value() { self.fcx.inh.tables.borrow_mut().adjustments.remove(&lhs.id); } }, @@ -142,7 +141,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> { return; } - self.visit_node_id(ResolvingExpr(s.span), hir_util::stmt_id(s)); + self.visit_node_id(ResolvingExpr(s.span), s.node.id()); intravisit::walk_stmt(self, s); } From 7bebe80bc28ff818c7990061275fa0ad6c8b3686 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 29 Mar 2016 12:12:01 +0300 Subject: [PATCH 3/8] syntax: dismantle ast_util. --- src/librustc/hir/fold.rs | 8 - src/librustc/hir/intravisit.rs | 60 ++- src/librustc/lint/context.rs | 39 +- src/librustc/middle/cstore.rs | 3 +- src/librustc/middle/dataflow.rs | 3 +- src/librustc_borrowck/borrowck/move_data.rs | 4 +- src/librustc_const_eval/check_match.rs | 5 +- src/librustc_metadata/astencode.rs | 17 +- src/librustc_save_analysis/lib.rs | 3 +- src/libsyntax/ast.rs | 17 + src/libsyntax/ast_util.rs | 398 -------------------- src/libsyntax/fold.rs | 8 - src/libsyntax/lib.rs | 1 - src/libsyntax/parse/parser.rs | 20 +- src/libsyntax/test.rs | 16 +- src/libsyntax_ext/deriving/generic/mod.rs | 4 +- 16 files changed, 117 insertions(+), 489 deletions(-) delete mode 100644 src/libsyntax/ast_util.rs diff --git a/src/librustc/hir/fold.rs b/src/librustc/hir/fold.rs index e65f2fc37debf..a6ff716488526 100644 --- a/src/librustc/hir/fold.rs +++ b/src/librustc/hir/fold.rs @@ -908,14 +908,6 @@ pub fn noop_fold_item(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, diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 90fba0c8985dc..d34d66918ca94 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -27,11 +27,13 @@ use syntax::abi::Abi; use syntax::ast::{NodeId, CRATE_NODE_ID, Name, Attribute}; -use syntax::ast_util; 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() @@ -837,6 +839,54 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) { 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, @@ -853,7 +903,7 @@ pub struct IdVisitor<'a, O: 'a> { skip_members: bool, } -impl<'a, O: ast_util::IdVisitingOperation> IdVisitor<'a, O> { +impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> { pub fn new(operation: &'a mut O) -> IdVisitor<'a, O> { IdVisitor { operation: operation, skip_members: false } } @@ -868,7 +918,7 @@ impl<'a, O: ast_util::IdVisitingOperation> IdVisitor<'a, O> { } } -impl<'a, 'v, O: ast_util::IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { +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) @@ -1012,8 +1062,8 @@ pub fn compute_id_range_for_fn_body(fk: FnKind, body: &Block, sp: Span, id: NodeId) - -> ast_util::IdRange { - let mut visitor = ast_util::IdRangeComputingVisitor { result: ast_util::IdRange::max() }; + -> 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 diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 18c8220192487..fd45f58327ffc 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -39,7 +39,6 @@ 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; @@ -48,7 +47,7 @@ use syntax::ast; use syntax::attr::ThinAttributesExt; use hir; use hir::intravisit as hir_visit; -use hir::intravisit::IdVisitor; +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(&mut self, f: F) - where F: FnOnce(&mut ast_util::IdVisitor) - { - let mut v = ast_util::IdVisitor { - operation: self, - visited_outermost: false, - }; - f(&mut v); - } } impl<'a, 'tcx> LateContext<'a, 'tcx> { @@ -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. diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 3ac2c3841346a..a7f415ef2a08a 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -38,14 +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 hir; -use hir::intravisit::{IdVisitor, Visitor}; +use hir::intravisit::{IdVisitor, IdVisitingOperation, Visitor}; pub use self::DefLike::{DlDef, DlField, DlImpl}; pub use self::NativeLibraryKind::{NativeStatic, NativeFramework, NativeUnknown}; diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 99b512141a493..1aaaa4bcd77f6 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -21,12 +21,11 @@ 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 hir; -use hir::intravisit; +use hir::intravisit::{self, IdRange}; use hir::print as pprust; diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 292cfcfeac19c..80e408e9a6e79 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -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::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> { diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index d290652576d84..797580319b2ee 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -34,11 +34,10 @@ use std::iter::{FromIterator, IntoIterator, repeat}; use rustc::hir; use rustc::hir::{Pat, PatKind}; -use rustc::hir::intravisit::{self, IdVisitor, Visitor, FnKind}; +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::hir::fold::{Folder, noop_fold_pat}; use rustc::hir::print::pat_to_string; @@ -460,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); diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 98e73f2902b74..61f35a12df7fb 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -18,6 +18,7 @@ use rustc::session::Session; use rustc::hir; use rustc::hir::fold; use rustc::hir::fold::Folder; +use rustc::hir::intravisit::{IdRange, IdRangeComputingVisitor, IdVisitingOperation}; use common as c; use cstore; @@ -36,7 +37,7 @@ use middle::region; use rustc::ty::subst; use rustc::ty::{self, Ty, TyCtxt}; -use syntax::{ast, ast_util, codemap}; +use syntax::{ast, codemap}; use syntax::ast::NodeIdAssigner; use syntax::ptr::P; @@ -61,8 +62,8 @@ use serialize::EncoderHelpers; struct DecodeContext<'a, 'b, 'tcx: 'a> { tcx: &'a TyCtxt<'tcx>, cdata: &'b cstore::crate_metadata, - from_id_range: ast_util::IdRange, - to_id_range: ast_util::IdRange, + from_id_range: IdRange, + to_id_range: IdRange, // Cache the last used filemap for translating spans as an optimization. last_filemap_index: Cell, } @@ -178,13 +179,13 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, // Enumerating the IDs which appear in an AST fn reserve_id_range(sess: &Session, - from_id_range: ast_util::IdRange) -> ast_util::IdRange { + from_id_range: IdRange) -> IdRange { // Handle the case of an empty range: if from_id_range.empty() { return from_id_range; } let cnt = from_id_range.max - from_id_range.min; let to_id_min = sess.reserve_node_ids(cnt); let to_id_max = to_id_min + cnt; - ast_util::IdRange { min: to_id_min, max: to_id_max } + IdRange { min: to_id_min, max: to_id_max } } impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> { @@ -705,7 +706,7 @@ struct SideTableEncodingIdVisitor<'a, 'b:'a, 'c:'a, 'tcx:'c> { rbml_w: &'a mut Encoder<'b>, } -impl<'a, 'b, 'c, 'tcx> ast_util::IdVisitingOperation for +impl<'a, 'b, 'c, 'tcx> IdVisitingOperation for SideTableEncodingIdVisitor<'a, 'b, 'c, 'tcx> { fn visit_id(&mut self, id: ast::NodeId) { encode_side_tables_for_id(self.ecx, self.rbml_w, id) @@ -1261,8 +1262,8 @@ fn copy_item_types(dcx: &DecodeContext, ii: &InlinedItem, orig_did: DefId) { } } -fn inlined_item_id_range(v: &InlinedItem) -> ast_util::IdRange { - let mut visitor = ast_util::IdRangeComputingVisitor::new(); +fn inlined_item_id_range(v: &InlinedItem) -> IdRange { + let mut visitor = IdRangeComputingVisitor::new(); v.visit_ids(&mut visitor); visitor.result() } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index e65bf5be25648..a4f9720bbe26b 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -39,7 +39,6 @@ use std::fs::{self, File}; use std::path::{Path, PathBuf}; use syntax::ast::{self, NodeId, PatKind}; -use syntax::ast_util; use syntax::codemap::*; use syntax::parse::token::{self, keywords}; use syntax::visit::{self, Visitor}; @@ -670,7 +669,7 @@ impl<'v> Visitor<'v> for PathCollector { ast::BindingMode::ByValue(mt) => mt, }; // collect path for either visit_local or visit_arm - let path = ast_util::ident_to_path(path1.span, path1.node); + let path = ast::Path::from_ident(path1.span, path1.node); self.collected_paths.push((p.id, path, immut, recorder::VarRef)); } _ => {} diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a441f2990cd1a..370dd0dad72db 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -205,6 +205,23 @@ impl fmt::Display for Path { } } +impl Path { + // convert a span and an identifier to the corresponding + // 1-segment path + pub fn from_ident(s: Span, identifier: Ident) -> Path { + Path { + span: s, + global: false, + segments: vec!( + PathSegment { + identifier: identifier, + parameters: PathParameters::none() + } + ), + } + } +} + /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs deleted file mode 100644 index 852b153044fea..0000000000000 --- a/src/libsyntax/ast_util.rs +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use ast::*; -use ast; -use codemap; -use codemap::Span; -use parse::token; -use print::pprust; -use ptr::P; -use visit::{FnKind, Visitor}; -use visit; - -use std::cmp; -use std::u32; - -pub fn path_name_i(idents: &[Ident]) -> String { - // FIXME: Bad copies (#2543 -- same for everything else that says "bad") - idents.iter().map(|i| i.to_string()).collect::>().join("::") -} - -pub fn is_path(e: P) -> bool { - match e.node { ExprKind::Path(..) => true, _ => false } -} - - -// convert a span and an identifier to the corresponding -// 1-segment path -pub fn ident_to_path(s: Span, identifier: Ident) -> Path { - ast::Path { - span: s, - global: false, - segments: vec!( - ast::PathSegment { - identifier: identifier, - parameters: ast::PathParameters::AngleBracketed(ast::AngleBracketedParameterData { - lifetimes: Vec::new(), - types: P::empty(), - bindings: P::empty(), - }) - } - ), - } -} - -// If path is a single segment ident path, return that ident. Otherwise, return -// None. -pub fn path_to_ident(path: &Path) -> Option { - if path.segments.len() != 1 { - return None; - } - - let segment = &path.segments[0]; - if !segment.parameters.is_empty() { - return None; - } - - Some(segment.identifier) -} - -pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P { - let spanned = codemap::Spanned{ span: s, node: i }; - P(Pat { - id: id, - node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), spanned, None), - span: s - }) -} - -/// Generate a "pretty" name for an `impl` from its type and trait. -/// This is designed so that symbols of `impl`'d methods give some -/// hint of where they came from, (previously they would all just be -/// listed as `__extensions__::method_name::hash`, with no indication -/// of the type). -pub fn impl_pretty_name(trait_ref: &Option, ty: Option<&Ty>) -> Ident { - let mut pretty = match ty { - Some(t) => pprust::ty_to_string(t), - None => String::from("..") - }; - - match *trait_ref { - Some(ref trait_ref) => { - pretty.push('.'); - pretty.push_str(&pprust::path_to_string(&trait_ref.path)); - } - None => {} - } - token::gensym_ident(&pretty[..]) -} - -pub fn struct_field_visibility(field: ast::StructField) -> Visibility { - match field.node.kind { - ast::NamedField(_, v) | ast::UnnamedField(v) => v - } -} - -// ______________________________________________________________________ -// Enumerating the IDs which appear in an AST - -#[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); -} - -/// A visitor that applies its operation to all of the node IDs -/// in a visitable thing. - -pub struct IdVisitor<'a, O:'a> { - pub operation: &'a mut O, - pub visited_outermost: bool, -} - -impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> { - 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); - visit::walk_mod(self, module) - } - - fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) { - self.operation.visit_id(foreign_item.id); - visit::walk_foreign_item(self, foreign_item) - } - - fn visit_item(&mut self, item: &Item) { - if self.visited_outermost { - return - } else { - self.visited_outermost = true - } - - self.operation.visit_id(item.id); - match item.node { - ItemKind::Use(ref view_path) => { - match view_path.node { - ViewPathSimple(_, _) | - ViewPathGlob(_) => {} - ViewPathList(_, ref paths) => { - for path in paths { - self.operation.visit_id(path.node.id()) - } - } - } - } - _ => {} - } - - visit::walk_item(self, item); - - self.visited_outermost = false - } - - fn visit_local(&mut self, local: &Local) { - self.operation.visit_id(local.id); - visit::walk_local(self, local) - } - - fn visit_block(&mut self, block: &Block) { - self.operation.visit_id(block.id); - visit::walk_block(self, block) - } - - fn visit_stmt(&mut self, statement: &Stmt) { - self.operation - .visit_id(statement.node.id().expect("attempted to visit unexpanded stmt")); - visit::walk_stmt(self, statement) - } - - fn visit_pat(&mut self, pattern: &Pat) { - self.operation.visit_id(pattern.id); - visit::walk_pat(self, pattern) - } - - fn visit_expr(&mut self, expression: &Expr) { - self.operation.visit_id(expression.id); - visit::walk_expr(self, expression) - } - - fn visit_ty(&mut self, typ: &Ty) { - self.operation.visit_id(typ.id); - visit::walk_ty(self, typ) - } - - fn visit_generics(&mut self, generics: &Generics) { - self.visit_generics_helper(generics); - visit::walk_generics(self, generics) - } - - fn visit_fn(&mut self, - function_kind: visit::FnKind<'v>, - function_declaration: &'v FnDecl, - block: &'v Block, - span: Span, - node_id: NodeId) { - match function_kind { - FnKind::Method(..) if self.visited_outermost => return, - FnKind::Method(..) => self.visited_outermost = true, - _ => {} - } - - self.operation.visit_id(node_id); - - match function_kind { - FnKind::ItemFn(_, generics, _, _, _, _) => { - self.visit_generics_helper(generics) - } - FnKind::Method(_, ref sig, _) => { - self.visit_generics_helper(&sig.generics) - } - FnKind::Closure => {} - } - - for argument in &function_declaration.inputs { - self.operation.visit_id(argument.id) - } - - visit::walk_fn(self, - function_kind, - function_declaration, - block, - span); - - if let FnKind::Method(..) = function_kind { - self.visited_outermost = false; - } - } - - fn visit_struct_field(&mut self, struct_field: &StructField) { - self.operation.visit_id(struct_field.node.id); - visit::walk_struct_field(self, struct_field) - } - - fn visit_variant_data(&mut self, - struct_def: &VariantData, - _: ast::Ident, - _: &ast::Generics, - _: NodeId, - _: Span) { - self.operation.visit_id(struct_def.id()); - visit::walk_struct_def(self, struct_def); - } - - fn visit_trait_item(&mut self, ti: &ast::TraitItem) { - self.operation.visit_id(ti.id); - visit::walk_trait_item(self, ti); - } - - fn visit_impl_item(&mut self, ii: &ast::ImplItem) { - self.operation.visit_id(ii.id); - visit::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); - visit::walk_trait_ref(self, trait_ref); - } -} - -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); - } -} - -/// 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::new(); - let mut id_visitor = IdVisitor { - operation: &mut visitor, - visited_outermost: false, - }; - id_visitor.visit_fn(fk, decl, body, sp, id); - id_visitor.operation.result -} - -/// Returns true if the given pattern consists solely of an identifier -/// and false otherwise. -pub fn pat_is_ident(pat: P) -> bool { - match pat.node { - PatKind::Ident(..) => true, - _ => false, - } -} - -// are two paths equal when compared unhygienically? -// since I'm using this to replace ==, it seems appropriate -// to compare the span, global, etc. fields as well. -pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool { - (a.span.source_equal(&b.span)) - && (a.global == b.global) - && (segments_name_eq(&a.segments[..], &b.segments[..])) -} - -// are two arrays of segments equal when compared unhygienically? -pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool { - a.len() == b.len() && - a.iter().zip(b).all(|(s, t)| { - s.identifier.name == t.identifier.name && - // FIXME #7743: ident -> name problems in lifetime comparison? - // can types contain idents? - s.parameters == t.parameters - }) -} - -#[cfg(test)] -mod tests { - use ast::*; - use super::*; - - fn ident_to_segment(id: Ident) -> PathSegment { - PathSegment {identifier: id, - parameters: PathParameters::none()} - } - - #[test] fn idents_name_eq_test() { - assert!(segments_name_eq( - &[Ident::new(Name(3),SyntaxContext(4)), Ident::new(Name(78),SyntaxContext(82))] - .iter().cloned().map(ident_to_segment).collect::>(), - &[Ident::new(Name(3),SyntaxContext(104)), Ident::new(Name(78),SyntaxContext(182))] - .iter().cloned().map(ident_to_segment).collect::>())); - assert!(!segments_name_eq( - &[Ident::new(Name(3),SyntaxContext(4)), Ident::new(Name(78),SyntaxContext(82))] - .iter().cloned().map(ident_to_segment).collect::>(), - &[Ident::new(Name(3),SyntaxContext(104)), Ident::new(Name(77),SyntaxContext(182))] - .iter().cloned().map(ident_to_segment).collect::>())); - } -} diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 46bcb8067a3b0..55eec16551752 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -21,7 +21,6 @@ use ast::*; use ast; use attr::{ThinAttributes, ThinAttributesExt}; -use ast_util; use codemap::{respan, Span, Spanned}; use parse::token; use ptr::P; @@ -1073,13 +1072,6 @@ pub fn noop_fold_item_simple(Item {id, ident, attrs, node, vis, span} folder: &mut T) -> Item { let id = folder.new_id(id); let node = folder.fold_item_kind(node); - let ident = match node { - // The node may have changed, recompute the "pretty" impl name. - ItemKind::Impl(_, _, _, ref maybe_trait, ref ty, _) => { - ast_util::impl_pretty_name(maybe_trait, Some(&ty)) - } - _ => ident - }; Item { id: id, diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 7f8472f8b2875..ab14e21e251cb 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -91,7 +91,6 @@ pub mod syntax { pub mod abi; pub mod ast; -pub mod ast_util; pub mod attr; pub mod codemap; pub mod config; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 89a504e1ebd60..36f01463205a0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -44,7 +44,6 @@ use ast::{Visibility, WhereClause}; use attr::{ThinAttributes, ThinAttributesExt, AttributesExt}; use ast::{BinOpKind, UnOp}; use ast; -use ast_util::{self, ident_to_path}; use codemap::{self, Span, BytePos, Spanned, spanned, mk_sp, CodeMap}; use errors::{self, DiagnosticBuilder}; use ext::tt::macro_parser; @@ -1577,9 +1576,14 @@ impl<'a> Parser<'a> { pat } else { debug!("parse_arg_general ident_to_pat"); - ast_util::ident_to_pat(ast::DUMMY_NODE_ID, - self.last_span, - special_idents::invalid) + let sp = self.last_span; + let spanned = Spanned { span: sp, node: special_idents::invalid }; + P(Pat { + id: ast::DUMMY_NODE_ID, + node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), + spanned, None), + span: sp + }) }; let t = self.parse_ty_sum()?; @@ -2223,7 +2227,7 @@ impl<'a> Parser<'a> { ctxt: _ }, token::Plain) => { self.bump(); - let path = ast_util::ident_to_path(mk_sp(lo, hi), id); + let path = ast::Path::from_ident(mk_sp(lo, hi), id); ex = ExprKind::Path(None, path); hi = self.last_span.hi; } @@ -3679,7 +3683,7 @@ impl<'a> Parser<'a> { // Parse macro invocation let ident = self.parse_ident()?; let ident_span = self.last_span; - let path = ident_to_path(ident_span, ident); + let path = ast::Path::from_ident(ident_span, ident); self.bump(); let delim = self.expect_open_delim()?; let tts = self.parse_seq_to_end( @@ -5116,7 +5120,7 @@ impl<'a> Parser<'a> { self.expect(&token::OpenDelim(token::Brace))?; self.expect(&token::CloseDelim(token::Brace))?; - Ok((ast_util::impl_pretty_name(&opt_trait, None), + Ok((special_idents::invalid, ItemKind::DefaultImpl(unsafety, opt_trait.unwrap()), None)) } else { if opt_trait.is_some() { @@ -5132,7 +5136,7 @@ impl<'a> Parser<'a> { impl_items.push(self.parse_impl_item()?); } - Ok((ast_util::impl_pretty_name(&opt_trait, Some(&ty)), + Ok((special_idents::invalid, ItemKind::Impl(unsafety, polarity, generics, opt_trait, ty, impl_items), Some(attrs))) } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 81b702e794d77..703b1611540c8 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -18,7 +18,6 @@ use std::iter; use std::slice; use std::mem; use std::vec; -use ast_util::*; use attr::AttrMetaMethods; use attr; use codemap::{DUMMY_SP, Span, ExpnInfo, NameAndSpan, MacroAttribute}; @@ -35,7 +34,7 @@ use fold; use parse::token::{intern, InternedString}; use parse::{token, ParseSess}; use print::pprust; -use {ast, ast_util}; +use ast; use ptr::P; use util::small_vector::SmallVector; @@ -120,8 +119,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { if ident.name != token::special_idents::invalid.name { self.cx.path.push(ident); } - debug!("current path: {}", - ast_util::path_name_i(&self.cx.path)); + debug!("current path: {}", path_name_i(&self.cx.path)); let i = if is_test_fn(&self.cx, &i) || is_bench_fn(&self.cx, &i) { match i.node { @@ -349,7 +347,6 @@ enum HasTestSignature { NotEvenAFunction, } - fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { let has_test_attr = attr::contains_name(&i.attrs, "test"); @@ -576,6 +573,11 @@ fn path_node(ids: Vec ) -> ast::Path { } } +fn path_name_i(idents: &[ast::Ident]) -> String { + // FIXME: Bad copies (#2543 -- same for everything else that says "bad") + idents.iter().map(|i| i.to_string()).collect::>().join("::") +} + fn mk_tests(cx: &TestCtxt) -> P { // The vector of test_descs for this crate let test_descs = mk_test_descs(cx); @@ -645,10 +647,10 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P { // creates $name: $expr let field = |name, expr| ecx.field_imm(span, ecx.ident_of(name), expr); - debug!("encoding {}", ast_util::path_name_i(&path[..])); + debug!("encoding {}", path_name_i(&path[..])); // path to the #[test] function: "foo::bar::baz" - let path_string = ast_util::path_name_i(&path[..]); + let path_string = path_name_i(&path[..]); let name_expr = ecx.expr_str(span, token::intern_and_get_ident(&path_string[..])); // self::test::StaticTestName($name_expr) diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 7d452b14dae84..37c77ec5b2fc9 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -194,7 +194,6 @@ use std::vec; use syntax::abi::Abi; use syntax::ast::{self, EnumDef, Expr, Ident, Generics, VariantData, BinOpKind, PatKind}; -use syntax::ast_util; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{ExtCtxt, Annotatable}; @@ -620,7 +619,6 @@ impl<'a> TraitDef<'a> { // Just mark it now since we know that it'll end up used downstream attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); - let ident = ast_util::impl_pretty_name(&opt_trait_ref, Some(&self_type)); let unused_qual = cx.attribute( self.span, cx.meta_list(self.span, @@ -638,7 +636,7 @@ impl<'a> TraitDef<'a> { cx.item( self.span, - ident, + special_idents::invalid, a, ast::ItemKind::Impl(unsafety, ast::ImplPolarity::Positive, From ffca6c3e155cb6033b1f749d0ba1be32dfc4d22a Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 29 Mar 2016 12:54:26 +0300 Subject: [PATCH 4/8] rustc: move middle::{def,def_id,pat_util} to hir. --- src/librustc/cfg/construct.rs | 4 ++-- src/librustc/dep_graph/mod.rs | 2 +- src/librustc/{middle => hir}/def.rs | 2 +- src/librustc/{middle => hir}/def_id.rs | 0 src/librustc/hir/map/collector.rs | 2 +- src/librustc/hir/map/definitions.rs | 2 +- src/librustc/hir/map/mod.rs | 2 +- src/librustc/hir/mod.rs | 3 +++ src/librustc/{middle => hir}/pat_util.rs | 4 ++-- src/librustc/infer/error_reporting.rs | 4 ++-- src/librustc/infer/mod.rs | 2 +- src/librustc/infer/type_variable.rs | 2 +- src/librustc/lib.rs | 3 --- src/librustc/middle/astconv_util.rs | 2 +- src/librustc/middle/const_val.rs | 2 +- src/librustc/middle/cstore.rs | 6 +++--- src/librustc/middle/dead.rs | 8 ++++---- src/librustc/middle/effect.rs | 2 +- src/librustc/middle/entry.rs | 2 +- src/librustc/middle/expr_use_visitor.rs | 6 +++--- src/librustc/middle/intrinsicck.rs | 4 ++-- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/liveness.rs | 4 ++-- src/librustc/middle/mem_categorization.rs | 4 ++-- src/librustc/middle/reachable.rs | 4 ++-- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/stability.rs | 4 ++-- src/librustc/mir/repr.rs | 2 +- src/librustc/mir/visit.rs | 2 +- src/librustc/traits/coherence.rs | 2 +- src/librustc/traits/error_reporting.rs | 2 +- src/librustc/traits/mod.rs | 2 +- src/librustc/traits/object_safety.rs | 2 +- src/librustc/traits/project.rs | 2 +- src/librustc/traits/select.rs | 2 +- src/librustc/traits/specialize/mod.rs | 2 +- src/librustc/traits/specialize/specialization_graph.rs | 2 +- src/librustc/traits/util.rs | 2 +- src/librustc/ty/contents.rs | 2 +- src/librustc/ty/context.rs | 4 ++-- src/librustc/ty/error.rs | 2 +- src/librustc/ty/fast_reject.rs | 2 +- src/librustc/ty/item_path.rs | 2 +- src/librustc/ty/maps.rs | 2 +- src/librustc/ty/mod.rs | 4 ++-- src/librustc/ty/relate.rs | 2 +- src/librustc/ty/sty.rs | 2 +- src/librustc/ty/subst.rs | 2 +- src/librustc/ty/trait_def.rs | 2 +- src/librustc/ty/util.rs | 4 ++-- src/librustc/ty/wf.rs | 2 +- src/librustc/util/nodemap.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_borrowck/borrowck/fragments.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_const_eval/check_match.rs | 6 +++--- src/librustc_const_eval/eval.rs | 6 +++--- src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 4 ++-- src/librustc_lint/types.rs | 2 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/astencode.rs | 4 ++-- src/librustc_metadata/csearch.rs | 4 ++-- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/decoder.rs | 4 ++-- src/librustc_metadata/encoder.rs | 4 ++-- src/librustc_metadata/index.rs | 2 +- src/librustc_metadata/tls_context.rs | 2 +- src/librustc_metadata/tydecode.rs | 2 +- src/librustc_metadata/tyencode.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 4 ++-- src/librustc_mir/hair/cx/mod.rs | 2 +- src/librustc_mir/hair/cx/pattern.rs | 4 ++-- src/librustc_mir/hair/mod.rs | 2 +- src/librustc_passes/consts.rs | 4 ++-- src/librustc_passes/static_recursion.rs | 2 +- src/librustc_privacy/lib.rs | 4 ++-- src/librustc_resolve/build_reduced_graph.rs | 4 ++-- src/librustc_resolve/lib.rs | 8 ++++---- src/librustc_resolve/resolve_imports.rs | 2 +- src/librustc_save_analysis/csv_dumper.rs | 2 +- src/librustc_save_analysis/data.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 4 ++-- src/librustc_save_analysis/lib.rs | 4 ++-- src/librustc_trans/_match.rs | 6 +++--- src/librustc_trans/assert_dep_graph.rs | 2 +- src/librustc_trans/back/symbol_names.rs | 2 +- src/librustc_trans/base.rs | 4 ++-- src/librustc_trans/callee.rs | 2 +- src/librustc_trans/closure.rs | 2 +- src/librustc_trans/collector.rs | 2 +- src/librustc_trans/common.rs | 4 ++-- src/librustc_trans/consts.rs | 4 ++-- src/librustc_trans/context.rs | 4 ++-- src/librustc_trans/controlflow.rs | 2 +- src/librustc_trans/debuginfo/create_scope_map.rs | 2 +- src/librustc_trans/debuginfo/metadata.rs | 4 ++-- src/librustc_trans/debuginfo/mod.rs | 2 +- src/librustc_trans/debuginfo/namespace.rs | 2 +- src/librustc_trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/debuginfo/utils.rs | 2 +- src/librustc_trans/expr.rs | 2 +- src/librustc_trans/inline.rs | 2 +- src/librustc_trans/meth.rs | 2 +- src/librustc_trans/monomorphize.rs | 2 +- src/librustc_trans/type_of.rs | 2 +- src/librustc_typeck/astconv.rs | 4 ++-- src/librustc_typeck/check/_match.rs | 6 +++--- src/librustc_typeck/check/callee.rs | 4 ++-- src/librustc_typeck/check/cast.rs | 2 +- src/librustc_typeck/check/dropck.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 4 ++-- src/librustc_typeck/check/method/suggest.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 6 +++--- src/librustc_typeck/check/op.rs | 2 +- src/librustc_typeck/check/regionck.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 2 +- src/librustc_typeck/check/writeback.rs | 4 ++-- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/coherence/orphan.rs | 2 +- src/librustc_typeck/coherence/overlap.rs | 2 +- src/librustc_typeck/collect.rs | 4 ++-- src/librustc_typeck/lib.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustdoc/clean/inline.rs | 4 ++-- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/clean/simplify.rs | 2 +- src/librustdoc/core.rs | 2 +- src/librustdoc/html/format.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/passes.rs | 2 +- 133 files changed, 190 insertions(+), 190 deletions(-) rename src/librustc/{middle => hir}/def.rs (99%) rename src/librustc/{middle => hir}/def_id.rs (100%) rename src/librustc/{middle => hir}/pat_util.rs (99%) diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 13c3e3895b5d0..7049749135565 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -10,8 +10,8 @@ use rustc_data_structures::graph; use cfg::*; -use middle::def::Def; -use middle::pat_util; +use hir::def::Def; +use hir::pat_util; use ty::{self, TyCtxt}; use syntax::ast; use syntax::ptr::P; diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index 70e7f675fcea9..55ec56a4bbe66 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -9,7 +9,7 @@ // except according to those terms. use self::thread::{DepGraphThreadData, DepMessage}; -use middle::def_id::DefId; +use hir::def_id::DefId; use syntax::ast::NodeId; use ty::TyCtxt; use hir; diff --git a/src/librustc/middle/def.rs b/src/librustc/hir/def.rs similarity index 99% rename from src/librustc/middle/def.rs rename to src/librustc/hir/def.rs index ee6e747a85554..c270a4413bfaf 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/hir/def.rs @@ -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::ParamSpace; use util::nodemap::NodeMap; use syntax::ast; diff --git a/src/librustc/middle/def_id.rs b/src/librustc/hir/def_id.rs similarity index 100% rename from src/librustc/middle/def_id.rs rename to src/librustc/hir/def_id.rs diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 62c80c9c8bbc3..b1a084ac7994e 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -13,7 +13,7 @@ use super::MapEntry::*; use hir::*; use hir::intravisit::Visitor; -use middle::def_id::{CRATE_DEF_INDEX, DefId, DefIndex}; +use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex}; use std::iter::repeat; use syntax::ast::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID}; use syntax::codemap::Span; diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 82574b852297a..d045313cb1e97 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -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; diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 4325be9b9a43b..4096606b001d6 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -19,7 +19,7 @@ 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}; diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index cb3cdd0b8258d..10fe86246de69 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -63,10 +63,13 @@ macro_rules! hir_vec { } pub mod check_attr; +pub mod def; +pub mod def_id; pub mod fold; pub mod intravisit; pub mod lowering; pub mod map; +pub mod pat_util; pub mod print; pub mod svh; diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/hir/pat_util.rs similarity index 99% rename from src/librustc/middle/pat_util.rs rename to src/librustc/hir/pat_util.rs index 3c60d5442285f..5eb4d53ea6ac7 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -8,8 +8,8 @@ // 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; diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index c0c63ac5042fb..5a0d9ec13322f 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -78,8 +78,8 @@ 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; diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 427ff88b8f24b..4c1216aa8626a 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -18,7 +18,7 @@ pub use ty::IntVarValue; pub use self::freshen::TypeFreshener; pub use self::region_inference::{GenericKind, VerifyBound}; -use middle::def_id::DefId; +use hir::def_id::DefId; use hir; use middle::free_region::FreeRegionMap; use middle::mem_categorization as mc; diff --git a/src/librustc/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index 3cc076f1f00be..c2a8d04ac00da 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -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; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 291eab30decbf..deb2062777220 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -86,8 +86,6 @@ pub mod middle { pub mod cstore; pub mod dataflow; pub mod dead; - pub mod def; - pub mod def_id; pub mod dependency_format; pub mod effect; pub mod entry; @@ -96,7 +94,6 @@ pub mod middle { pub mod lang_items; pub mod liveness; pub mod mem_categorization; - pub mod pat_util; pub mod privacy; pub mod reachable; pub mod region; diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index 871440a7e54ff..2a27732b9532c 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -14,7 +14,7 @@ * Almost certainly this could (and should) be refactored out of existence. */ -use middle::def::Def; +use hir::def::Def; use ty::{Ty, TyCtxt}; use syntax::codemap::Span; diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs index a939389c460ea..3621cb267d91f 100644 --- a/src/librustc/middle/const_val.rs +++ b/src/librustc/middle/const_val.rs @@ -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::*; diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index a7f415ef2a08a..027792b743995 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -24,10 +24,10 @@ use hir::svh::Svh; use hir::map as hir_map; -use middle::def::{self, Def}; +use hir::def::{self, Def}; use middle::lang_items; use ty::{self, Ty, TyCtxt, VariantKind}; -use middle::def_id::{DefId, DefIndex}; +use hir::def_id::{DefId, DefIndex}; use mir::repr::Mir; use mir::mir_map::MirMap; use session::Session; @@ -504,7 +504,7 @@ pub mod tls { use std::mem; use ty::{self, Ty, TyCtxt}; use ty::subst::Substs; - use middle::def_id::DefId; + use hir::def_id::DefId; pub trait EncodingContext<'tcx> { fn tcx<'a>(&'a self) -> &'a TyCtxt<'tcx>; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index b7b6279270cb4..dcdc02c9df609 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -14,13 +14,13 @@ use dep_graph::DepNode; use hir::map as ast_map; -use hir::{self, PatKind}; +use hir::{self, pat_util, PatKind}; use hir::intravisit::{self, Visitor}; -use middle::{pat_util, privacy}; +use middle::privacy; use ty::{self, TyCtxt}; -use middle::def::Def; -use middle::def_id::{DefId}; +use hir::def::Def; +use hir::def_id::{DefId}; use lint; use std::collections::HashSet; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index e4c93dfdb9319..ac7a1b8aa0de5 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -13,7 +13,7 @@ use self::RootUnsafeContext::*; use dep_graph::DepNode; -use middle::def::Def; +use hir::def::Def; use ty::{self, Ty, TyCtxt}; use ty::MethodCall; diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 4a64980fcdd5a..602889375e970 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -11,7 +11,7 @@ use dep_graph::DepNode; use hir::map as ast_map; -use middle::def_id::{CRATE_DEF_INDEX}; +use hir::def_id::{CRATE_DEF_INDEX}; use session::{config, Session}; use syntax::ast::NodeId; use syntax::attr; diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 1b9673773041b..c4d6f100671b0 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -19,9 +19,9 @@ 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}; diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 354a6c5e13bca..767c5adc81e25 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -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}; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 7aad106c4ed44..86531ced8dfae 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -25,7 +25,7 @@ use dep_graph::DepNode; 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; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 72d3c9414a408..35991ae56c8a1 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -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; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 7260bdde3ee71..2f77552c389ad 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -71,11 +71,11 @@ pub use self::deref_kind::*; use self::Aliasability::*; -use middle::def_id::DefId; +use hir::def_id::DefId; use hir::map as ast_map; use infer; use middle::const_qualif::ConstQualif; -use middle::def::Def; +use hir::def::Def; use ty::adjustment; use ty::{self, Ty, TyCtxt}; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 8c44594c1f783..63bccc2d02eb6 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -17,8 +17,8 @@ use dep_graph::DepNode; use hir::map as ast_map; -use middle::def::Def; -use middle::def_id::DefId; +use hir::def::Def; +use hir::def_id::DefId; use ty::{self, TyCtxt}; use middle::privacy; use session::config; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 1275753a3406b..585b65b9f5e42 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -21,7 +21,7 @@ use self::ScopeChain::*; use dep_graph::DepNode; use hir::map::Map; use session::Session; -use middle::def::{Def, DefMap}; +use hir::def::{Def, DefMap}; use middle::region; use ty::subst; use ty; diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index ffb4a791363c4..6c7c7f160f4e5 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -18,8 +18,8 @@ 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; diff --git a/src/librustc/mir/repr.rs b/src/librustc/mir/repr.rs index 1b24b4f6210bb..28437fa13368a 100644 --- a/src/librustc/mir/repr.rs +++ b/src/librustc/mir/repr.rs @@ -11,7 +11,7 @@ use graphviz::IntoCow; use middle::const_val::ConstVal; use rustc_const_math::{ConstUsize, ConstInt}; -use middle::def_id::DefId; +use hir::def_id::DefId; use ty::subst::Substs; use ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty}; use util::ppaux; diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 403c749fe4bcb..ae803f502318e 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -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::*; diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index a0ac514852674..6710d2a653c84 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -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}; diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f15b9ee44ce52..9357dda258364 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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; diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 867bd054fa9dd..a160465e2e815 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -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}; diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 7cd2ac5938d41..9af2cfbd04da0 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -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}; diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index d4d61ec024471..a0d6f5f912b2c 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -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}; diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 97c9caadd5237..8d7df6e44aeb7 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -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}; diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 88f4129d8860c..63647515a9785 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -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}; diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index d3146697ee627..51b0b6b8b3830 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -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}; diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index befca878bc0e4..7668b8bf20282 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -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}; diff --git a/src/librustc/ty/contents.rs b/src/librustc/ty/contents.rs index ba237184a9f1d..f5dedb1324801 100644 --- a/src/librustc/ty/contents.rs +++ b/src/librustc/ty/contents.rs @@ -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; diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fa5a7f3ca692d..14ffeadbb3a22 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -16,8 +16,8 @@ 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; diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e6b7b49ea573c..73bafc5e850b9 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -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}; diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 0865e059f59c5..29647253ad2ad 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -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; diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 0648450d8331b..4d88b6974166e 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -10,7 +10,7 @@ use hir::map::DefPathData; use middle::cstore::LOCAL_CRATE; -use middle::def_id::{DefId, CRATE_DEF_INDEX}; +use hir::def_id::{DefId, CRATE_DEF_INDEX}; use ty::{self, Ty, TyCtxt}; use syntax::ast; diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 77b6b03e48fe9..65a96e79ff43c 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -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; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 69a6a6aa920f3..2f0b520d84276 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -23,8 +23,8 @@ use hir::map as ast_map; use hir::map::LinkedPath; use middle; use middle::cstore::{self, CrateStore, LOCAL_CRATE}; -use middle::def::{self, Def, ExportMap}; -use middle::def_id::DefId; +use hir::def::{self, Def, ExportMap}; +use hir::def_id::DefId; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; use middle::region::{CodeExtent}; use traits; diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index b1bff9b43ccce..f14e680e9e06f 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -13,7 +13,7 @@ //! can be other things. Examples of type relations are subtyping, //! type equality, etc. -use middle::def_id::DefId; +use hir::def_id::DefId; use ty::subst::{ParamSpace, Substs}; use ty::{self, Ty, TyCtxt, TypeFoldable}; use ty::error::{ExpectedFound, TypeError}; diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 101c8501bd3dd..c0fb60d4dd3dc 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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; diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 93157f28482a5..dd547da59e9cf 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -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}; diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 0eb70f93bed30..94f4e31efc665 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -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; diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 710cd2e301c09..354744b27875d 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -11,10 +11,10 @@ //! misc. type-system utilities too small to deserve their own file use hir::svh::Svh; -use middle::def_id::DefId; +use hir::def_id::DefId; use ty::subst; use infer; -use middle::pat_util; +use hir::pat_util; use traits::{self, ProjectionMode}; use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable}; use ty::{Disr, ParameterEnvironment}; diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index e6c4e90babbf5..9ea634bb41c1b 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -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; diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 4a45797602d81..69bcc9cbfffea 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -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; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index c386a670ba256..a84a42fc2b535 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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}; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index d1b30bb2746c9..0b1c4efa9ac04 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -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; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 789d7dd9fefb0..d7c928b8d6e1f 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -28,7 +28,7 @@ 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; diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 797580319b2ee..1e662d456d141 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -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; diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index dba31ddef95dd..45a90bf00681c 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -19,9 +19,9 @@ 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; diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index ed9c66a188275..d10691d12ed97 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -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}; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6f11ebafa86ec..fe10ca87b7542 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -28,9 +28,9 @@ //! Use the former for unit-like structs and the latter for structs with //! a `pub fn new()`. -use middle::def::Def; +use rustc::hir::def::Def; use middle::cstore::CrateStore; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use middle::stability; use rustc::{cfg, infer}; use rustc::ty::subst::Substs; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 574c7af4cfc28..891731cb29604 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -10,7 +10,7 @@ #![allow(non_snake_case)] -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, TyCtxt}; diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index f531628601b0f..d1595f243c9bf 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::pat_util; +use rustc::hir::pat_util; use rustc::ty; use rustc::ty::adjustment; use util::nodemap::FnvHashMap; diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 61f35a12df7fb..df60e35d0f3d3 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -31,8 +31,8 @@ use middle::cstore::{InlinedItem, InlinedItemRef}; use rustc::ty::adjustment; use rustc::ty::cast; use middle::const_qualif::ConstQualif; -use middle::def::{self, Def}; -use middle::def_id::DefId; +use rustc::hir::def::{self, Def}; +use rustc::hir::def_id::DefId; use middle::region; use rustc::ty::subst; use rustc::ty::{self, Ty, TyCtxt}; diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index c9e661dec510e..bb691cebccd12 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -15,10 +15,10 @@ use loader; use middle::cstore::{CrateStore, CrateSource, ChildItem, ExternCrate, FoundAst, DefLike}; use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference}; -use middle::def; +use rustc::hir::def; use middle::lang_items; use rustc::ty::{self, Ty, TyCtxt, VariantKind}; -use middle::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; +use rustc::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; use rustc::hir::map as hir_map; use rustc::mir::repr::Mir; diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 3a6cd4d832b9a..d5a9adafe7dca 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -20,10 +20,10 @@ use decoder; use index; use loader; +use rustc::hir::def_id::DefId; use rustc::hir::svh::Svh; use rustc::middle::cstore::{ExternCrate}; use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap}; -use rustc::middle::def_id::DefId; use std::cell::{RefCell, Ref, Cell}; use std::rc::Rc; diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 5aafd015f9a1c..e6f538255ac26 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -29,8 +29,8 @@ use rustc::hir; use middle::cstore::{LOCAL_CRATE, FoundAst, InlinedItem, LinkagePreference}; use middle::cstore::{DefLike, DlDef, DlField, DlImpl, tls}; -use middle::def::Def; -use middle::def_id::{DefId, DefIndex}; +use rustc::hir::def::Def; +use rustc::hir::def_id::{DefId, DefIndex}; use middle::lang_items; use rustc::ty::subst; use rustc::ty::{ImplContainer, TraitContainer}; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index dc21ebcbcfcbd..83ffd8afbeb01 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -21,8 +21,8 @@ use tyencode; use index::{self, IndexData}; use middle::cstore::{LOCAL_CRATE, CrateStore, InlinedItemRef, LinkMeta, tls}; -use middle::def; -use middle::def_id::{CRATE_DEF_INDEX, DefId}; +use rustc::hir::def; +use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use middle::dependency_format::Linkage; use middle::stability; use rustc::ty::subst; diff --git a/src/librustc_metadata/index.rs b/src/librustc_metadata/index.rs index 60bbdaddd7516..9c066f9f5f1f1 100644 --- a/src/librustc_metadata/index.rs +++ b/src/librustc_metadata/index.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::def_id::{DefId, DefIndex}; +use rustc::hir::def_id::{DefId, DefIndex}; use rbml; use std::io::{Cursor, Write}; use std::slice; diff --git a/src/librustc_metadata/tls_context.rs b/src/librustc_metadata/tls_context.rs index 6ecd7a7f50ad8..782c7cba26ec5 100644 --- a/src/librustc_metadata/tls_context.rs +++ b/src/librustc_metadata/tls_context.rs @@ -14,7 +14,7 @@ use rbml::opaque::Encoder as OpaqueEncoder; use rbml::opaque::Decoder as OpaqueDecoder; use rustc::middle::cstore::tls; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::subst::Substs; use rustc::ty::{self, TyCtxt}; diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index cd63b58372b32..3004246d1d7e7 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -18,7 +18,7 @@ use rustc::hir; -use middle::def_id::{DefId, DefIndex}; +use rustc::hir::def_id::{DefId, DefIndex}; use middle::region; use rustc::ty::subst; use rustc::ty::subst::VecPerParamSpace; diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index b5079256487de..f49c2e22c6a80 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -17,7 +17,7 @@ use std::cell::RefCell; use std::io::Cursor; use std::io::prelude::*; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use middle::region; use rustc::ty::subst; use rustc::ty::subst::VecPerParamSpace; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 790833f99ca8a..7f748ef9b1ea7 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -15,11 +15,11 @@ use hair::cx::Cx; use hair::cx::block; use hair::cx::to_ref::ToRef; use rustc::hir::map; -use rustc::middle::def::Def; +use rustc::hir::def::Def; use rustc::middle::const_val::ConstVal; use rustc_const_eval as const_eval; use rustc::middle::region::CodeExtent; -use rustc::middle::pat_util; +use rustc::hir::pat_util; use rustc::ty::{self, VariantDef, Ty}; use rustc::mir::repr::*; use rustc::hir; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index f0c6887802d63..c3a5fbd967c84 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -20,7 +20,7 @@ use rustc::mir::repr::*; use rustc::middle::const_val::ConstVal; use rustc_const_eval as const_eval; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::ty::subst::{Subst, Substs}; use rustc::ty::{self, Ty, TyCtxt}; diff --git a/src/librustc_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index 673d12c33167a..990ba9e786c30 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -12,8 +12,8 @@ use hair::*; use hair::cx::Cx; use rustc_data_structures::fnv::FnvHashMap; use rustc_const_eval as const_eval; -use rustc::middle::def::Def; -use rustc::middle::pat_util::{pat_is_resolved_const, pat_is_binding}; +use rustc::hir::def::Def; +use rustc::hir::pat_util::{pat_is_resolved_const, pat_is_binding}; use rustc::ty::{self, Ty}; use rustc::mir::repr::*; use rustc::hir::{self, PatKind}; diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 0ea8dece47c7b..51f2cc2687a99 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -17,7 +17,7 @@ use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, TypedConstVal}; use rustc::middle::const_val::ConstVal; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::middle::region::CodeExtent; use rustc::ty::subst::Substs; use rustc::ty::{self, AdtDef, ClosureSubsts, Region, Ty}; diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 38784191a7828..4659bb389dc6b 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -30,8 +30,8 @@ use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, compare_lit_exprs}; use rustc_const_eval::{eval_const_expr_partial, lookup_const_by_id}; use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal}; use rustc_const_eval::EvalHint::ExprTypeChecked; -use rustc::middle::def::Def; -use rustc::middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::middle::expr_use_visitor as euv; use rustc::infer; use rustc::middle::mem_categorization as mc; diff --git a/src/librustc_passes/static_recursion.rs b/src/librustc_passes/static_recursion.rs index 2766d13d7b8ab..245960a04f030 100644 --- a/src/librustc_passes/static_recursion.rs +++ b/src/librustc_passes/static_recursion.rs @@ -14,7 +14,7 @@ use rustc::dep_graph::DepNode; use rustc::hir::map as ast_map; use rustc::session::{Session, CompileResult}; -use rustc::middle::def::{Def, DefMap}; +use rustc::hir::def::{Def, DefMap}; use rustc::util::nodemap::NodeMap; use syntax::{ast}; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 908a7869c4297..8840bd4271781 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -35,8 +35,8 @@ use rustc::hir::intravisit::{self, Visitor}; use rustc::dep_graph::DepNode; use rustc::lint; use rustc::middle::cstore::CrateStore; -use rustc::middle::def::{self, Def}; -use rustc::middle::def_id::DefId; +use rustc::hir::def::{self, Def}; +use rustc::hir::def_id::DefId; use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::ty::{self, TyCtxt}; use rustc::util::nodemap::NodeSet; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 470fd88025e4e..a422b09f96bf2 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -24,8 +24,8 @@ use {resolve_error, resolve_struct_error, ResolutionError}; use rustc::middle::cstore::{CrateStore, ChildItem, DlDef}; use rustc::lint; -use rustc::middle::def::*; -use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; +use rustc::hir::def::*; +use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::ty::VariantKind; use syntax::ast::Name; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c0b8aad1c0913..502b45c945347 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -52,9 +52,9 @@ use rustc::hir::map as hir_map; use rustc::session::Session; use rustc::lint; use rustc::middle::cstore::CrateStore; -use rustc::middle::def::*; -use rustc::middle::def_id::DefId; -use rustc::middle::pat_util::pat_bindings; +use rustc::hir::def::*; +use rustc::hir::def_id::DefId; +use rustc::hir::pat_util::pat_bindings; use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace}; use rustc::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, FnvHashMap}; @@ -2570,7 +2570,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } /// Skips `path_depth` trailing segments, which is also reflected in the - /// returned value. See `middle::def::PathResolution` for more info. + /// returned value. See `hir::def::PathResolution` for more info. fn resolve_path(&mut self, id: NodeId, path: &Path, path_depth: usize, namespace: Namespace) -> Option { let span = path.span; diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 2aa8925fb54b5..738a99fbe9200 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -22,7 +22,7 @@ use {names_to_string, module_to_string}; use {resolve_error, ResolutionError}; use rustc::lint; -use rustc::middle::def::*; +use rustc::hir::def::*; use syntax::ast::{NodeId, Name}; use syntax::attr::AttrMetaMethods; diff --git a/src/librustc_save_analysis/csv_dumper.rs b/src/librustc_save_analysis/csv_dumper.rs index 3021d4e9820b7..0e02830db7ad7 100644 --- a/src/librustc_save_analysis/csv_dumper.rs +++ b/src/librustc_save_analysis/csv_dumper.rs @@ -10,7 +10,7 @@ use std::io::Write; -use rustc::middle::def_id::{DefId, DefIndex}; +use rustc::hir::def_id::{DefId, DefIndex}; use syntax::codemap::Span; use super::data::*; diff --git a/src/librustc_save_analysis/data.rs b/src/librustc_save_analysis/data.rs index 649c8387eb37c..7f2f2618c3c96 100644 --- a/src/librustc_save_analysis/data.rs +++ b/src/librustc_save_analysis/data.rs @@ -15,7 +15,7 @@ use std::hash::Hasher; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty; use syntax::ast::{CrateNum, NodeId}; use syntax::codemap::Span; diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 310747c89914a..c724091a2ec87 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -27,8 +27,8 @@ //! is used for recording the output in a format-agnostic way (see CsvDumper //! for an example). -use rustc::middle::def::Def; -use rustc::middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::session::Session; use rustc::ty::{self, TyCtxt}; diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index a4f9720bbe26b..98c0be1c93c15 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -29,8 +29,8 @@ use rustc::hir::{self, lowering}; use rustc::hir::map::NodeItem; -use rustc::middle::def::Def; -use rustc::middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::session::config::CrateType::CrateTypeExecutable; use rustc::ty::{self, TyCtxt}; diff --git a/src/librustc_trans/_match.rs b/src/librustc_trans/_match.rs index 3bbead9847bdd..d8b8f9f08067c 100644 --- a/src/librustc_trans/_match.rs +++ b/src/librustc_trans/_match.rs @@ -191,14 +191,14 @@ use self::FailureHandler::*; use llvm::{ValueRef, BasicBlockRef}; use rustc_const_eval::check_match::{self, StaticInliner}; use rustc_const_eval::{compare_lit_exprs, eval_const_expr}; -use middle::def::{Def, DefMap}; -use middle::def_id::DefId; +use rustc::hir::def::{Def, DefMap}; +use rustc::hir::def_id::DefId; use middle::expr_use_visitor as euv; use rustc::infer; use middle::lang_items::StrEqFnLangItem; use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; -use middle::pat_util::*; +use rustc::hir::pat_util::*; use rustc::ty::subst::Substs; use adt; use base::*; diff --git a/src/librustc_trans/assert_dep_graph.rs b/src/librustc_trans/assert_dep_graph.rs index ecbb504944330..932f66f17cc7b 100644 --- a/src/librustc_trans/assert_dep_graph.rs +++ b/src/librustc_trans/assert_dep_graph.rs @@ -39,7 +39,7 @@ use graphviz as dot; use rustc::dep_graph::{DepGraphQuery, DepNode}; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::TyCtxt; use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet}; use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex}; diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index 949a10297c1e2..8127d1c0e29ab 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -102,7 +102,7 @@ use monomorphize::Instance; use util::sha2::{Digest, Sha256}; use rustc::middle::cstore; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::{self, TypeFoldable}; use rustc::ty::item_path::{ItemPathBuffer, RootMode}; use rustc::hir::map::definitions::{DefPath, DefPathData}; diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 6714f6440ee4f..4f1585eeaca3b 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -36,11 +36,11 @@ use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param}; use llvm; use rustc::cfg; use middle::cstore::CrateStore; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem}; use middle::weak_lang_items; -use middle::pat_util::simple_name; +use rustc::hir::pat_util::simple_name; use rustc::ty::subst::{self, Substs}; use rustc::traits; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; diff --git a/src/librustc_trans/callee.rs b/src/librustc_trans/callee.rs index 2da9acf325089..392c40a60155c 100644 --- a/src/librustc_trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -21,7 +21,7 @@ use arena::TypedArena; use back::symbol_names; use llvm::{self, ValueRef, get_params}; use middle::cstore::LOCAL_CRATE; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::ty::subst; use rustc::ty::subst::{Substs}; diff --git a/src/librustc_trans/closure.rs b/src/librustc_trans/closure.rs index 579848919ecb9..6bd5fd355a731 100644 --- a/src/librustc_trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -11,7 +11,7 @@ use arena::TypedArena; use back::symbol_names; use llvm::{ValueRef, get_param, get_params}; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::traits::ProjectionMode; use abi::{Abi, FnType}; diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 4f197dbee1315..c72a1a6bef32f 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -192,7 +192,7 @@ use rustc::hir; use rustc::hir::intravisit as hir_visit; use rustc::hir::map as hir_map; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::middle::lang_items::{ExchangeFreeFnLangItem, ExchangeMallocFnLangItem}; use rustc::traits; use rustc::ty::subst::{self, Substs, Subst}; diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 1f48eb916039b..5ce7caf5deb06 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -17,8 +17,8 @@ use llvm; use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind}; use llvm::{True, False, Bool, OperandBundleDef}; use rustc::cfg; -use middle::def::Def; -use middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::infer; use middle::lang_items::LangItem; use rustc::ty::subst::Substs; diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 7945639f86b32..89f3b295c8d22 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -15,8 +15,8 @@ use llvm::{InternalLinkage, ValueRef, Bool, True}; use middle::const_qualif::ConstQualif; use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, lookup_const_by_id, ErrKind}; use rustc_const_eval::eval_repeat_count; -use middle::def::Def; -use middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::hir::map as hir_map; use {abi, adt, closure, debuginfo, expr, machine}; use base::{self, exported_name, imported_name, push_ctxt}; diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 3574883c5f588..9bbc72eba36ef 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -12,8 +12,8 @@ use llvm; use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef}; use rustc::dep_graph::{DepNode, DepTrackingMap, DepTrackingMapConfig}; use middle::cstore::LinkMeta; -use middle::def::ExportMap; -use middle::def_id::DefId; +use rustc::hir::def::ExportMap; +use rustc::hir::def_id::DefId; use rustc::traits; use rustc::mir::mir_map::MirMap; use rustc::mir::repr as mir; diff --git a/src/librustc_trans/controlflow.rs b/src/librustc_trans/controlflow.rs index f3cb4d5001aa5..58971dec8a9d7 100644 --- a/src/librustc_trans/controlflow.rs +++ b/src/librustc_trans/controlflow.rs @@ -9,7 +9,7 @@ // except according to those terms. use llvm::ValueRef; -use middle::def::Def; +use rustc::hir::def::Def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; use rustc::ty::subst::Substs; use base::*; diff --git a/src/librustc_trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs index b98b98813507a..b1cfeb8125bd3 100644 --- a/src/librustc_trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -14,7 +14,7 @@ use super::utils::DIB; use llvm; use llvm::debuginfo::{DIScope, DISubprogram}; use common::CrateContext; -use middle::pat_util; +use rustc::hir::pat_util; use rustc::util::nodemap::NodeMap; use libc::c_uint; diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index acfafc6e3297d..822155f8c36a9 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -23,9 +23,9 @@ use super::{declare_local, VariableKind, VariableAccess}; use llvm::{self, ValueRef}; use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType}; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; -use middle::pat_util; +use rustc::hir::pat_util; use rustc::ty::subst; use rustc::hir::map as hir_map; use rustc::hir::{self, PatKind}; diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 7e9c8228f29f4..bb999c31ffb5e 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -26,7 +26,7 @@ use llvm; use llvm::{ModuleRef, ContextRef, ValueRef}; use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIDescriptor, FlagPrototyped}; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer::normalize_associated_type; use rustc::ty::subst::{self, Substs}; use rustc::hir; diff --git a/src/librustc_trans/debuginfo/namespace.rs b/src/librustc_trans/debuginfo/namespace.rs index 1feb47a3a7d99..c1487f56956fc 100644 --- a/src/librustc_trans/debuginfo/namespace.rs +++ b/src/librustc_trans/debuginfo/namespace.rs @@ -14,7 +14,7 @@ use super::utils::{DIB, debug_context}; use llvm; use llvm::debuginfo::DIScope; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::hir::map as hir_map; use common::CrateContext; diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index f5bb1677f29ba..0169734ad3b7c 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -13,7 +13,7 @@ use super::namespace::crate_root_namespace; use common::CrateContext; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::ty::subst; use rustc::ty::{self, Ty}; diff --git a/src/librustc_trans/debuginfo/utils.rs b/src/librustc_trans/debuginfo/utils.rs index 61dc3dc3f8fdb..bef7af3aec6c8 100644 --- a/src/librustc_trans/debuginfo/utils.rs +++ b/src/librustc_trans/debuginfo/utils.rs @@ -13,7 +13,7 @@ use super::{FunctionDebugContext, CrateDebugContext}; use super::namespace::namespace_for_item; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use llvm; use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray}; diff --git a/src/librustc_trans/expr.rs b/src/librustc_trans/expr.rs index fce8656fb93d8..beca81da05f4c 100644 --- a/src/librustc_trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -53,7 +53,7 @@ use self::lazy_binop_ty::*; use llvm::{self, ValueRef, TypeKind}; use middle::const_qualif::ConstQualif; -use middle::def::Def; +use rustc::hir::def::Def; use rustc::ty::subst::Substs; use {_match, abi, adt, asm, base, closure, consts, controlflow}; use base::*; diff --git a/src/librustc_trans/inline.rs b/src/librustc_trans/inline.rs index 36dfbec115e79..1eff09d67f96b 100644 --- a/src/librustc_trans/inline.rs +++ b/src/librustc_trans/inline.rs @@ -10,7 +10,7 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use middle::cstore::{CrateStore, FoundAst, InlinedItem}; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::subst::Substs; use base::{push_ctxt, trans_item, trans_fn}; use callee::Callee; diff --git a/src/librustc_trans/meth.rs b/src/librustc_trans/meth.rs index 82b61e15f2bfe..478094c2b87b0 100644 --- a/src/librustc_trans/meth.rs +++ b/src/librustc_trans/meth.rs @@ -13,7 +13,7 @@ use std::rc::Rc; use arena::TypedArena; use back::symbol_names; use llvm::{ValueRef, get_params}; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::ty::subst::{FnSpace, Subst, Substs}; use rustc::ty::subst; diff --git a/src/librustc_trans/monomorphize.rs b/src/librustc_trans/monomorphize.rs index de66951d09129..ef0da37f0b261 100644 --- a/src/librustc_trans/monomorphize.rs +++ b/src/librustc_trans/monomorphize.rs @@ -11,7 +11,7 @@ use back::symbol_names; use llvm::ValueRef; use llvm; -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer::normalize_associated_type; use rustc::ty::subst; use rustc::ty::subst::{Subst, Substs}; diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index 8b1aaafab58ed..500eda2624ce7 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -10,7 +10,7 @@ #![allow(non_camel_case_types)] -use middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::infer; use rustc::ty::subst; use abi::FnType; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index a52b8cad1083a..21122e7095dd1 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -52,8 +52,8 @@ use middle::astconv_util::{prim_ty_to_ty, prohibit_type_params, prohibit_project use middle::const_val::ConstVal; use rustc_const_eval::eval_const_expr_partial; use rustc_const_eval::EvalHint::UncheckedExprHint; -use middle::def::{self, Def}; -use middle::def_id::DefId; +use hir::def::{self, Def}; +use hir::def_id::DefId; use middle::resolve_lifetime as rl; use rustc::ty::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace}; use rustc::traits; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index eaf8479585f8d..8dbd6496b6fb0 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::def::{self, Def}; +use hir::def::{self, Def}; use rustc::infer::{self, InferOk, TypeOrigin}; -use middle::pat_util::{PatIdMap, pat_id_map, pat_is_binding}; -use middle::pat_util::pat_is_resolved_const; +use hir::pat_util::{PatIdMap, pat_id_map, pat_is_binding}; +use hir::pat_util::pat_is_resolved_const; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, TypeFoldable, LvaluePreference}; use check::{check_expr, check_expr_has_type, check_expr_with_expectation}; diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 460230c60c60a..21800d91d9458 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -26,8 +26,8 @@ use super::write_call; use CrateCtxt; use middle::cstore::LOCAL_CRATE; -use middle::def::Def; -use middle::def_id::DefId; +use hir::def::Def; +use hir::def_id::DefId; use rustc::infer; use rustc::ty::{self, LvaluePreference, Ty}; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 00a73a062fe18..91cdb8d966d41 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -44,7 +44,7 @@ use super::FnCtxt; use super::structurally_resolved_type; use lint; -use middle::def_id::DefId; +use hir::def_id::DefId; use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::cast::{CastKind, CastTy}; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 1f1bba509e01e..368b826b1bb39 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -10,7 +10,7 @@ use check::regionck::{self, Rcx}; -use middle::def_id::DefId; +use hir::def_id::DefId; use middle::free_region::FreeRegionMap; use rustc::infer; use middle::region; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index cc12b2e05152d..b98f1884f01ce 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -12,7 +12,7 @@ use super::probe; use check::{self, FnCtxt, callee, demand}; use check::UnresolvedTypeAction; -use middle::def_id::DefId; +use hir::def_id::DefId; use rustc::ty::subst::{self}; use rustc::traits; use rustc::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt}; diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 72ca73aac940e..3f069a68316de 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -12,8 +12,8 @@ use astconv::AstConv; use check::FnCtxt; -use middle::def::Def; -use middle::def_id::DefId; +use hir::def::Def; +use hir::def_id::DefId; use rustc::ty::subst; use rustc::traits; use rustc::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index c907a6dc64020..7d98eac30c5d0 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -15,8 +15,8 @@ use super::suggest; use check; use check::{FnCtxt, UnresolvedTypeAction}; -use middle::def_id::DefId; -use middle::def::Def; +use hir::def_id::DefId; +use hir::def::Def; use rustc::ty::subst; use rustc::ty::subst::Subst; use rustc::traits; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 620863a7a2e11..c5195cf8787da 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -18,8 +18,8 @@ use check::{self, FnCtxt, UnresolvedTypeAction, autoderef}; use rustc::hir::map as hir_map; use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TypeFoldable}; use middle::cstore::{self, CrateStore}; -use middle::def::Def; -use middle::def_id::DefId; +use hir::def::Def; +use hir::def_id::DefId; use middle::lang_items::FnOnceTraitLangItem; use rustc::ty::subst::Substs; use rustc::ty::LvaluePreference; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c3a42826dbc41..e7159e65eeb7c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -86,10 +86,10 @@ use dep_graph::DepNode; use fmt_macros::{Parser, Piece, Position}; use middle::astconv_util::prohibit_type_params; use middle::cstore::LOCAL_CRATE; -use middle::def::{self, Def}; -use middle::def_id::DefId; +use hir::def::{self, Def}; +use hir::def_id::DefId; use rustc::infer::{self, InferOk, TypeOrigin, TypeTrace, type_variable}; -use middle::pat_util::{self, pat_id_map}; +use hir::pat_util::{self, pat_id_map}; use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace}; use rustc::traits::{self, report_fulfillment_errors, ProjectionMode}; use rustc::ty::{GenericPredicates, TypeScheme}; diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index f7f40e6077f4a..debf925875723 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -18,7 +18,7 @@ use super::{ method, FnCtxt, }; -use middle::def_id::DefId; +use hir::def_id::DefId; use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue}; use syntax::ast; use syntax::parse::token; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 02114c170c44b..2a4de6e091b3d 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -93,7 +93,7 @@ use rustc::ty::subst::Substs; use rustc::traits; use rustc::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable}; use rustc::infer::{self, GenericKind, InferCtxt, InferOk, SubregionOrigin, TypeOrigin, VerifyBound}; -use middle::pat_util; +use hir::pat_util; use rustc::ty::adjustment; use rustc::ty::wf::ImpliedBound; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 0ed0b64b9704f..1b21e6ce9ebe3 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -12,7 +12,7 @@ use astconv::AstConv; use check::{FnCtxt, Inherited, blank_fn_ctxt, regionck}; use constrained_type_params::{identify_constrained_type_params, Parameter}; use CrateCtxt; -use middle::def_id::DefId; +use hir::def_id::DefId; use middle::region::{CodeExtent}; use rustc::ty::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; use rustc::traits; diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 50f2f27b3d2a2..68327ccd39ab6 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -15,8 +15,8 @@ use self::ResolveReason::*; use astconv::AstConv; use check::FnCtxt; -use middle::def_id::DefId; -use middle::pat_util; +use hir::def_id::DefId; +use hir::pat_util; use rustc::ty::{self, Ty, TyCtxt, MethodCall, MethodCallee}; use rustc::ty::adjustment; use rustc::ty::fold::{TypeFolder,TypeFoldable}; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 1f7fc45327965..9c8c9ba505612 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -15,7 +15,7 @@ // done by the orphan and overlap modules. Then we build up various // mappings. That mapping code resides here. -use middle::def_id::DefId; +use hir::def_id::DefId; use middle::lang_items::UnsizeTraitLangItem; use rustc::ty::subst::{self, Subst}; use rustc::ty::{self, TyCtxt, TypeFoldable}; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 0821d5582bded..f3d63957018d6 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -12,7 +12,7 @@ //! crate or pertains to a type defined in this crate. use middle::cstore::LOCAL_CRATE; -use middle::def_id::DefId; +use hir::def_id::DefId; use rustc::traits; use rustc::ty::{self, TyCtxt}; use syntax::ast; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index d99c5d52f4a67..a05167dbe4333 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -13,7 +13,7 @@ //! constructor provide a method with the same name. use middle::cstore::CrateStore; -use middle::def_id::DefId; +use hir::def_id::DefId; use rustc::traits::{self, ProjectionMode}; use rustc::infer; use rustc::ty::{self, TyCtxt}; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 53126d3494ab1..9d76b4c5284b1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -60,8 +60,8 @@ There are some shortcomings in this design: use astconv::{self, AstConv, ty_of_arg, ast_ty_to_ty, ast_region_to_region}; use lint; -use middle::def::Def; -use middle::def_id::DefId; +use hir::def::Def; +use hir::def_id::DefId; use constrained_type_params as ctp; use coherence; use middle::lang_items::SizedTraitLangItem; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index af32026d47e46..ab2276c324b60 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -103,7 +103,7 @@ pub use rustc::util; use dep_graph::DepNode; use hir::map as hir_map; -use middle::def::Def; +use hir::def::Def; use rustc::infer::{self, TypeOrigin}; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index fa3ee80c6dac8..3b03a713a5b93 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -14,7 +14,7 @@ //! We walk the set of items and, for each member, generate new constraints. use dep_graph::DepTrackingMapConfig; -use middle::def_id::DefId; +use hir::def_id::DefId; use middle::resolve_lifetime as rl; use rustc::ty::subst; use rustc::ty::subst::ParamSpace; diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 2f080dae37084..70997a1a6eed2 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -17,8 +17,8 @@ use syntax::attr::AttrMetaMethods; use rustc::hir; use rustc::middle::cstore::{self, CrateStore}; -use rustc::middle::def::Def; -use rustc::middle::def_id::DefId; +use rustc::hir::def::Def; +use rustc::hir::def_id::DefId; use rustc::ty::{self, TyCtxt}; use rustc::ty::subst; use rustc::middle::stability; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 715d0e759c3b7..4895022cfac29 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -35,8 +35,8 @@ use syntax::ptr::P; use rustc_trans::back::link; use rustc::middle::cstore::{self, CrateStore}; -use rustc::middle::def::Def; -use rustc::middle::def_id::{DefId, DefIndex}; +use rustc::hir::def::Def; +use rustc::hir::def_id::{DefId, DefIndex}; use rustc::ty::subst::{self, ParamSpace, VecPerParamSpace}; use rustc::ty; use rustc::middle::stability; diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index e6a4d882c0449..4ba412cdc851b 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -29,7 +29,7 @@ use std::mem; use std::collections::HashMap; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::ty::subst; use clean::PathParameters as PP; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 4686e60be872a..6b7aa103e1d0a 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -13,7 +13,7 @@ use rustc_lint; use rustc_driver::{driver, target_features, abort_on_err}; use rustc::dep_graph::DepGraph; use rustc::session::{self, config}; -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::middle::privacy::AccessLevels; use rustc::ty::{self, TyCtxt}; use rustc::hir::map as hir_map; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 9f0b636227ff6..a43711a32733b 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -19,7 +19,7 @@ use std::fmt; use std::iter::repeat; use rustc::middle::cstore::LOCAL_CRATE; -use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; +use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use syntax::abi::Abi; use rustc::hir; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index f97d4fee05391..d63e704e06bfb 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -56,7 +56,7 @@ use serialize::json::{ToJson, Json, as_json}; use syntax::{abi, ast}; use syntax::feature_gate::UnstableFeatures; use rustc::middle::cstore::LOCAL_CRATE; -use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; +use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability; use rustc::session::config::get_unstable_features_setting; diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 31f00caee436f..ff2a9f13e8a12 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::middle::def_id::DefId; +use rustc::hir::def_id::DefId; use rustc::middle::privacy::AccessLevels; use rustc::util::nodemap::DefIdSet; use std::cmp; From 20f0f3c1f131b54dcc6fdc7eeb1d04ea89f5f6fd Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 29 Mar 2016 13:14:01 +0300 Subject: [PATCH 5/8] rustc: move some maps from ty to hir. --- src/librustc/hir/mod.rs | 25 +++++++++++++++++++++++++ src/librustc/ty/context.rs | 2 +- src/librustc/ty/mod.rs | 28 +++------------------------- src/librustc_metadata/astencode.rs | 14 +++++++------- src/librustc_mir/hair/cx/expr.rs | 2 +- src/librustc_resolve/lib.rs | 8 ++++---- src/librustc_typeck/lib.rs | 4 ++-- 7 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 10fe86246de69..edb9b78352765 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -33,6 +33,10 @@ pub use self::ViewPath_::*; pub use self::Visibility::*; pub use self::PathParameters::*; +use hir::def::Def; +use hir::def_id::DefId; +use util::nodemap::{NodeMap, FnvHashSet}; + use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId}; use syntax::abi::Abi; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect}; @@ -1625,3 +1629,24 @@ impl ForeignItem_ { } } } + +/// A free variable referred to in a function. +#[derive(Copy, Clone, RustcEncodable, RustcDecodable)] +pub struct Freevar { + /// The variable being accessed free. + pub def: Def, + + // First span where it is accessed (there can be multiple). + pub span: Span +} + +pub type FreevarMap = NodeMap>; + +pub type CaptureModeMap = NodeMap; + +// Trait method resolution +pub type TraitMap = NodeMap>; + +// Map from the NodeId of a glob import to a list of items which are actually +// imported. +pub type GlobMap = NodeMap>; diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 14ffeadbb3a22..bdba700f49ad5 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -27,7 +27,7 @@ use traits; use ty::{self, TraitRef, Ty, TypeAndMut}; use ty::{TyS, TypeVariants}; use ty::{AdtDef, ClosureSubsts, ExistentialBounds, Region}; -use ty::{FreevarMap}; +use hir::FreevarMap; use ty::{BareFnTy, InferTy, ParamTy, ProjectionTy, TraitTy}; use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; use ty::TypeVariants::*; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2f0b520d84276..4ff859f5a94bf 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -33,7 +33,7 @@ use ty::fold::TypeFolder; use ty::subst::{Subst, Substs, VecPerParamSpace}; use ty::walk::TypeWalker; use util::common::MemoizationMap; -use util::nodemap::{NodeMap, NodeSet}; +use util::nodemap::NodeSet; use util::nodemap::FnvHashMap; use serialize::{Encodable, Encoder, Decodable, Decoder}; @@ -44,7 +44,6 @@ use std::iter; use std::rc::Rc; use std::slice; use std::vec::IntoIter; -use std::collections::{HashMap, HashSet}; use syntax::ast::{self, CrateNum, Name, NodeId}; use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{DUMMY_SP, Span}; @@ -115,7 +114,7 @@ pub struct CrateAnalysis<'a> { pub access_levels: middle::privacy::AccessLevels, pub reachable: NodeSet, pub name: &'a str, - pub glob_map: Option, + pub glob_map: Option, } #[derive(Copy, Clone)] @@ -2724,30 +2723,9 @@ pub enum ExplicitSelfCategory { ByBox, } -/// A free variable referred to in a function. -#[derive(Copy, Clone, RustcEncodable, RustcDecodable)] -pub struct Freevar { - /// The variable being accessed free. - pub def: Def, - - // First span where it is accessed (there can be multiple). - pub span: Span -} - -pub type FreevarMap = NodeMap>; - -pub type CaptureModeMap = NodeMap; - -// Trait method resolution -pub type TraitMap = NodeMap>; - -// Map from the NodeId of a glob import to a list of items which are actually -// imported. -pub type GlobMap = HashMap>; - impl<'tcx> TyCtxt<'tcx> { pub fn with_freevars(&self, fid: NodeId, f: F) -> T where - F: FnOnce(&[Freevar]) -> T, + F: FnOnce(&[hir::Freevar]) -> T, { match self.freevars.borrow().get(&fid) { None => f(&[]), diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index df60e35d0f3d3..3becc93f8a4f5 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -410,20 +410,20 @@ impl tr for Def { // ______________________________________________________________________ // Encoding and decoding of freevar information -fn encode_freevar_entry(rbml_w: &mut Encoder, fv: &ty::Freevar) { +fn encode_freevar_entry(rbml_w: &mut Encoder, fv: &hir::Freevar) { (*fv).encode(rbml_w).unwrap(); } trait rbml_decoder_helper { fn read_freevar_entry(&mut self, dcx: &DecodeContext) - -> ty::Freevar; + -> hir::Freevar; fn read_capture_mode(&mut self) -> hir::CaptureClause; } impl<'a> rbml_decoder_helper for reader::Decoder<'a> { fn read_freevar_entry(&mut self, dcx: &DecodeContext) - -> ty::Freevar { - let fv: ty::Freevar = Decodable::decode(self).unwrap(); + -> hir::Freevar { + let fv: hir::Freevar = Decodable::decode(self).unwrap(); fv.tr(dcx) } @@ -433,9 +433,9 @@ impl<'a> rbml_decoder_helper for reader::Decoder<'a> { } } -impl tr for ty::Freevar { - fn tr(&self, dcx: &DecodeContext) -> ty::Freevar { - ty::Freevar { +impl tr for hir::Freevar { + fn tr(&self, dcx: &DecodeContext) -> hir::Freevar { + hir::Freevar { def: self.def.tr(dcx), span: self.span.tr(dcx), } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 7f748ef9b1ea7..12dcb32da3fcd 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -958,7 +958,7 @@ fn overloaded_lvalue<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, fn capture_freevar<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, closure_expr: &'tcx hir::Expr, - freevar: &ty::Freevar, + freevar: &hir::Freevar, freevar_ty: Ty<'tcx>) -> ExprRef<'tcx> { let id_var = freevar.def.var_id(); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 502b45c945347..299a8c0299d0e 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -56,8 +56,8 @@ use rustc::hir::def::*; use rustc::hir::def_id::DefId; use rustc::hir::pat_util::pat_bindings; use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace}; -use rustc::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; -use rustc::util::nodemap::{NodeMap, FnvHashMap}; +use rustc::hir::{Freevar, FreevarMap, TraitMap, GlobMap}; +use rustc::util::nodemap::{NodeMap, FnvHashMap, FnvHashSet}; use syntax::ast::{self, FloatTy}; use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, IntTy, UintTy}; @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { emit_errors: true, make_glob_map: make_glob_map == MakeGlobMap::Yes, - glob_map: HashMap::new(), + glob_map: NodeMap(), callback: None, resolved: false, @@ -1253,7 +1253,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { return; } - let mut new_set = HashSet::new(); + let mut new_set = FnvHashSet(); new_set.insert(name); self.glob_map.insert(import_id, new_set); } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ab2276c324b60..7f27d10ce1ec3 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -136,7 +136,7 @@ pub struct TypeAndSubsts<'tcx> { pub struct CrateCtxt<'a, 'tcx: 'a> { // A mapping from method call sites to traits that have that method. - pub trait_map: ty::TraitMap, + pub trait_map: hir::TraitMap, /// A vector of every trait accessible in the whole crate /// (i.e. including those from subcrates). This is used only for /// error reporting, and so is lazily initialised and generally @@ -329,7 +329,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) { } } -pub fn check_crate(tcx: &TyCtxt, trait_map: ty::TraitMap) -> CompileResult { +pub fn check_crate(tcx: &TyCtxt, trait_map: hir::TraitMap) -> CompileResult { let time_passes = tcx.sess.time_passes(); let ccx = CrateCtxt { trait_map: trait_map, From 7f3744f07f0d32f9673af1563d70b22985b1c2cf Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 2 Apr 2016 16:47:53 +0300 Subject: [PATCH 6/8] Get rid of ast::StructFieldKind --- src/librustc_front/lowering.rs | 5 +-- src/librustc_save_analysis/lib.rs | 33 +++++++------- src/libsyntax/ast.rs | 35 +-------------- src/libsyntax/ast_util.rs | 6 --- src/libsyntax/ext/build.rs | 3 +- src/libsyntax/fold.rs | 12 ++--- src/libsyntax/parse/parser.rs | 8 ++-- src/libsyntax/print/pprust.rs | 32 +++++-------- src/libsyntax/visit.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 55 +++++------------------ 10 files changed, 55 insertions(+), 136 deletions(-) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 66b9e217bd387..4ca30a041a541 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -622,9 +622,8 @@ pub fn lower_struct_field(lctx: &LoweringContext, hir::StructField { span: f.span, id: f.node.id, - name: f.node.ident().map(|ident| ident.name) - .unwrap_or(token::intern(&index.to_string())), - vis: lower_visibility(lctx, f.node.kind.visibility()), + name: f.node.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())), + vis: lower_visibility(lctx, f.node.vis), ty: lower_ty(lctx, &f.node.ty), attrs: lower_attrs(lctx, &f.node.attrs), } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 36b94731e45ab..550628741c209 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -246,23 +246,22 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option { - match field.node.kind { - ast::NamedField(ident, _) => { - let qualname = format!("::{}::{}", self.tcx.map.path_to_string(scope), ident); - let typ = self.tcx.node_types().get(&field.node.id).unwrap().to_string(); - let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); - filter!(self.span_utils, sub_span, field.span, None); - Some(VariableData { - id: field.node.id, - name: ident.to_string(), - qualname: qualname, - span: sub_span.unwrap(), - scope: scope, - value: "".to_owned(), - type_value: typ, - }) - } - _ => None, + if let Some(ident) = field.node.ident { + let qualname = format!("::{}::{}", self.tcx.map.path_to_string(scope), ident); + let typ = self.tcx.node_types().get(&field.node.id).unwrap().to_string(); + let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); + filter!(self.span_utils, sub_span, field.span, None); + Some(VariableData { + id: field.node.id, + name: ident.to_string(), + qualname: qualname, + span: sub_span.unwrap(), + scope: scope, + value: "".to_owned(), + type_value: typ, + }) + } else { + None } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a441f2990cd1a..fb6ae8b88bed2 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::StructFieldKind::*; pub use self::TyParamBound::*; pub use self::UnsafeSource::*; pub use self::ViewPath_::*; @@ -1878,45 +1877,15 @@ pub enum Visibility { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct StructField_ { - pub kind: StructFieldKind, + pub ident: Option, + pub vis: Visibility, pub id: NodeId, pub ty: P, pub attrs: Vec, } -impl StructField_ { - pub fn ident(&self) -> Option { - match self.kind { - NamedField(ref ident, _) => Some(ident.clone()), - UnnamedField(_) => None - } - } -} - pub type StructField = Spanned; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum StructFieldKind { - NamedField(Ident, Visibility), - /// Element of a tuple-like struct - UnnamedField(Visibility), -} - -impl StructFieldKind { - pub fn is_unnamed(&self) -> bool { - match *self { - UnnamedField(..) => true, - NamedField(..) => false, - } - } - - pub fn visibility(&self) -> &Visibility { - match *self { - NamedField(_, ref vis) | UnnamedField(ref vis) => vis - } - } -} - /// Fields and Ids of enum variants and structs /// /// For enum variants: `NodeId` represents both an Id of the variant itself (relevant for all diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 852b153044fea..671ba3b0996af 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -95,12 +95,6 @@ pub fn impl_pretty_name(trait_ref: &Option, ty: Option<&Ty>) -> Ident token::gensym_ident(&pretty[..]) } -pub fn struct_field_visibility(field: ast::StructField) -> Visibility { - match field.node.kind { - ast::NamedField(_, v) | ast::UnnamedField(v) => v - } -} - // ______________________________________________________________________ // Enumerating the IDs which appear in an AST diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0eb42f17f68b4..a62832b928d60 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1009,7 +1009,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { let fields: Vec<_> = tys.into_iter().map(|ty| { Spanned { span: ty.span, node: ast::StructField_ { ty: ty, - kind: ast::UnnamedField(ast::Visibility::Inherited), + ident: None, + vis: ast::Visibility::Inherited, attrs: Vec::new(), id: ast::DUMMY_NODE_ID, }} diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 46bcb8067a3b0..eb35d3fd9d35b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -847,15 +847,15 @@ pub fn noop_fold_poly_trait_ref(p: PolyTraitRef, fld: &mut T) -> Poly } pub fn noop_fold_struct_field(f: StructField, fld: &mut T) -> StructField { - let StructField {node: StructField_ {id, kind, ty, attrs}, span} = f; Spanned { node: StructField_ { - id: fld.new_id(id), - kind: kind, - ty: fld.fold_ty(ty), - attrs: fold_attrs(attrs, fld), + id: fld.new_id(f.node.id), + ident: f.node.ident.map(|ident| fld.fold_ident(ident)), + vis: f.node.vis, + ty: fld.fold_ty(f.node.ty), + attrs: fold_attrs(f.node.attrs, fld), }, - span: fld.new_span(span) + span: fld.new_span(f.span) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 89a504e1ebd60..00d60630eaceb 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -29,7 +29,6 @@ use ast::Local; use ast::MacStmtStyle; use ast::Mac_; use ast::{MutTy, Mutability}; -use ast::NamedField; use ast::{Pat, PatKind}; use ast::{PolyTraitRef, QSelf}; use ast::{Stmt, StmtKind}; @@ -38,7 +37,6 @@ use ast::StrStyle; use ast::SelfKind; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds}; -use ast::UnnamedField; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{Visibility, WhereClause}; use attr::{ThinAttributes, ThinAttributesExt, AttributesExt}; @@ -3848,7 +3846,8 @@ impl<'a> Parser<'a> { self.expect(&token::Colon)?; let ty = self.parse_ty_sum()?; Ok(spanned(lo, self.last_span.hi, ast::StructField_ { - kind: NamedField(name, pr), + ident: Some(name), + vis: pr, id: ast::DUMMY_NODE_ID, ty: ty, attrs: attrs, @@ -5247,7 +5246,8 @@ impl<'a> Parser<'a> { let attrs = p.parse_outer_attributes()?; let lo = p.span.lo; let struct_field_ = ast::StructField_ { - kind: UnnamedField(p.parse_visibility()?), + vis: p.parse_visibility()?, + ident: None, id: ast::DUMMY_NODE_ID, ty: p.parse_ty_sum()?, attrs: attrs, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a8f28ed3d9e0d..c7a755aeeac56 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1407,14 +1407,9 @@ impl<'a> State<'a> { self.commasep( Inconsistent, struct_def.fields(), |s, field| { - match field.node.kind { - ast::NamedField(..) => panic!("unexpected named field"), - ast::UnnamedField(ref vis) => { - s.print_visibility(vis)?; - s.maybe_print_comment(field.span.lo)?; - s.print_type(&field.node.ty) - } - } + s.print_visibility(field.node.vis)?; + s.maybe_print_comment(field.span.lo)?; + s.print_type(&field.node.ty) } )?; self.pclose()?; @@ -1432,19 +1427,14 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol()?; for field in struct_def.fields() { - match field.node.kind { - ast::UnnamedField(..) => panic!("unexpected unnamed field"), - ast::NamedField(ident, ref visibility) => { - self.hardbreak_if_not_bol()?; - self.maybe_print_comment(field.span.lo)?; - self.print_outer_attributes(&field.node.attrs)?; - self.print_visibility(visibility)?; - self.print_ident(ident)?; - self.word_nbsp(":")?; - self.print_type(&field.node.ty)?; - word(&mut self.s, ",")?; - } - } + self.hardbreak_if_not_bol()?; + self.maybe_print_comment(field.span.lo)?; + self.print_outer_attributes(&field.node.attrs)?; + self.print_visibility(field.node.vis)?; + self.print_ident(field.node.ident.unwrap())?; + self.word_nbsp(":")?; + self.print_type(&field.node.ty)?; + word(&mut self.s, ",")?; } self.bclose(span) diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 1251f9bfe1350..d97e2db626514 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -619,7 +619,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v StructField) { - walk_opt_ident(visitor, struct_field.span, struct_field.node.ident()); + walk_opt_ident(visitor, struct_field.span, struct_field.node.ident); visitor.visit_ty(&struct_field.node.ty); walk_list!(visitor, visit_attribute, &struct_field.node.attrs); } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 7d452b14dae84..12a7270d5214b 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -186,7 +186,6 @@ pub use self::StaticFields::*; pub use self::SubstructureFields::*; -use self::StructType::*; use std::cell::RefCell; use std::collections::HashSet; @@ -1409,11 +1408,6 @@ impl<'a> MethodDef<'a> { } } -#[derive(PartialEq)] // dogfooding! -enum StructType { - Unknown, Record, Tuple -} - // general helper methods. impl<'a> TraitDef<'a> { fn set_expn_info(&self, @@ -1441,9 +1435,9 @@ impl<'a> TraitDef<'a> { let mut just_spans = Vec::new(); for field in struct_def.fields(){ let sp = self.set_expn_info(cx, field.span); - match field.node.kind { - ast::NamedField(ident, _) => named_idents.push((ident, sp)), - ast::UnnamedField(..) => just_spans.push(sp), + match field.node.ident { + Some(ident) => named_idents.push((ident, sp)), + _ => just_spans.push(sp), } } @@ -1479,53 +1473,26 @@ impl<'a> TraitDef<'a> { -> (P, Vec<(Span, Option, P, &'a [ast::Attribute])>) { - if struct_def.fields().is_empty() { - if struct_def.is_struct() { - return (cx.pat_struct(self.span, struct_path, vec![]), vec![]); - } else { - return (cx.pat_enum(self.span, struct_path, vec![]), vec![]); - } - } - let mut paths = Vec::new(); - let mut ident_expr = Vec::new(); - let mut struct_type = Unknown; - + let mut ident_exprs = Vec::new(); for (i, struct_field) in struct_def.fields().iter().enumerate() { let sp = self.set_expn_info(cx, struct_field.span); - let opt_id = match struct_field.node.kind { - ast::NamedField(ident, _) if (struct_type == Unknown || - struct_type == Record) => { - struct_type = Record; - Some(ident) - } - ast::UnnamedField(..) if (struct_type == Unknown || - struct_type == Tuple) => { - struct_type = Tuple; - None - } - _ => { - cx.span_bug(sp, "a struct with named and unnamed fields in `derive`"); - } - }; let ident = cx.ident_of(&format!("{}_{}", prefix, i)); paths.push(codemap::Spanned{span: sp, node: ident}); let val = cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))); let val = cx.expr(sp, ast::ExprKind::Paren(val)); - ident_expr.push((sp, opt_id, val, &struct_field.node.attrs[..])); + ident_exprs.push((sp, struct_field.node.ident, val, &struct_field.node.attrs[..])); } let subpats = self.create_subpatterns(cx, paths, mutbl); - - // struct_type is definitely not Unknown, since struct_def.fields - // must be nonempty to reach here let pattern = if struct_def.is_struct() { - let field_pats = subpats.into_iter().zip(&ident_expr) - .map(|(pat, &(_, id, _, _))| { - // id is guaranteed to be Some + let field_pats = subpats.into_iter().zip(&ident_exprs).map(|(pat, &(sp, ident, _, _))| { + if ident.is_none() { + cx.span_bug(sp, "a braced struct with unnamed fields in `derive`"); + } codemap::Spanned { span: pat.span, - node: ast::FieldPat { ident: id.unwrap(), pat: pat, is_shorthand: false }, + node: ast::FieldPat { ident: ident.unwrap(), pat: pat, is_shorthand: false }, } }).collect(); cx.pat_struct(self.span, struct_path, field_pats) @@ -1533,7 +1500,7 @@ impl<'a> TraitDef<'a> { cx.pat_enum(self.span, struct_path, subpats) }; - (pattern, ident_expr) + (pattern, ident_exprs) } fn create_enum_variant_pattern(&self, From 8fe4290f1cf87bf7b0a0661e6bbe84f3319e614d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 6 Apr 2016 11:19:10 +0300 Subject: [PATCH 7/8] Move span into `StructField` --- src/librustc/lint/context.rs | 2 +- src/librustc_front/lowering.rs | 10 +++++----- src/librustc_save_analysis/dump_visitor.rs | 4 ++-- src/librustc_save_analysis/lib.rs | 6 +++--- src/libsyntax/ast.rs | 5 ++--- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/config.rs | 6 +++--- src/libsyntax/ext/build.rs | 5 +++-- src/libsyntax/fold.rs | 16 +++++++--------- src/libsyntax/parse/parser.rs | 17 ++++++++++------- src/libsyntax/print/pprust.rs | 12 ++++++------ src/libsyntax/visit.rs | 6 +++--- src/libsyntax_ext/deriving/generic/mod.rs | 8 ++++---- 13 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index e78ff513ac473..46ac384670685 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -978,7 +978,7 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> { } fn visit_struct_field(&mut self, s: &ast::StructField) { - self.with_lint_attrs(&s.node.attrs, |cx| { + self.with_lint_attrs(&s.attrs, |cx| { run_lints!(cx, check_struct_field, early_passes, s); ast_visit::walk_struct_field(cx, s); }) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 4ca30a041a541..738a04dea585d 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -621,11 +621,11 @@ pub fn lower_struct_field(lctx: &LoweringContext, -> hir::StructField { hir::StructField { span: f.span, - id: f.node.id, - name: f.node.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())), - vis: lower_visibility(lctx, f.node.vis), - ty: lower_ty(lctx, &f.node.ty), - attrs: lower_attrs(lctx, &f.node.attrs), + id: f.id, + name: f.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())), + vis: lower_visibility(lctx, &f.vis), + ty: lower_ty(lctx, &f.ty), + attrs: lower_attrs(lctx, &f.attrs), } } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 35ca2a9b0149a..e9cfd24d41047 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -563,7 +563,7 @@ where D: Dump // fields for field in def.fields() { self.process_struct_field_def(field, item.id); - self.visit_ty(&field.node.ty); + self.visit_ty(&field.ty); } self.process_generic_params(ty_params, item.span, &qualname, item.id); @@ -624,7 +624,7 @@ where D: Dump for field in variant.node.data.fields() { self.process_struct_field_def(field, variant.node.data.id()); - self.visit_ty(&field.node.ty); + self.visit_ty(&field.ty); } } self.process_generic_params(ty_params, item.span, &enum_data.qualname, enum_data.id); diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 550628741c209..95339c7937161 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -246,13 +246,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option { - if let Some(ident) = field.node.ident { + if let Some(ident) = field.ident { let qualname = format!("::{}::{}", self.tcx.map.path_to_string(scope), ident); - let typ = self.tcx.node_types().get(&field.node.id).unwrap().to_string(); + let typ = self.tcx.node_types().get(&field.id).unwrap().to_string(); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); filter!(self.span_utils, sub_span, field.span, None); Some(VariableData { - id: field.node.id, + id: field.id, name: ident.to_string(), qualname: qualname, span: sub_span.unwrap(), diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index fb6ae8b88bed2..dbe7b078498ea 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1876,7 +1876,8 @@ pub enum Visibility { } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub struct StructField_ { +pub struct StructField { + pub span: Span, pub ident: Option, pub vis: Visibility, pub id: NodeId, @@ -1884,8 +1885,6 @@ pub struct StructField_ { pub attrs: Vec, } -pub type StructField = Spanned; - /// Fields and Ids of enum variants and structs /// /// For enum variants: `NodeId` represents both an Id of the variant itself (relevant for all diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 671ba3b0996af..ffba9e824d4ad 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -263,7 +263,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { } fn visit_struct_field(&mut self, struct_field: &StructField) { - self.operation.visit_id(struct_field.node.id); + self.operation.visit_id(struct_field.id); visit::walk_struct_field(self, struct_field) } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 9acb1805cdde8..4554a280e5f19 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -180,12 +180,12 @@ fn fold_struct(cx: &mut Context, vdata: ast::VariantData) -> ast::VariantD match vdata { ast::VariantData::Struct(fields, id) => { ast::VariantData::Struct(fields.into_iter().filter(|m| { - (cx.in_cfg)(&m.node.attrs) + (cx.in_cfg)(&m.attrs) }).collect(), id) } ast::VariantData::Tuple(fields, id) => { ast::VariantData::Tuple(fields.into_iter().filter(|m| { - (cx.in_cfg)(&m.node.attrs) + (cx.in_cfg)(&m.attrs) }).collect(), id) } ast::VariantData::Unit(id) => ast::VariantData::Unit(id) @@ -434,7 +434,7 @@ impl<'v, 'a, 'b> visit::Visitor<'v> for StmtExprAttrFeatureVisitor<'a, 'b> { } fn visit_struct_field(&mut self, s: &'v ast::StructField) { - if node_survives_cfg(&s.node.attrs, self.config) { + if node_survives_cfg(&s.attrs, self.config) { visit::walk_struct_field(self, s); } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a62832b928d60..a4e5b68277d69 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1007,13 +1007,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn variant(&self, span: Span, name: Ident, tys: Vec> ) -> ast::Variant { let fields: Vec<_> = tys.into_iter().map(|ty| { - Spanned { span: ty.span, node: ast::StructField_ { + ast::StructField { + span: ty.span, ty: ty, ident: None, vis: ast::Visibility::Inherited, attrs: Vec::new(), id: ast::DUMMY_NODE_ID, - }} + } }).collect(); let vdata = if fields.is_empty() { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index eb35d3fd9d35b..46191b95f81f6 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -847,15 +847,13 @@ pub fn noop_fold_poly_trait_ref(p: PolyTraitRef, fld: &mut T) -> Poly } pub fn noop_fold_struct_field(f: StructField, fld: &mut T) -> StructField { - Spanned { - node: StructField_ { - id: fld.new_id(f.node.id), - ident: f.node.ident.map(|ident| fld.fold_ident(ident)), - vis: f.node.vis, - ty: fld.fold_ty(f.node.ty), - attrs: fold_attrs(f.node.attrs, fld), - }, - span: fld.new_span(f.span) + StructField { + span: fld.new_span(f.span), + id: fld.new_id(f.id), + ident: f.ident.map(|ident| fld.fold_ident(ident)), + vis: f.vis, + ty: fld.fold_ty(f.ty), + attrs: fold_attrs(f.attrs, fld), } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 00d60630eaceb..28e4682f66b7e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3845,13 +3845,14 @@ impl<'a> Parser<'a> { let name = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty_sum()?; - Ok(spanned(lo, self.last_span.hi, ast::StructField_ { + Ok(StructField { + span: mk_sp(lo, self.last_span.hi), ident: Some(name), vis: pr, id: ast::DUMMY_NODE_ID, ty: ty, attrs: attrs, - })) + }) } /// Emit an expected item after attributes error. @@ -5245,14 +5246,16 @@ impl<'a> Parser<'a> { |p| { let attrs = p.parse_outer_attributes()?; let lo = p.span.lo; - let struct_field_ = ast::StructField_ { - vis: p.parse_visibility()?, + let vis = p.parse_visibility()?; + let ty = p.parse_ty_sum()?; + Ok(StructField { + span: mk_sp(lo, p.span.hi), + vis: vis, ident: None, id: ast::DUMMY_NODE_ID, - ty: p.parse_ty_sum()?, + ty: ty, attrs: attrs, - }; - Ok(spanned(lo, p.span.hi, struct_field_)) + }) })?; Ok(fields) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c7a755aeeac56..e2b1d2f5e7abe 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1407,9 +1407,9 @@ impl<'a> State<'a> { self.commasep( Inconsistent, struct_def.fields(), |s, field| { - s.print_visibility(field.node.vis)?; + s.print_visibility(&field.vis)?; s.maybe_print_comment(field.span.lo)?; - s.print_type(&field.node.ty) + s.print_type(&field.ty) } )?; self.pclose()?; @@ -1429,11 +1429,11 @@ impl<'a> State<'a> { for field in struct_def.fields() { self.hardbreak_if_not_bol()?; self.maybe_print_comment(field.span.lo)?; - self.print_outer_attributes(&field.node.attrs)?; - self.print_visibility(field.node.vis)?; - self.print_ident(field.node.ident.unwrap())?; + self.print_outer_attributes(&field.attrs)?; + self.print_visibility(&field.vis)?; + self.print_ident(field.ident.unwrap())?; self.word_nbsp(":")?; - self.print_type(&field.node.ty)?; + self.print_type(&field.ty)?; word(&mut self.s, ",")?; } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index d97e2db626514..839bbf4805df2 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -619,9 +619,9 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, struct_field: &'v StructField) { - walk_opt_ident(visitor, struct_field.span, struct_field.node.ident); - visitor.visit_ty(&struct_field.node.ty); - walk_list!(visitor, visit_attribute, &struct_field.node.attrs); + walk_opt_ident(visitor, struct_field.span, struct_field.ident); + visitor.visit_ty(&struct_field.ty); + walk_list!(visitor, visit_attribute, &struct_field.attrs); } pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 12a7270d5214b..a389165f71534 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -653,7 +653,7 @@ impl<'a> TraitDef<'a> { type_ident: Ident, generics: &Generics) -> P { let field_tys: Vec> = struct_def.fields().iter() - .map(|field| field.node.ty.clone()) + .map(|field| field.ty.clone()) .collect(); let methods = self.methods.iter().map(|method_def| { @@ -701,7 +701,7 @@ impl<'a> TraitDef<'a> { for variant in &enum_def.variants { field_tys.extend(variant.node.data.fields().iter() - .map(|field| field.node.ty.clone())); + .map(|field| field.ty.clone())); } let methods = self.methods.iter().map(|method_def| { @@ -1435,7 +1435,7 @@ impl<'a> TraitDef<'a> { let mut just_spans = Vec::new(); for field in struct_def.fields(){ let sp = self.set_expn_info(cx, field.span); - match field.node.ident { + match field.ident { Some(ident) => named_idents.push((ident, sp)), _ => just_spans.push(sp), } @@ -1481,7 +1481,7 @@ impl<'a> TraitDef<'a> { paths.push(codemap::Spanned{span: sp, node: ident}); let val = cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident))); let val = cx.expr(sp, ast::ExprKind::Paren(val)); - ident_exprs.push((sp, struct_field.node.ident, val, &struct_field.node.attrs[..])); + ident_exprs.push((sp, struct_field.ident, val, &struct_field.attrs[..])); } let subpats = self.create_subpatterns(cx, paths, mutbl); From e8a8dfb056fb3654bacd6aaa6acbc4536358df23 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 6 Apr 2016 13:51:55 +0300 Subject: [PATCH 8/8] rustc: retire hir::map's paths. --- src/librustc/hir/map/collector.rs | 3 +- src/librustc/hir/map/mod.rs | 239 ++++-------------- src/librustc/hir/pat_util.rs | 10 +- src/librustc/infer/error_reporting.rs | 10 +- src/librustc/middle/cstore.rs | 5 - src/librustc/ty/item_path.rs | 5 + src/librustc/ty/mod.rs | 33 +-- src/librustc_driver/pretty.rs | 19 +- src/librustc_lint/builtin.rs | 5 +- src/librustc_metadata/astencode.rs | 17 +- src/librustc_metadata/common.rs | 9 +- src/librustc_metadata/csearch.rs | 16 -- src/librustc_metadata/decoder.rs | 26 -- src/librustc_metadata/encoder.rs | 101 +------- src/librustc_mir/graphviz.rs | 2 +- src/librustc_mir/pretty.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 8 +- src/librustc_save_analysis/lib.rs | 12 +- src/librustc_trans/base.rs | 11 +- src/librustc_trans/debuginfo/namespace.rs | 140 +++++----- src/librustc_trans/debuginfo/type_names.rs | 34 +-- src/librustdoc/clean/inline.rs | 8 +- .../pretty-print-path-suffix/foo_method.pp | 2 +- 23 files changed, 192 insertions(+), 525 deletions(-) diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index b1a084ac7994e..94fa393ae3df8 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -14,6 +14,7 @@ use super::MapEntry::*; 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; @@ -46,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, diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 4096606b001d6..e1b7afda58bbe 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -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, @@ -25,7 +24,6 @@ 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 hir::*; use hir::fold::Folder; @@ -33,85 +31,13 @@ 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 { - 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>, LinkedPath<'b>>; - -pub fn path_to_string>(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), @@ -156,7 +82,7 @@ pub enum MapEntry<'ast> { /// Roots for node trees. RootCrate, - RootInlinedParent(&'ast InlinedParent) + RootInlinedParent(&'ast InlinedItem) } impl<'ast> Clone for MapEntry<'ast> { @@ -165,12 +91,6 @@ impl<'ast> Clone for MapEntry<'ast> { } } -#[derive(Debug)] -pub struct InlinedParent { - path: Vec, - ii: InlinedItem -} - impl<'ast> MapEntry<'ast> { fn from_node(p: NodeId, node: Node<'ast>) -> MapEntry<'ast> { match node { @@ -233,7 +153,7 @@ impl<'ast> MapEntry<'ast> { pub struct Forest { krate: Crate, pub dep_graph: DepGraph, - inlined_items: TypedArena + inlined_items: TypedArena } impl Forest { @@ -351,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 { + self.opt_local_def_id(id).map(|def_id| { + self.def_path(def_id) + }) } pub fn def_path(&self, def_id: DefId) -> DefPath { @@ -551,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) } } @@ -634,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(&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(&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)) } } @@ -958,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, parent_def_path: DefPath, parent_def_id: DefId, ii: InlinedItem, @@ -978,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 { @@ -1032,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::>().join("::") + } else { + String::from("") + } + }) + }; + 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", @@ -1050,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) } } } @@ -1084,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) @@ -1111,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 {}{}", diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index 5eb4d53ea6ac7..6cc5a29062fd0 100644 --- a/src/librustc/hir/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -210,14 +210,8 @@ pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option { } 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. diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 5a0d9ec13322f..a7553f4eb1f1c 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -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::>()); - let found_path = self.tcx.with_path(did2, - |p| p.map(|x| x.to_string()) - .collect::>()); - // 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); diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 027792b743995..1f6328187a59b 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -166,9 +166,7 @@ pub trait CrateStore<'tcx> : Any { fn repr_attrs(&self, def: DefId) -> Vec; fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::TypeScheme<'tcx>; - fn relative_item_path(&self, def: DefId) -> Vec; fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap>; - fn extern_item_path(&self, def: DefId) -> Vec; fn item_name(&self, def: DefId) -> ast::Name; fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx>; @@ -345,12 +343,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { fn repr_attrs(&self, def: DefId) -> Vec { 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 { bug!("relative_item_path") } fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap> { bug!("visible_parent_map") } - fn extern_item_path(&self, def: DefId) -> Vec { 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") } diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 4d88b6974166e..5c1e19aee7b84 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -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 { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 4ff859f5a94bf..444fea0918f8d 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -20,7 +20,6 @@ pub use self::fold::TypeFoldable; use dep_graph::{self, DepNode}; use hir::map as ast_map; -use hir::map::LinkedPath; use middle; use middle::cstore::{self, CrateStore, LOCAL_CRATE}; use hir::def::{self, Def, ExportMap}; @@ -2231,39 +2230,9 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn with_path(&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 { - 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) } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index cda5595c1024e..cde5ba19859e0 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -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 { + 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::>().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 { + 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) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index fe10ca87b7542..5e3a47701ebbf 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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" } } } diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 3becc93f8a4f5..6fd9f27f0fb9f 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -85,7 +85,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, InlinedItemRef::ImplItem(_, ii) => ii.id, }; debug!("> Encoding inlined item: {} ({:?})", - ecx.tcx.map.path_to_string(id), + ecx.tcx.node_path_str(id), rbml_w.writer.seek(SeekFrom::Current(0))); // Folding could be avoided with a smarter encoder. @@ -99,7 +99,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext, rbml_w.end_tag(); debug!("< Encoded inlined fn: {} ({:?})", - ecx.tcx.map.path_to_string(id), + ecx.tcx.node_path_str(id), rbml_w.writer.seek(SeekFrom::Current(0))); } @@ -124,20 +124,12 @@ impl<'a, 'b, 'c, 'tcx> ast_map::FoldOps for &'a DecodeContext<'b, 'c, 'tcx> { /// ast-map. pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, tcx: &TyCtxt<'tcx>, - parent_path: Vec, parent_def_path: ast_map::DefPath, parent_did: DefId, ast_doc: rbml::Doc, orig_did: DefId) -> &'tcx InlinedItem { - let mut path_as_str = None; - debug!("> Decoding inlined fn: {:?}::?", - { - // Do an Option dance to use the path after it is moved below. - let s = ast_map::path_to_string(parent_path.iter().cloned()); - path_as_str = Some(s); - path_as_str.as_ref().map(|x| &x[..]) - }); + debug!("> Decoding inlined fn: {:?}", tcx.item_path_str(orig_did)); let mut ast_dsr = reader::Decoder::new(ast_doc); let from_id_range = Decodable::decode(&mut ast_dsr).unwrap(); let to_id_range = reserve_id_range(&tcx.sess, from_id_range); @@ -149,7 +141,6 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, last_filemap_index: Cell::new(0) }; let ii = ast_map::map_decoded_item(&dcx.tcx.map, - parent_path, parent_def_path, parent_did, decode_ast(ast_doc), @@ -162,7 +153,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, }; debug!("Fn named: {}", name); debug!("< Decoded inlined fn: {}::{}", - path_as_str.unwrap(), + tcx.item_path_str(parent_did), name); region::resolve_inlined_item(&tcx.sess, &tcx.region_maps, ii); decode_side_tables(dcx, ast_doc); diff --git a/src/librustc_metadata/common.rs b/src/librustc_metadata/common.rs index 22a5289f02be8..ea4e25754202c 100644 --- a/src/librustc_metadata/common.rs +++ b/src/librustc_metadata/common.rs @@ -86,13 +86,10 @@ pub const tag_item_trait_ref: usize = 0x3b; // discriminator value for variants pub const tag_disr_val: usize = 0x3c; -// used to encode ast_map::PathElem -pub const tag_path: usize = 0x3d; -pub const tag_path_len: usize = 0x3e; -pub const tag_path_elem_mod: usize = 0x3f; -pub const tag_path_elem_name: usize = 0x40; -pub const tag_item_field: usize = 0x41; +// GAP 0x3d, 0x3e, 0x3f, 0x40 +pub const tag_item_field: usize = 0x41; +// GAP 0x42 pub const tag_item_variances: usize = 0x43; /* trait items contain tag_item_trait_item elements, diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index bb691cebccd12..0b90ad5b4e276 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -128,22 +128,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { decoder::get_method_arg_names(&cdata, did.index) } - fn relative_item_path(&self, def: DefId) -> Vec { - let cdata = self.get_crate_data(def.krate); - decoder::get_item_path(&cdata, def.index) - } - - fn extern_item_path(&self, def: DefId) -> Vec { - let cdata = self.get_crate_data(def.krate); - let path = decoder::get_item_path(&cdata, def.index); - - let mut r = Vec::with_capacity(path.len() + 1); - let crate_name = hir_map::PathMod(token::intern(&cdata.name)); - r.push(crate_name); - r.extend_from_slice(&path); - r - } - fn item_name(&self, def: DefId) -> ast::Name { let cdata = self.get_crate_data(def.krate); decoder::get_item_name(&self.intr, &cdata, def.index) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index e6f538255ac26..6b53edbbff1d8 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -255,22 +255,6 @@ fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &TyCtxt<'tcx>, cdata: Cmd) doc_trait_ref(tp, tcx, cdata) } -fn item_path(item_doc: rbml::Doc) -> Vec { - let path_doc = reader::get_doc(item_doc, tag_path); - reader::docs(path_doc).filter_map(|(tag, elt_doc)| { - if tag == tag_path_elem_mod { - let s = elt_doc.as_str_slice(); - Some(hir_map::PathMod(token::intern(s))) - } else if tag == tag_path_elem_name { - let s = elt_doc.as_str_slice(); - Some(hir_map::PathName(token::intern(s))) - } else { - // ignore tag_path_len element - None - } - }).collect() -} - fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name { let name = reader::get_doc(item, tag_paths_data_name); let string = name.as_str_slice(); @@ -786,10 +770,6 @@ pub fn each_top_level_item_of_crate(intr: Rc, callback) } -pub fn get_item_path(cdata: Cmd, id: DefIndex) -> Vec { - item_path(cdata.lookup_item(id)) -} - pub fn get_item_name(intr: &IdentInterner, cdata: Cmd, id: DefIndex) -> ast::Name { item_name(intr, cdata.lookup_item(id)) } @@ -803,14 +783,11 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &TyCtxt<'tcx>, id: DefIndex) krate: cdata.cnum, index: def_key(cdata, id).parent.unwrap() }; - let mut parent_path = item_path(item_doc); - parent_path.pop(); let mut parent_def_path = def_path(cdata, id); parent_def_path.data.pop(); if let Some(ast_doc) = reader::maybe_get_doc(item_doc, tag_ast as usize) { let ii = decode_inlined_item(cdata, tcx, - parent_path, parent_def_path, parent_def_id, ast_doc, @@ -823,15 +800,12 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &TyCtxt<'tcx>, id: DefIndex) krate: cdata.cnum, index: def_key(cdata, parent_def_id.index).parent.unwrap() }; - let mut grandparent_path = parent_path; - grandparent_path.pop(); let mut grandparent_def_path = parent_def_path; grandparent_def_path.data.pop(); let parent_doc = cdata.lookup_item(parent_did.index); if let Some(ast_doc) = reader::maybe_get_doc(parent_doc, tag_ast as usize) { let ii = decode_inlined_item(cdata, tcx, - grandparent_path, grandparent_def_path, grandparent_def_id, ast_doc, diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 83ffd8afbeb01..d45650159e3c8 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -31,8 +31,6 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::util::IntTypeExt; use rustc::hir::svh::Svh; -use rustc::hir::map::{LinkedPath, PathElem, PathElems}; -use rustc::hir::map as ast_map; use rustc::mir::mir_map::MirMap; use rustc::session::config; use rustc::util::nodemap::{FnvHashMap, NodeMap, NodeSet}; @@ -300,26 +298,11 @@ fn encode_enum_variant_info<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, } encode_bounds_and_type_for_item(rbml_w, ecx, index, variant_node_id); - ecx.tcx.map.with_path(variant_node_id, |path| encode_path(rbml_w, path)); rbml_w.end_tag(); disr_val = disr_val.wrap_incr(); } } -fn encode_path>(rbml_w: &mut Encoder, path: PI) { - let path = path.collect::>(); - rbml_w.start_tag(tag_path); - rbml_w.wr_tagged_u32(tag_path_len, path.len() as u32); - for pe in &path { - let tag = match *pe { - ast_map::PathMod(_) => tag_path_elem_mod, - ast_map::PathName(_) => tag_path_elem_name - }; - rbml_w.wr_tagged_str(tag, &pe.name().as_str()); - } - rbml_w.end_tag(); -} - /// Iterates through "auxiliary node IDs", which are node IDs that describe /// top-level items that are sub-items of the given item. Specifically: /// @@ -371,7 +354,6 @@ fn encode_info_for_mod(ecx: &EncodeContext, md: &hir::Mod, attrs: &[ast::Attribute], id: NodeId, - path: PathElems, name: Name, vis: hir::Visibility) { rbml_w.start_tag(tag_items_data_item); @@ -393,7 +375,6 @@ fn encode_info_for_mod(ecx: &EncodeContext, }); } - encode_path(rbml_w, path.clone()); encode_visibility(rbml_w, vis); let stab = stability::lookup_stability(ecx.tcx, ecx.tcx.map.local_def_id(id)); @@ -521,7 +502,6 @@ fn encode_info_for_struct_ctor<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, }); encode_bounds_and_type_for_item(rbml_w, ecx, index, ctor_id); encode_name(rbml_w, name); - ecx.tcx.map.with_path(ctor_id, |path| encode_path(rbml_w, path)); encode_parent_item(rbml_w, ecx.tcx.map.local_def_id(struct_id)); if ecx.item_symbols.borrow().contains_key(&ctor_id) { @@ -637,7 +617,6 @@ fn encode_info_for_associated_const<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w: &mut Encoder, index: &mut CrateIndex<'tcx>, associated_const: &ty::AssociatedConst, - impl_path: PathElems, parent_id: NodeId, impl_item_opt: Option<&hir::ImplItem>) { debug!("encode_info_for_associated_const({:?},{:?})", @@ -663,9 +642,6 @@ fn encode_info_for_associated_const<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); - let elem = ast_map::PathName(associated_const.name); - encode_path(rbml_w, impl_path.chain(Some(elem))); - if let Some(ii) = impl_item_opt { encode_attributes(rbml_w, &ii.attrs); encode_defaultness(rbml_w, ii.defaultness); @@ -683,7 +659,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w: &mut Encoder, index: &mut CrateIndex<'tcx>, m: &ty::Method<'tcx>, - impl_path: PathElems, is_default_impl: bool, parent_id: NodeId, impl_item_opt: Option<&hir::ImplItem>) { @@ -705,8 +680,6 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, let m_node_id = ecx.local_id(m.def_id); encode_bounds_and_type_for_item(rbml_w, ecx, index, m_node_id); - let elem = ast_map::PathName(m.name); - encode_path(rbml_w, impl_path.chain(Some(elem))); if let Some(impl_item) = impl_item_opt { if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node { encode_attributes(rbml_w, &impl_item.attrs); @@ -738,7 +711,6 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w: &mut Encoder, index: &mut CrateIndex<'tcx>, associated_type: &ty::AssociatedType<'tcx>, - impl_path: PathElems, parent_id: NodeId, impl_item_opt: Option<&hir::ImplItem>) { debug!("encode_info_for_associated_type({:?},{:?})", @@ -760,9 +732,6 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); - let elem = ast_map::PathName(associated_type.name); - encode_path(rbml_w, impl_path.chain(Some(elem))); - if let Some(ii) = impl_item_opt { encode_attributes(rbml_w, &ii.attrs); encode_defaultness(rbml_w, ii.defaultness); @@ -886,14 +855,13 @@ fn encode_xrefs<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w: &mut Encoder, item: &hir::Item, - index: &mut CrateIndex<'tcx>, - path: PathElems, - vis: hir::Visibility) { + index: &mut CrateIndex<'tcx>) { let tcx = ecx.tcx; debug!("encoding info for item at {}", tcx.sess.codemap().span_to_string(item.span)); + let vis = item.vis; let def_id = ecx.tcx.map.local_def_id(item.id); let stab = stability::lookup_stability(tcx, ecx.tcx.map.local_def_id(item.id)); let depr = stability::lookup_deprecation(tcx, ecx.tcx.map.local_def_id(item.id)); @@ -911,7 +879,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id); encode_symbol(ecx, rbml_w, item.id); encode_name(rbml_w, item.name); - encode_path(rbml_w, path); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); @@ -925,7 +892,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_family(rbml_w, 'C'); encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id); encode_name(rbml_w, item.name); - encode_path(rbml_w, path); encode_attributes(rbml_w, &item.attrs); encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); encode_mir(ecx, rbml_w, item.id); @@ -942,7 +908,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, let tps_len = generics.ty_params.len(); encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id); encode_name(rbml_w, item.name); - encode_path(rbml_w, path); encode_attributes(rbml_w, &item.attrs); let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs); if needs_inline || constness == hir::Constness::Const { @@ -966,7 +931,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, m, &item.attrs, item.id, - path, item.name, item.vis); } @@ -976,7 +940,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_def_id_and_key(ecx, rbml_w, def_id); encode_family(rbml_w, 'n'); encode_name(rbml_w, item.name); - encode_path(rbml_w, path); // Encode all the items in this module. for foreign_item in &fm.items { @@ -995,7 +958,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_family(rbml_w, 'y'); encode_bounds_and_type_for_item(rbml_w, ecx, index, item.id); encode_name(rbml_w, item.name); - encode_path(rbml_w, path); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); @@ -1017,7 +979,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, } encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item)); encode_mir(ecx, rbml_w, item.id); - encode_path(rbml_w, path); // Encode inherent implementations for this enumeration. encode_inherent_implementations(ecx, rbml_w, def_id); @@ -1053,7 +1014,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_item_variances(rbml_w, ecx, item.id); encode_name(rbml_w, item.name); encode_attributes(rbml_w, &item.attrs); - encode_path(rbml_w, path.clone()); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); encode_visibility(rbml_w, vis); @@ -1156,7 +1116,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, }); encode_parent_impl(rbml_w, parent); } - encode_path(rbml_w, path.clone()); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); rbml_w.end_tag(); @@ -1179,7 +1138,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w, index, &associated_const, - path.clone(), item.id, ast_item) } @@ -1188,7 +1146,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w, index, &method_type, - path.clone(), false, item.id, ast_item) @@ -1198,7 +1155,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w, index, &associated_type, - path.clone(), item.id, ast_item) } @@ -1250,7 +1206,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w.wr_tagged_u64(tag_mod_child, def_to_u64(method_def_id.def_id())); } - encode_path(rbml_w, path.clone()); // Encode inherent implementations for this trait. encode_inherent_implementations(ecx, rbml_w, def_id); @@ -1281,10 +1236,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_def_id_and_key(ecx, rbml_w, associated_const.def_id); encode_visibility(rbml_w, associated_const.vis); - let elem = ast_map::PathName(associated_const.name); - encode_path(rbml_w, - path.clone().chain(Some(elem))); - encode_family(rbml_w, 'C'); encode_bounds_and_type_for_item(rbml_w, ecx, index, @@ -1297,10 +1248,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_method_ty_fields(ecx, rbml_w, index, &method_ty); - let elem = ast_map::PathName(method_ty.name); - encode_path(rbml_w, - path.clone().chain(Some(elem))); - match method_ty.explicit_self { ty::ExplicitSelfCategory::Static => { encode_family(rbml_w, @@ -1320,11 +1267,6 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, ty::TypeTraitItem(associated_type) => { encode_name(rbml_w, associated_type.name); encode_def_id_and_key(ecx, rbml_w, associated_type.def_id); - - let elem = ast_map::PathName(associated_type.name); - encode_path(rbml_w, - path.clone().chain(Some(elem))); - encode_item_sort(rbml_w, 't'); encode_family(rbml_w, 'y'); @@ -1386,10 +1328,10 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, rbml_w: &mut Encoder, nitem: &hir::ForeignItem, - index: &mut CrateIndex<'tcx>, - path: PathElems, - abi: Abi) { + index: &mut CrateIndex<'tcx>) { + debug!("writing foreign item {}", ecx.tcx.node_path_str(nitem.id)); let def_id = ecx.tcx.map.local_def_id(nitem.id); + let abi = ecx.tcx.map.get_foreign_abi(nitem.id); index.record(def_id, rbml_w); rbml_w.start_tag(tag_items_data_item); @@ -1429,7 +1371,6 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_name(rbml_w, nitem.name); } } - encode_path(rbml_w, path); rbml_w.end_tag(); } @@ -1454,8 +1395,6 @@ fn my_visit_expr(expr: &hir::Expr, ecx.tcx.closure_kind(def_id).encode(rbml_w).unwrap(); rbml_w.end_tag(); - ecx.tcx.map.with_path(expr.id, |path| encode_path(rbml_w, path)); - assert!(ecx.mir_map.map.contains_key(&expr.id)); encode_mir(ecx, rbml_w, expr.id); @@ -1465,31 +1404,6 @@ fn my_visit_expr(expr: &hir::Expr, } } -fn my_visit_item<'a, 'tcx>(i: &hir::Item, - rbml_w: &mut Encoder, - ecx: &EncodeContext<'a, 'tcx>, - index: &mut CrateIndex<'tcx>) { - ecx.tcx.map.with_path(i.id, |path| { - encode_info_for_item(ecx, rbml_w, i, index, path, i.vis); - }); -} - -fn my_visit_foreign_item<'a, 'tcx>(ni: &hir::ForeignItem, - rbml_w: &mut Encoder, - ecx: &EncodeContext<'a, 'tcx>, - index: &mut CrateIndex<'tcx>) { - debug!("writing foreign item {}::{}", - ecx.tcx.map.path_to_string(ni.id), - ni.name); - - let abi = ecx.tcx.map.get_foreign_abi(ni.id); - ecx.tcx.map.with_path(ni.id, |path| { - encode_info_for_foreign_item(ecx, rbml_w, - ni, index, - path, abi); - }); -} - struct EncodeVisitor<'a, 'b:'a, 'c:'a, 'tcx:'c> { rbml_w_for_visit_item: &'a mut Encoder<'b>, ecx: &'a EncodeContext<'c,'tcx>, @@ -1503,11 +1417,11 @@ impl<'a, 'b, 'c, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'c, 'tcx> { } fn visit_item(&mut self, i: &'tcx hir::Item) { intravisit::walk_item(self, i); - my_visit_item(i, self.rbml_w_for_visit_item, self.ecx, self.index); + encode_info_for_item(self.ecx, self.rbml_w_for_visit_item, i, self.index); } fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) { intravisit::walk_foreign_item(self, ni); - my_visit_foreign_item(ni, self.rbml_w_for_visit_item, self.ecx, self.index); + encode_info_for_foreign_item(self.ecx, self.rbml_w_for_visit_item, ni, self.index); } } @@ -1528,7 +1442,6 @@ fn encode_info_for_items<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, &krate.module, &[], CRATE_NODE_ID, - [].iter().cloned().chain(LinkedPath::empty()), syntax::parse::token::intern(&ecx.link_meta.crate_name), hir::Public); diff --git a/src/librustc_mir/graphviz.rs b/src/librustc_mir/graphviz.rs index 959b1fdef5270..069bd7826bcdc 100644 --- a/src/librustc_mir/graphviz.rs +++ b/src/librustc_mir/graphviz.rs @@ -118,7 +118,7 @@ fn write_edges(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result /// all the variables and temporaries. fn write_graph_label(tcx: &ty::TyCtxt, nid: NodeId, mir: &Mir, w: &mut W) -> io::Result<()> { - write!(w, " label= io::Result<()> { - write!(w, "fn {}(", tcx.map.path_to_string(nid))?; + write!(w, "fn {}(", tcx.node_path_str(nid))?; // fn argument types. for (i, arg) in mir.arg_decls.iter().enumerate() { diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index c724091a2ec87..da0e8ba78cfdb 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -519,7 +519,7 @@ where D: Dump span: Span, typ: &ast::Ty, expr: &ast::Expr) { - let qualname = format!("::{}", self.tcx.map.path_to_string(id)); + let qualname = format!("::{}", self.tcx.node_path_str(id)); let sub_span = self.span.sub_span_after_keyword(span, keywords::Const); @@ -544,7 +544,7 @@ where D: Dump item: &ast::Item, def: &ast::VariantData, ty_params: &ast::Generics) { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let val = self.span.snippet(item.span); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct); @@ -677,7 +677,7 @@ where D: Dump generics: &ast::Generics, trait_refs: &ast::TyParamBounds, methods: &[ast::TraitItem]) { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let val = self.span.snippet(item.span); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait); if !self.span.filter_generated(sub_span, item.span) { @@ -1108,7 +1108,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> { self.nest(item.id, |v| visit::walk_mod(v, m)); } Ty(ref ty, ref ty_params) => { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let value = ty_to_string(&ty); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); if !self.span.filter_generated(sub_span, item.span) { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 98c0be1c93c15..da4c8770b7e36 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -116,7 +116,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_item_data(&self, item: &ast::Item) -> Option { match item.node { ast::ItemKind::Fn(..) => { - let name = self.tcx.map.path_to_string(item.id); + let name = self.tcx.node_path_str(item.id); let qualname = format!("::{}", name); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn); filter!(self.span_utils, sub_span, item.span, None); @@ -130,7 +130,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { })) } ast::ItemKind::Static(ref typ, mt, ref expr) => { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); // If the variable is immutable, save the initialising expression. let (value, keyword) = match mt { @@ -153,7 +153,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { })) } ast::ItemKind::Const(ref typ, ref expr) => { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const); filter!(self.span_utils, sub_span, item.span, None); Some(Data::VariableData(VariableData { @@ -167,7 +167,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { })) } ast::ItemKind::Mod(ref m) => { - let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let cm = self.tcx.sess.codemap(); let filename = cm.span_to_filename(m.inner); @@ -184,7 +184,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { })) } ast::ItemKind::Enum(..) => { - let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id)); + let enum_name = format!("::{}", self.tcx.node_path_str(item.id)); let val = self.span_utils.snippet(item.span); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Enum); filter!(self.span_utils, sub_span, item.span, None); @@ -246,7 +246,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { scope: NodeId) -> Option { match field.node.kind { ast::NamedField(ident, _) => { - let qualname = format!("::{}::{}", self.tcx.map.path_to_string(scope), ident); + let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident); let typ = self.tcx.node_types().get(&field.node.id).unwrap().to_string(); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); filter!(self.span_utils, sub_span, field.span, None); diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 4f1585eeaca3b..c8ed4e629e4c1 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1351,7 +1351,7 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option) { None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None), _ => bug!("unexpected variant in has_nested_returns: {}", - tcx.map.path_to_string(id)), + tcx.node_path_str(id)), }; (blk.id, Some(cfg::CFG::new(tcx, blk))) @@ -1412,9 +1412,7 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> { let local_id = def_id.and_then(|id| ccx.tcx().map.as_local_node_id(id)); debug!("FunctionContext::new(path={}, def_id={:?}, param_substs={:?})", - inlined_id.map_or(String::new(), |id| { - ccx.tcx().map.path_to_string(id).to_string() - }), + inlined_id.map_or(String::new(), |id| ccx.tcx().node_path_str(id)), def_id, param_substs); @@ -1906,7 +1904,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, llfndecl: ValueRef, param_substs: &'tcx Substs<'tcx>, id: ast::NodeId) { - let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string()); + let _s = StatRecorder::new(ccx, ccx.tcx().node_path_str(id)); debug!("trans_fn(param_substs={:?})", param_substs); let _icx = push_ctxt("trans_fn"); let fn_ty = ccx.tcx().node_id_to_type(id); @@ -2446,8 +2444,7 @@ pub fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, _ => { if attr::contains_name(attrs, "no_mangle") { // Don't mangle - let path = ccx.tcx().map.def_path_from_id(id); - path.data.last().unwrap().data.to_string() + ccx.tcx().map.name(id).as_str().to_string() } else { match weak_lang_items::link_name(attrs) { Some(name) => name.to_string(), diff --git a/src/librustc_trans/debuginfo/namespace.rs b/src/librustc_trans/debuginfo/namespace.rs index c1487f56956fc..5272a4fbbb76b 100644 --- a/src/librustc_trans/debuginfo/namespace.rs +++ b/src/librustc_trans/debuginfo/namespace.rs @@ -19,6 +19,7 @@ use rustc::hir::map as hir_map; use common::CrateContext; use std::ffi::CString; +use std::iter::once; use std::ptr; use std::rc::{Rc, Weak}; use syntax::ast; @@ -51,85 +52,76 @@ impl NamespaceTreeNode { } } -pub fn crate_root_namespace<'a>(cx: &'a CrateContext) -> &'a str { - &cx.link_meta().crate_name -} - pub fn namespace_for_item(cx: &CrateContext, def_id: DefId) -> Rc { - cx.tcx().with_path(def_id, |path| { - // prepend crate name if not already present - let krate = if def_id.is_local() { - let crate_namespace_name = token::intern(crate_root_namespace(cx)); - Some(hir_map::PathMod(crate_namespace_name)) - } else { - None + // prepend crate name. + // This shouldn't need a roundtrip through InternedString. + let krate = token::intern(&cx.tcx().crate_name(def_id.krate)); + let krate = hir_map::DefPathData::TypeNs(krate); + let path = cx.tcx().def_path(def_id).data; + let mut path = once(krate).chain(path.into_iter().map(|e| e.data)).peekable(); + + let mut current_key = Vec::new(); + let mut parent_node: Option> = None; + + // Create/Lookup namespace for each element of the path. + loop { + // Emulate a for loop so we can use peek below. + let path_element = match path.next() { + Some(e) => e, + None => break }; - let mut path = krate.into_iter().chain(path).peekable(); - - let mut current_key = Vec::new(); - let mut parent_node: Option> = None; - - // Create/Lookup namespace for each element of the path. - loop { - // Emulate a for loop so we can use peek below. - let path_element = match path.next() { - Some(e) => e, - None => break - }; - // Ignore the name of the item (the last path element). - if path.peek().is_none() { - break; - } - - let name = path_element.name(); - current_key.push(name); - - let existing_node = debug_context(cx).namespace_map.borrow() - .get(¤t_key).cloned(); - let current_node = match existing_node { - Some(existing_node) => existing_node, - None => { - // create and insert - let parent_scope = match parent_node { - Some(ref node) => node.scope, - None => ptr::null_mut() - }; - let namespace_name = name.as_str(); - let namespace_name = CString::new(namespace_name.as_bytes()).unwrap(); - let scope = unsafe { - llvm::LLVMDIBuilderCreateNameSpace( - DIB(cx), - parent_scope, - namespace_name.as_ptr(), - // cannot reconstruct file ... - ptr::null_mut(), - // ... or line information, but that's not so important. - 0) - }; - - let node = Rc::new(NamespaceTreeNode { - name: name, - scope: scope, - parent: parent_node.map(|parent| Rc::downgrade(&parent)), - }); - - debug_context(cx).namespace_map.borrow_mut() - .insert(current_key.clone(), node.clone()); - - node - } - }; - - parent_node = Some(current_node); + // Ignore the name of the item (the last path element). + if path.peek().is_none() { + break; } - match parent_node { - Some(node) => node, + // This shouldn't need a roundtrip through InternedString. + let namespace_name = path_element.as_interned_str(); + let name = token::intern(&namespace_name); + current_key.push(name); + + let existing_node = debug_context(cx).namespace_map.borrow() + .get(¤t_key).cloned(); + let current_node = match existing_node { + Some(existing_node) => existing_node, None => { - bug!("debuginfo::namespace_for_item(): \ - path too short for {:?}", - def_id); + // create and insert + let parent_scope = match parent_node { + Some(ref node) => node.scope, + None => ptr::null_mut() + }; + let namespace_name = CString::new(namespace_name.as_bytes()).unwrap(); + let scope = unsafe { + llvm::LLVMDIBuilderCreateNameSpace( + DIB(cx), + parent_scope, + namespace_name.as_ptr(), + // cannot reconstruct file ... + ptr::null_mut(), + // ... or line information, but that's not so important. + 0) + }; + + let node = Rc::new(NamespaceTreeNode { + name: name, + scope: scope, + parent: parent_node.map(|parent| Rc::downgrade(&parent)), + }); + + debug_context(cx).namespace_map.borrow_mut() + .insert(current_key.clone(), node.clone()); + + node } + }; + + parent_node = Some(current_node); + } + + match parent_node { + Some(node) => node, + None => { + bug!("debuginfo::namespace_for_item: path too short for {:?}", def_id); } - }) + } } diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 0169734ad3b7c..6fdd6a2c1d111 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -10,8 +10,6 @@ // Type Names for Debug Info. -use super::namespace::crate_root_namespace; - use common::CrateContext; use rustc::hir::def_id::DefId; use rustc::infer; @@ -163,31 +161,15 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, def_id: DefId, qualified: bool, output: &mut String) { - cx.tcx().with_path(def_id, |path| { - if qualified { - if def_id.is_local() { - output.push_str(crate_root_namespace(cx)); - output.push_str("::"); - } - - let mut path_element_count = 0; - for path_element in path { - output.push_str(&path_element.name().as_str()); - output.push_str("::"); - path_element_count += 1; - } - - if path_element_count == 0 { - bug!("debuginfo: Encountered empty item path!"); - } - - output.pop(); - output.pop(); - } else { - let name = path.last().expect("debuginfo: Empty item path?").name(); - output.push_str(&name.as_str()); + if qualified { + output.push_str(&cx.tcx().crate_name(def_id.krate)); + for path_element in cx.tcx().def_path(def_id).data { + output.push_str("::"); + output.push_str(&path_element.data.as_interned_str()); } - }); + } else { + output.push_str(&cx.tcx().item_name(def_id).as_str()); + } } // Pushes the type parameters in the given `Substs` to the output string. diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 70997a1a6eed2..8c65eb8dbd367 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -11,6 +11,7 @@ //! Support for inlining external documentation into the current AST. use std::collections::HashSet; +use std::iter::once; use syntax::ast; use syntax::attr::AttrMetaMethods; @@ -140,8 +141,11 @@ pub fn load_attrs(cx: &DocContext, tcx: &TyCtxt, /// source links back to the original item. pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) { if let Some(tcx) = cx.tcx_opt() { - let fqn = tcx.sess.cstore.extern_item_path(did); - let fqn = fqn.into_iter().map(|i| i.to_string()).collect(); + let crate_name = tcx.sess.cstore.crate_name(did.krate).to_string(); + let relative = tcx.def_path(did).data.into_iter().map(|elem| { + elem.data.to_string() + }); + let fqn = once(crate_name).chain(relative).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, kind)); } } diff --git a/src/test/run-make/pretty-print-path-suffix/foo_method.pp b/src/test/run-make/pretty-print-path-suffix/foo_method.pp index 4879fbfe6d343..696e0544fdc57 100644 --- a/src/test/run-make/pretty-print-path-suffix/foo_method.pp +++ b/src/test/run-make/pretty-print-path-suffix/foo_method.pp @@ -13,4 +13,4 @@ fn foo_method(&self) -> &'static str { return "i am very similar to foo."; } -/* nest::S::foo_method */ +/* nest::{{impl}}::foo_method */