mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 03:44:24 +00:00
Auto merge of #39309 - eddyb:map-shmap, r=nikomatsakis
Rename tcx.map to the far more descriptive tcx.hir. Also a bit more renaming because `ast_map` and `'ast` were still used with HIR. Main motivation is to "free up" `tcx.map`, or rather, `tcx.maps`, to consolidate `ty::maps` there. r? @nikomatsakis
This commit is contained in:
commit
491b978822
@ -46,18 +46,18 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// Find the function this expression is from.
|
||||
let mut node_id = body.id;
|
||||
loop {
|
||||
let node = tcx.map.get(node_id);
|
||||
let node = tcx.hir.get(node_id);
|
||||
if hir::map::blocks::FnLikeNode::from_node(node).is_some() {
|
||||
break;
|
||||
}
|
||||
let parent = tcx.map.get_parent_node(node_id);
|
||||
let parent = tcx.hir.get_parent_node(node_id);
|
||||
assert!(node_id != parent);
|
||||
node_id = parent;
|
||||
}
|
||||
|
||||
let mut cfg_builder = CFGBuilder {
|
||||
tcx: tcx,
|
||||
tables: tcx.item_tables(tcx.map.local_def_id(node_id)),
|
||||
tables: tcx.item_tables(tcx.hir.local_def_id(node_id)),
|
||||
graph: graph,
|
||||
fn_exit: fn_exit,
|
||||
loop_scopes: Vec::new()
|
||||
|
@ -17,14 +17,14 @@ use graphviz::IntoCow;
|
||||
|
||||
use syntax::ast;
|
||||
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use cfg;
|
||||
|
||||
pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode);
|
||||
pub type Edge<'a> = &'a cfg::CFGEdge;
|
||||
|
||||
pub struct LabelledCFG<'a, 'ast: 'a> {
|
||||
pub ast_map: &'a ast_map::Map<'ast>,
|
||||
pub struct LabelledCFG<'a, 'hir: 'a> {
|
||||
pub hir_map: &'a hir_map::Map<'hir>,
|
||||
pub cfg: &'a cfg::CFG,
|
||||
pub name: String,
|
||||
/// `labelled_edges` controls whether we emit labels on the edges
|
||||
@ -52,7 +52,7 @@ fn replace_newline_with_backslash_l(s: String) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> {
|
||||
impl<'a, 'hir> dot::Labeller<'a> for LabelledCFG<'a, 'hir> {
|
||||
type Node = Node<'a>;
|
||||
type Edge = Edge<'a>;
|
||||
fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(&self.name[..]).unwrap() }
|
||||
@ -69,7 +69,7 @@ impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> {
|
||||
} else if n.data.id() == ast::DUMMY_NODE_ID {
|
||||
dot::LabelText::LabelStr("(dummy_node)".into_cow())
|
||||
} else {
|
||||
let s = self.ast_map.node_to_string(n.data.id());
|
||||
let s = self.hir_map.node_to_string(n.data.id());
|
||||
// left-aligns the lines
|
||||
let s = replace_newline_with_backslash_l(s);
|
||||
dot::LabelText::EscStr(s.into_cow())
|
||||
@ -88,7 +88,7 @@ impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> {
|
||||
} else {
|
||||
put_one = true;
|
||||
}
|
||||
let s = self.ast_map.node_to_string(node_id);
|
||||
let s = self.hir_map.node_to_string(node_id);
|
||||
// left-aligns the lines
|
||||
let s = replace_newline_with_backslash_l(s);
|
||||
label.push_str(&format!("exiting scope_{} {}",
|
||||
@ -120,7 +120,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'ast> dot::GraphWalk<'a> for LabelledCFG<'a, 'ast>
|
||||
impl<'a, 'hir> dot::GraphWalk<'a> for LabelledCFG<'a, 'hir>
|
||||
{
|
||||
type Node = Node<'a>;
|
||||
type Edge = Edge<'a>;
|
||||
|
@ -29,10 +29,10 @@ pub enum DepNode<D: Clone + Debug> {
|
||||
// Represents the `Krate` as a whole (the `hir::Krate` value) (as
|
||||
// distinct from the krate module). This is basically a hash of
|
||||
// the entire krate, so if you read from `Krate` (e.g., by calling
|
||||
// `tcx.map.krate()`), we will have to assume that any change
|
||||
// `tcx.hir.krate()`), we will have to assume that any change
|
||||
// means that you need to be recompiled. This is because the
|
||||
// `Krate` value gives you access to all other items. To avoid
|
||||
// this fate, do not call `tcx.map.krate()`; instead, prefer
|
||||
// this fate, do not call `tcx.hir.krate()`; instead, prefer
|
||||
// wrappers like `tcx.visit_all_items_in_krate()`. If there is no
|
||||
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
|
||||
// access to the krate, but you must remember to add suitable
|
||||
|
@ -117,7 +117,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
|
||||
///
|
||||
/// ```
|
||||
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
|
||||
/// let item_def_id = ccx.tcx.map.local_def_id(it.id);
|
||||
/// let item_def_id = ccx.tcx.hir.local_def_id(it.id);
|
||||
/// ccx.tcx.item_types.memoized(item_def_id, || {
|
||||
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
|
||||
/// compute_type_of_item(ccx, item)
|
||||
|
@ -36,7 +36,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
where F: FnMut(DefId) -> DepNode<DefId>, V: ItemLikeVisitor<'tcx>
|
||||
{
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.map.local_def_id(i.id);
|
||||
let item_def_id = self.tcx.hir.local_def_id(i.id);
|
||||
let task_id = (self.dep_node_fn)(item_def_id);
|
||||
let _task = self.tcx.dep_graph.in_task(task_id.clone());
|
||||
debug!("Started task {:?}", task_id);
|
||||
@ -46,7 +46,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, i: &'tcx hir::TraitItem) {
|
||||
let trait_item_def_id = self.tcx.map.local_def_id(i.id);
|
||||
let trait_item_def_id = self.tcx.hir.local_def_id(i.id);
|
||||
let task_id = (self.dep_node_fn)(trait_item_def_id);
|
||||
let _task = self.tcx.dep_graph.in_task(task_id.clone());
|
||||
debug!("Started task {:?}", task_id);
|
||||
@ -56,7 +56,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
|
||||
let impl_item_def_id = self.tcx.map.local_def_id(i.id);
|
||||
let impl_item_def_id = self.tcx.hir.local_def_id(i.id);
|
||||
let task_id = (self.dep_node_fn)(impl_item_def_id);
|
||||
let _task = self.tcx.dep_graph.in_task(task_id.clone());
|
||||
debug!("Started task {:?}", task_id);
|
||||
@ -66,7 +66,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||
}
|
||||
}
|
||||
|
||||
let krate = tcx.dep_graph.with_ignore(|| tcx.map.krate());
|
||||
let krate = tcx.dep_graph.with_ignore(|| tcx.hir.krate());
|
||||
let mut tracking_visitor = TrackingVisitor {
|
||||
tcx: tcx,
|
||||
dep_node_fn: &mut dep_node_fn,
|
||||
|
@ -1085,13 +1085,13 @@ impl IdRange {
|
||||
}
|
||||
|
||||
|
||||
pub struct IdRangeComputingVisitor<'a, 'ast: 'a> {
|
||||
pub struct IdRangeComputingVisitor<'a, 'hir: 'a> {
|
||||
result: IdRange,
|
||||
map: &'a map::Map<'ast>,
|
||||
map: &'a map::Map<'hir>,
|
||||
}
|
||||
|
||||
impl<'a, 'ast> IdRangeComputingVisitor<'a, 'ast> {
|
||||
pub fn new(map: &'a map::Map<'ast>) -> IdRangeComputingVisitor<'a, 'ast> {
|
||||
impl<'a, 'hir> IdRangeComputingVisitor<'a, 'hir> {
|
||||
pub fn new(map: &'a map::Map<'hir>) -> IdRangeComputingVisitor<'a, 'hir> {
|
||||
IdRangeComputingVisitor { result: IdRange::max(), map: map }
|
||||
}
|
||||
|
||||
@ -1100,8 +1100,8 @@ impl<'a, 'ast> IdRangeComputingVisitor<'a, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Visitor<'ast> for IdRangeComputingVisitor<'a, 'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
impl<'a, 'hir> Visitor<'hir> for IdRangeComputingVisitor<'a, 'hir> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
NestedVisitorMap::OnlyBodies(&self.map)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ use super::intravisit::Visitor;
|
||||
/// - How: Implement `intravisit::Visitor` and override the
|
||||
/// `visit_nested_map()` methods to return
|
||||
/// `NestedVisitorMap::All`. Walk your crate with
|
||||
/// `intravisit::walk_crate()` invoked on `tcx.map.krate()`.
|
||||
/// `intravisit::walk_crate()` invoked on `tcx.hir.krate()`.
|
||||
/// - Pro: Visitor methods for any kind of HIR node, not just item-like things.
|
||||
/// - Pro: Preserves nesting information
|
||||
/// - Con: Does not integrate well into dependency tracking.
|
||||
|
@ -16,17 +16,17 @@ use syntax::ast::{NodeId, CRATE_NODE_ID};
|
||||
use syntax_pos::Span;
|
||||
|
||||
/// A Visitor that walks over the HIR and collects Nodes into a HIR map
|
||||
pub struct NodeCollector<'ast> {
|
||||
pub struct NodeCollector<'hir> {
|
||||
/// The crate
|
||||
pub krate: &'ast Crate,
|
||||
pub krate: &'hir Crate,
|
||||
/// The node map
|
||||
pub(super) map: Vec<MapEntry<'ast>>,
|
||||
pub(super) map: Vec<MapEntry<'hir>>,
|
||||
/// The parent of this node
|
||||
pub parent_node: NodeId,
|
||||
}
|
||||
|
||||
impl<'ast> NodeCollector<'ast> {
|
||||
pub fn root(krate: &'ast Crate) -> NodeCollector<'ast> {
|
||||
impl<'hir> NodeCollector<'hir> {
|
||||
pub fn root(krate: &'hir Crate) -> NodeCollector<'hir> {
|
||||
let mut collector = NodeCollector {
|
||||
krate: krate,
|
||||
map: vec![],
|
||||
@ -37,8 +37,8 @@ impl<'ast> NodeCollector<'ast> {
|
||||
collector
|
||||
}
|
||||
|
||||
fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) {
|
||||
debug!("ast_map: {:?} => {:?}", id, entry);
|
||||
fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'hir>) {
|
||||
debug!("hir_map: {:?} => {:?}", id, entry);
|
||||
let len = self.map.len();
|
||||
if id.as_usize() >= len {
|
||||
self.map.extend(repeat(NotPresent).take(id.as_usize() - len + 1));
|
||||
@ -46,7 +46,7 @@ impl<'ast> NodeCollector<'ast> {
|
||||
self.map[id.as_usize()] = entry;
|
||||
}
|
||||
|
||||
fn insert(&mut self, id: NodeId, node: Node<'ast>) {
|
||||
fn insert(&mut self, id: NodeId, node: Node<'hir>) {
|
||||
let entry = MapEntry::from_node(self.parent_node, node);
|
||||
self.insert_entry(id, entry);
|
||||
}
|
||||
@ -59,12 +59,12 @@ impl<'ast> NodeCollector<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
impl<'hir> Visitor<'hir> for NodeCollector<'hir> {
|
||||
/// Because we want to track parent items and so forth, enable
|
||||
/// deep walking so that we walk nested items in the context of
|
||||
/// their outer items.
|
||||
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
panic!("visit_nested_xxx must be manually implemented in this visitor")
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
self.visit_body(self.krate.body(id));
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'ast Item) {
|
||||
fn visit_item(&mut self, i: &'hir Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
|
||||
self.insert(i.id, NodeItem(i));
|
||||
@ -104,7 +104,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) {
|
||||
self.insert(foreign_item.id, NodeForeignItem(foreign_item));
|
||||
|
||||
self.with_parent(foreign_item.id, |this| {
|
||||
@ -112,7 +112,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_generics(&mut self, generics: &'ast Generics) {
|
||||
fn visit_generics(&mut self, generics: &'hir Generics) {
|
||||
for ty_param in generics.ty_params.iter() {
|
||||
self.insert(ty_param.id, NodeTyParam(ty_param));
|
||||
}
|
||||
@ -120,7 +120,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
intravisit::walk_generics(self, generics);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
|
||||
self.insert(ti.id, NodeTraitItem(ti));
|
||||
|
||||
self.with_parent(ti.id, |this| {
|
||||
@ -128,7 +128,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &'hir ImplItem) {
|
||||
self.insert(ii.id, NodeImplItem(ii));
|
||||
|
||||
self.with_parent(ii.id, |this| {
|
||||
@ -136,7 +136,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'ast Pat) {
|
||||
fn visit_pat(&mut self, pat: &'hir Pat) {
|
||||
let node = if let PatKind::Binding(..) = pat.node {
|
||||
NodeLocal(pat)
|
||||
} else {
|
||||
@ -149,7 +149,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'ast Expr) {
|
||||
fn visit_expr(&mut self, expr: &'hir Expr) {
|
||||
self.insert(expr.id, NodeExpr(expr));
|
||||
|
||||
self.with_parent(expr.id, |this| {
|
||||
@ -157,7 +157,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'ast Stmt) {
|
||||
fn visit_stmt(&mut self, stmt: &'hir Stmt) {
|
||||
let id = stmt.node.id();
|
||||
self.insert(id, NodeStmt(stmt));
|
||||
|
||||
@ -166,7 +166,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'ast Ty) {
|
||||
fn visit_ty(&mut self, ty: &'hir Ty) {
|
||||
self.insert(ty.id, NodeTy(ty));
|
||||
|
||||
self.with_parent(ty.id, |this| {
|
||||
@ -174,7 +174,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_trait_ref(&mut self, tr: &'ast TraitRef) {
|
||||
fn visit_trait_ref(&mut self, tr: &'hir TraitRef) {
|
||||
self.insert(tr.ref_id, NodeTraitRef(tr));
|
||||
|
||||
self.with_parent(tr.ref_id, |this| {
|
||||
@ -182,24 +182,24 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: intravisit::FnKind<'ast>, fd: &'ast FnDecl,
|
||||
fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
|
||||
b: BodyId, s: Span, id: NodeId) {
|
||||
assert_eq!(self.parent_node, id);
|
||||
intravisit::walk_fn(self, fk, fd, b, s, id);
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, block: &'ast Block) {
|
||||
fn visit_block(&mut self, block: &'hir Block) {
|
||||
self.insert(block.id, NodeBlock(block));
|
||||
self.with_parent(block.id, |this| {
|
||||
intravisit::walk_block(this, block);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) {
|
||||
fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) {
|
||||
self.insert(lifetime.id, NodeLifetime(lifetime));
|
||||
}
|
||||
|
||||
fn visit_vis(&mut self, visibility: &'ast Visibility) {
|
||||
fn visit_vis(&mut self, visibility: &'hir Visibility) {
|
||||
match *visibility {
|
||||
Visibility::Public |
|
||||
Visibility::Crate |
|
||||
@ -213,11 +213,11 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) {
|
||||
fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) {
|
||||
self.insert_entry(macro_def.id, NotPresent);
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, v: &'ast Variant, g: &'ast Generics, item_id: NodeId) {
|
||||
fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: NodeId) {
|
||||
let id = v.node.data.id();
|
||||
self.insert(id, NodeVariant(v));
|
||||
self.with_parent(id, |this| {
|
||||
@ -225,7 +225,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_struct_field(&mut self, field: &'ast StructField) {
|
||||
fn visit_struct_field(&mut self, field: &'hir StructField) {
|
||||
self.insert(field.id, NodeField(field));
|
||||
self.with_parent(field.id, |this| {
|
||||
intravisit::walk_struct_field(this, field);
|
||||
|
@ -38,67 +38,67 @@ mod def_collector;
|
||||
pub mod definitions;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Node<'ast> {
|
||||
NodeItem(&'ast Item),
|
||||
NodeForeignItem(&'ast ForeignItem),
|
||||
NodeTraitItem(&'ast TraitItem),
|
||||
NodeImplItem(&'ast ImplItem),
|
||||
NodeVariant(&'ast Variant),
|
||||
NodeField(&'ast StructField),
|
||||
NodeExpr(&'ast Expr),
|
||||
NodeStmt(&'ast Stmt),
|
||||
NodeTy(&'ast Ty),
|
||||
NodeTraitRef(&'ast TraitRef),
|
||||
NodeLocal(&'ast Pat),
|
||||
NodePat(&'ast Pat),
|
||||
NodeBlock(&'ast Block),
|
||||
pub enum Node<'hir> {
|
||||
NodeItem(&'hir Item),
|
||||
NodeForeignItem(&'hir ForeignItem),
|
||||
NodeTraitItem(&'hir TraitItem),
|
||||
NodeImplItem(&'hir ImplItem),
|
||||
NodeVariant(&'hir Variant),
|
||||
NodeField(&'hir StructField),
|
||||
NodeExpr(&'hir Expr),
|
||||
NodeStmt(&'hir Stmt),
|
||||
NodeTy(&'hir Ty),
|
||||
NodeTraitRef(&'hir TraitRef),
|
||||
NodeLocal(&'hir Pat),
|
||||
NodePat(&'hir Pat),
|
||||
NodeBlock(&'hir Block),
|
||||
|
||||
/// NodeStructCtor represents a tuple struct.
|
||||
NodeStructCtor(&'ast VariantData),
|
||||
NodeStructCtor(&'hir VariantData),
|
||||
|
||||
NodeLifetime(&'ast Lifetime),
|
||||
NodeTyParam(&'ast TyParam),
|
||||
NodeVisibility(&'ast Visibility),
|
||||
NodeLifetime(&'hir Lifetime),
|
||||
NodeTyParam(&'hir TyParam),
|
||||
NodeVisibility(&'hir Visibility),
|
||||
}
|
||||
|
||||
/// Represents an entry and its parent NodeID.
|
||||
/// The odd layout is to bring down the total size.
|
||||
#[derive(Copy, Debug)]
|
||||
enum MapEntry<'ast> {
|
||||
enum MapEntry<'hir> {
|
||||
/// Placeholder for holes in the map.
|
||||
NotPresent,
|
||||
|
||||
/// All the node types, with a parent ID.
|
||||
EntryItem(NodeId, &'ast Item),
|
||||
EntryForeignItem(NodeId, &'ast ForeignItem),
|
||||
EntryTraitItem(NodeId, &'ast TraitItem),
|
||||
EntryImplItem(NodeId, &'ast ImplItem),
|
||||
EntryVariant(NodeId, &'ast Variant),
|
||||
EntryField(NodeId, &'ast StructField),
|
||||
EntryExpr(NodeId, &'ast Expr),
|
||||
EntryStmt(NodeId, &'ast Stmt),
|
||||
EntryTy(NodeId, &'ast Ty),
|
||||
EntryTraitRef(NodeId, &'ast TraitRef),
|
||||
EntryLocal(NodeId, &'ast Pat),
|
||||
EntryPat(NodeId, &'ast Pat),
|
||||
EntryBlock(NodeId, &'ast Block),
|
||||
EntryStructCtor(NodeId, &'ast VariantData),
|
||||
EntryLifetime(NodeId, &'ast Lifetime),
|
||||
EntryTyParam(NodeId, &'ast TyParam),
|
||||
EntryVisibility(NodeId, &'ast Visibility),
|
||||
EntryItem(NodeId, &'hir Item),
|
||||
EntryForeignItem(NodeId, &'hir ForeignItem),
|
||||
EntryTraitItem(NodeId, &'hir TraitItem),
|
||||
EntryImplItem(NodeId, &'hir ImplItem),
|
||||
EntryVariant(NodeId, &'hir Variant),
|
||||
EntryField(NodeId, &'hir StructField),
|
||||
EntryExpr(NodeId, &'hir Expr),
|
||||
EntryStmt(NodeId, &'hir Stmt),
|
||||
EntryTy(NodeId, &'hir Ty),
|
||||
EntryTraitRef(NodeId, &'hir TraitRef),
|
||||
EntryLocal(NodeId, &'hir Pat),
|
||||
EntryPat(NodeId, &'hir Pat),
|
||||
EntryBlock(NodeId, &'hir Block),
|
||||
EntryStructCtor(NodeId, &'hir VariantData),
|
||||
EntryLifetime(NodeId, &'hir Lifetime),
|
||||
EntryTyParam(NodeId, &'hir TyParam),
|
||||
EntryVisibility(NodeId, &'hir Visibility),
|
||||
|
||||
/// Roots for node trees.
|
||||
RootCrate,
|
||||
}
|
||||
|
||||
impl<'ast> Clone for MapEntry<'ast> {
|
||||
fn clone(&self) -> MapEntry<'ast> {
|
||||
impl<'hir> Clone for MapEntry<'hir> {
|
||||
fn clone(&self) -> MapEntry<'hir> {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> MapEntry<'ast> {
|
||||
fn from_node(p: NodeId, node: Node<'ast>) -> MapEntry<'ast> {
|
||||
impl<'hir> MapEntry<'hir> {
|
||||
fn from_node(p: NodeId, node: Node<'hir>) -> MapEntry<'hir> {
|
||||
match node {
|
||||
NodeItem(n) => EntryItem(p, n),
|
||||
NodeForeignItem(n) => EntryForeignItem(p, n),
|
||||
@ -145,7 +145,7 @@ impl<'ast> MapEntry<'ast> {
|
||||
})
|
||||
}
|
||||
|
||||
fn to_node(self) -> Option<Node<'ast>> {
|
||||
fn to_node(self) -> Option<Node<'hir>> {
|
||||
Some(match self {
|
||||
EntryItem(_, n) => NodeItem(n),
|
||||
EntryForeignItem(_, n) => NodeForeignItem(n),
|
||||
@ -225,7 +225,7 @@ impl Forest {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn krate<'ast>(&'ast self) -> &'ast Crate {
|
||||
pub fn krate<'hir>(&'hir self) -> &'hir Crate {
|
||||
self.dep_graph.read(DepNode::Krate);
|
||||
&self.krate
|
||||
}
|
||||
@ -234,9 +234,9 @@ impl Forest {
|
||||
/// Represents a mapping from Node IDs to AST elements and their parent
|
||||
/// Node IDs
|
||||
#[derive(Clone)]
|
||||
pub struct Map<'ast> {
|
||||
pub struct Map<'hir> {
|
||||
/// The backing storage for all the AST nodes.
|
||||
pub forest: &'ast Forest,
|
||||
pub forest: &'hir Forest,
|
||||
|
||||
/// Same as the dep_graph in forest, just available with one fewer
|
||||
/// deref. This is a gratuitious micro-optimization.
|
||||
@ -251,15 +251,15 @@ pub struct Map<'ast> {
|
||||
///
|
||||
/// Also, indexing is pretty quick when you've got a vector and
|
||||
/// plain old integers.
|
||||
map: Vec<MapEntry<'ast>>,
|
||||
map: Vec<MapEntry<'hir>>,
|
||||
|
||||
definitions: Definitions,
|
||||
|
||||
/// Bodies inlined from other crates are cached here.
|
||||
inlined_bodies: RefCell<DefIdMap<&'ast Body>>,
|
||||
inlined_bodies: RefCell<DefIdMap<&'hir Body>>,
|
||||
}
|
||||
|
||||
impl<'ast> Map<'ast> {
|
||||
impl<'hir> Map<'hir> {
|
||||
/// Registers a read in the dependency graph of the AST node with
|
||||
/// the given `id`. This needs to be called each time a public
|
||||
/// function returns the HIR for a node -- in other words, when it
|
||||
@ -388,15 +388,15 @@ impl<'ast> Map<'ast> {
|
||||
self.map.len()
|
||||
}
|
||||
|
||||
fn find_entry(&self, id: NodeId) -> Option<MapEntry<'ast>> {
|
||||
fn find_entry(&self, id: NodeId) -> Option<MapEntry<'hir>> {
|
||||
self.map.get(id.as_usize()).cloned()
|
||||
}
|
||||
|
||||
pub fn krate(&self) -> &'ast Crate {
|
||||
pub fn krate(&self) -> &'hir Crate {
|
||||
self.forest.krate()
|
||||
}
|
||||
|
||||
pub fn trait_item(&self, id: TraitItemId) -> &'ast TraitItem {
|
||||
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem {
|
||||
self.read(id.node_id);
|
||||
|
||||
// NB: intentionally bypass `self.forest.krate()` so that we
|
||||
@ -404,7 +404,7 @@ impl<'ast> Map<'ast> {
|
||||
self.forest.krate.trait_item(id)
|
||||
}
|
||||
|
||||
pub fn impl_item(&self, id: ImplItemId) -> &'ast ImplItem {
|
||||
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem {
|
||||
self.read(id.node_id);
|
||||
|
||||
// NB: intentionally bypass `self.forest.krate()` so that we
|
||||
@ -412,7 +412,7 @@ impl<'ast> Map<'ast> {
|
||||
self.forest.krate.impl_item(id)
|
||||
}
|
||||
|
||||
pub fn body(&self, id: BodyId) -> &'ast Body {
|
||||
pub fn body(&self, id: BodyId) -> &'hir Body {
|
||||
self.read(id.node_id);
|
||||
|
||||
// NB: intentionally bypass `self.forest.krate()` so that we
|
||||
@ -440,7 +440,7 @@ impl<'ast> Map<'ast> {
|
||||
/// Get the attributes on the krate. This is preferable to
|
||||
/// invoking `krate.attrs` because it registers a tighter
|
||||
/// dep-graph access.
|
||||
pub fn krate_attrs(&self) -> &'ast [ast::Attribute] {
|
||||
pub fn krate_attrs(&self) -> &'hir [ast::Attribute] {
|
||||
let crate_root_def_id = DefId::local(CRATE_DEF_INDEX);
|
||||
self.dep_graph.read(DepNode::Hir(crate_root_def_id));
|
||||
&self.forest.krate.attrs
|
||||
@ -448,20 +448,20 @@ impl<'ast> Map<'ast> {
|
||||
|
||||
/// Retrieve the Node corresponding to `id`, panicking if it cannot
|
||||
/// be found.
|
||||
pub fn get(&self, id: NodeId) -> Node<'ast> {
|
||||
pub fn get(&self, id: NodeId) -> Node<'hir> {
|
||||
match self.find(id) {
|
||||
Some(node) => node, // read recorded by `find`
|
||||
None => bug!("couldn't find node id {} in the AST map", id)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_if_local(&self, id: DefId) -> Option<Node<'ast>> {
|
||||
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
|
||||
self.as_local_node_id(id).map(|id| self.get(id)) // read recorded by `get`
|
||||
}
|
||||
|
||||
/// Retrieve the Node corresponding to `id`, returning None if
|
||||
/// cannot be found.
|
||||
pub fn find(&self, id: NodeId) -> Option<Node<'ast>> {
|
||||
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
|
||||
let result = self.find_entry(id).and_then(|x| x.to_node());
|
||||
if result.is_some() {
|
||||
self.read(id);
|
||||
@ -508,7 +508,7 @@ impl<'ast> Map<'ast> {
|
||||
/// is not an error, since items in the crate module have the crate root as
|
||||
/// parent.
|
||||
fn walk_parent_nodes<F>(&self, start_id: NodeId, found: F) -> Result<NodeId, NodeId>
|
||||
where F: Fn(&Node<'ast>) -> bool
|
||||
where F: Fn(&Node<'hir>) -> bool
|
||||
{
|
||||
let mut id = start_id;
|
||||
loop {
|
||||
@ -611,28 +611,28 @@ impl<'ast> Map<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
|
||||
pub fn expect_item(&self, id: NodeId) -> &'hir Item {
|
||||
match self.find(id) { // read recorded by `find`
|
||||
Some(NodeItem(item)) => item,
|
||||
_ => bug!("expected item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_impl_item(&self, id: NodeId) -> &'ast ImplItem {
|
||||
pub fn expect_impl_item(&self, id: NodeId) -> &'hir ImplItem {
|
||||
match self.find(id) {
|
||||
Some(NodeImplItem(item)) => item,
|
||||
_ => bug!("expected impl item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem {
|
||||
pub fn expect_trait_item(&self, id: NodeId) -> &'hir TraitItem {
|
||||
match self.find(id) {
|
||||
Some(NodeTraitItem(item)) => item,
|
||||
_ => bug!("expected trait item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant_data(&self, id: NodeId) -> &'ast VariantData {
|
||||
pub fn expect_variant_data(&self, id: NodeId) -> &'hir VariantData {
|
||||
match self.find(id) {
|
||||
Some(NodeItem(i)) => {
|
||||
match i.node {
|
||||
@ -653,35 +653,35 @@ impl<'ast> Map<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant(&self, id: NodeId) -> &'ast Variant {
|
||||
pub fn expect_variant(&self, id: NodeId) -> &'hir Variant {
|
||||
match self.find(id) {
|
||||
Some(NodeVariant(variant)) => variant,
|
||||
_ => bug!("expected variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem {
|
||||
pub fn expect_foreign_item(&self, id: NodeId) -> &'hir ForeignItem {
|
||||
match self.find(id) {
|
||||
Some(NodeForeignItem(item)) => item,
|
||||
_ => bug!("expected foreign item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_expr(&self, id: NodeId) -> &'ast Expr {
|
||||
pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
|
||||
match self.find(id) { // read recorded by find
|
||||
Some(NodeExpr(expr)) => expr,
|
||||
_ => bug!("expected expr, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_inlined_body(&self, def_id: DefId) -> Option<&'ast Body> {
|
||||
pub fn get_inlined_body(&self, def_id: DefId) -> Option<&'hir Body> {
|
||||
self.inlined_bodies.borrow().get(&def_id).map(|&body| {
|
||||
self.dep_graph.read(DepNode::MetaData(def_id));
|
||||
body
|
||||
})
|
||||
}
|
||||
|
||||
pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'ast Body {
|
||||
pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body {
|
||||
let body = self.forest.inlined_bodies.alloc(body);
|
||||
self.inlined_bodies.borrow_mut().insert(def_id, body);
|
||||
body
|
||||
@ -706,7 +706,7 @@ impl<'ast> Map<'ast> {
|
||||
|
||||
/// Given a node ID, get a list of attributes associated with the AST
|
||||
/// corresponding to the Node ID
|
||||
pub fn attrs(&self, id: NodeId) -> &'ast [ast::Attribute] {
|
||||
pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] {
|
||||
self.read(id); // reveals attributes on the node
|
||||
let attrs = match self.find(id) {
|
||||
Some(NodeItem(i)) => Some(&i.attrs[..]),
|
||||
@ -735,7 +735,7 @@ impl<'ast> Map<'ast> {
|
||||
/// such as `foo::bar::quux`, `bar::quux`, `other::bar::quux`, and
|
||||
/// any other such items it can find in the map.
|
||||
pub fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String])
|
||||
-> NodesMatchingSuffix<'a, 'ast> {
|
||||
-> NodesMatchingSuffix<'a, 'hir> {
|
||||
NodesMatchingSuffix {
|
||||
map: self,
|
||||
item_name: parts.last().unwrap(),
|
||||
@ -790,14 +790,14 @@ impl<'ast> Map<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NodesMatchingSuffix<'a, 'ast:'a> {
|
||||
map: &'a Map<'ast>,
|
||||
pub struct NodesMatchingSuffix<'a, 'hir:'a> {
|
||||
map: &'a Map<'hir>,
|
||||
item_name: &'a String,
|
||||
in_which: &'a [String],
|
||||
idx: NodeId,
|
||||
}
|
||||
|
||||
impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
||||
impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> {
|
||||
/// Returns true only if some suffix of the module path for parent
|
||||
/// matches `self.in_which`.
|
||||
///
|
||||
@ -853,7 +853,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Iterator for NodesMatchingSuffix<'a, 'ast> {
|
||||
impl<'a, 'hir> Iterator for NodesMatchingSuffix<'a, 'hir> {
|
||||
type Item = NodeId;
|
||||
|
||||
fn next(&mut self) -> Option<NodeId> {
|
||||
@ -892,9 +892,9 @@ impl Named for StructField { fn name(&self) -> Name { self.name } }
|
||||
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
|
||||
impl Named for ImplItem { fn name(&self) -> Name { self.name } }
|
||||
|
||||
pub fn map_crate<'ast>(forest: &'ast mut Forest,
|
||||
pub fn map_crate<'hir>(forest: &'hir mut Forest,
|
||||
definitions: Definitions)
|
||||
-> Map<'ast> {
|
||||
-> Map<'hir> {
|
||||
let mut collector = NodeCollector::root(&forest.krate);
|
||||
intravisit::walk_crate(&mut collector, &forest.krate);
|
||||
let map = collector.map;
|
||||
@ -926,7 +926,7 @@ pub fn map_crate<'ast>(forest: &'ast mut Forest,
|
||||
|
||||
/// Identical to the `PpAnn` implementation for `hir::Crate`,
|
||||
/// except it avoids creating a dependency on the whole crate.
|
||||
impl<'ast> print::PpAnn for Map<'ast> {
|
||||
impl<'hir> print::PpAnn for Map<'hir> {
|
||||
fn nested(&self, state: &mut print::State, nested: print::Nested) -> io::Result<()> {
|
||||
match nested {
|
||||
Nested::Item(id) => state.print_item(self.expect_item(id.id)),
|
||||
@ -966,7 +966,7 @@ impl<'a> print::State<'a> {
|
||||
NodeTyParam(_) => bug!("cannot print TyParam"),
|
||||
NodeField(_) => bug!("cannot print StructField"),
|
||||
// these cases do not carry enough information in the
|
||||
// ast_map to reconstruct their full structure for pretty
|
||||
// hir_map to reconstruct their full structure for pretty
|
||||
// printing.
|
||||
NodeStructCtor(_) => bug!("cannot print isolated StructCtor"),
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ use super::region_inference::SameRegions;
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use hir;
|
||||
|
||||
use lint;
|
||||
@ -144,16 +144,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
format!("{}unknown scope: {:?}{}. Please report a bug.",
|
||||
prefix, scope, suffix)
|
||||
};
|
||||
let span = match scope.span(&self.region_maps, &self.map) {
|
||||
let span = match scope.span(&self.region_maps, &self.hir) {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
err.note(&unknown_scope());
|
||||
return;
|
||||
}
|
||||
};
|
||||
let tag = match self.map.find(scope.node_id(&self.region_maps)) {
|
||||
Some(ast_map::NodeBlock(_)) => "block",
|
||||
Some(ast_map::NodeExpr(expr)) => match expr.node {
|
||||
let tag = match self.hir.find(scope.node_id(&self.region_maps)) {
|
||||
Some(hir_map::NodeBlock(_)) => "block",
|
||||
Some(hir_map::NodeExpr(expr)) => match expr.node {
|
||||
hir::ExprCall(..) => "call",
|
||||
hir::ExprMethodCall(..) => "method call",
|
||||
hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
|
||||
@ -162,10 +162,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
hir::ExprMatch(..) => "match",
|
||||
_ => "expression",
|
||||
},
|
||||
Some(ast_map::NodeStmt(_)) => "statement",
|
||||
Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
|
||||
Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
|
||||
Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
|
||||
Some(hir_map::NodeStmt(_)) => "statement",
|
||||
Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
|
||||
Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
|
||||
Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
|
||||
Some(_) | None => {
|
||||
err.span_note(span, &unknown_scope());
|
||||
return;
|
||||
@ -206,19 +206,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
let node = fr.scope.node_id(&self.region_maps);
|
||||
let unknown;
|
||||
let tag = match self.map.find(node) {
|
||||
Some(ast_map::NodeBlock(_)) |
|
||||
Some(ast_map::NodeExpr(_)) => "body",
|
||||
Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
|
||||
Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
|
||||
Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
|
||||
let tag = match self.hir.find(node) {
|
||||
Some(hir_map::NodeBlock(_)) |
|
||||
Some(hir_map::NodeExpr(_)) => "body",
|
||||
Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
|
||||
Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
|
||||
Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
|
||||
|
||||
// this really should not happen, but it does:
|
||||
// FIXME(#27942)
|
||||
Some(_) => {
|
||||
unknown = format!("unexpected node ({}) for scope {:?}. \
|
||||
Please report a bug.",
|
||||
self.map.node_to_string(node), fr.scope);
|
||||
self.hir.node_to_string(node), fr.scope);
|
||||
&unknown
|
||||
}
|
||||
None => {
|
||||
@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
&unknown
|
||||
}
|
||||
};
|
||||
let (msg, opt_span) = explain_span(self, tag, self.map.span(node));
|
||||
let (msg, opt_span) = explain_span(self, tag, self.hir.span(node));
|
||||
(format!("{} {}", prefix, msg), opt_span)
|
||||
}
|
||||
|
||||
@ -467,18 +467,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
},
|
||||
_ => return None
|
||||
};
|
||||
let parent = tcx.map.get_parent(scope_id);
|
||||
let parent_node = tcx.map.find(parent);
|
||||
let parent = tcx.hir.get_parent(scope_id);
|
||||
let parent_node = tcx.hir.find(parent);
|
||||
match parent_node {
|
||||
Some(node) => match node {
|
||||
ast_map::NodeItem(item) => match item.node {
|
||||
hir_map::NodeItem(item) => match item.node {
|
||||
hir::ItemFn(..) => {
|
||||
Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
|
||||
},
|
||||
_ => None
|
||||
},
|
||||
ast_map::NodeImplItem(..) |
|
||||
ast_map::NodeTraitItem(..) => {
|
||||
hir_map::NodeImplItem(..) |
|
||||
hir_map::NodeTraitItem(..) => {
|
||||
Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
|
||||
},
|
||||
_ => None
|
||||
@ -1071,13 +1071,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
fn give_suggestion(&self, err: &mut DiagnosticBuilder, same_regions: &[SameRegions]) {
|
||||
let scope_id = same_regions[0].scope_id;
|
||||
let parent = self.tcx.map.get_parent(scope_id);
|
||||
let parent_node = self.tcx.map.find(parent);
|
||||
let parent = self.tcx.hir.get_parent(scope_id);
|
||||
let parent_node = self.tcx.hir.find(parent);
|
||||
let taken = lifetimes_in_scope(self.tcx, scope_id);
|
||||
let life_giver = LifeGiver::with_taken(&taken[..]);
|
||||
let node_inner = match parent_node {
|
||||
Some(ref node) => match *node {
|
||||
ast_map::NodeItem(ref item) => {
|
||||
hir_map::NodeItem(ref item) => {
|
||||
match item.node {
|
||||
hir::ItemFn(ref fn_decl, unsafety, constness, _, ref gen, body) => {
|
||||
Some((fn_decl, gen, unsafety, constness, item.name, item.span, body))
|
||||
@ -1085,9 +1085,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
ast_map::NodeImplItem(item) => {
|
||||
let id = self.tcx.map.get_parent(item.id);
|
||||
if let Some(ast_map::NodeItem(parent_scope)) = self.tcx.map.find(id) {
|
||||
hir_map::NodeImplItem(item) => {
|
||||
let id = self.tcx.hir.get_parent(item.id);
|
||||
if let Some(hir_map::NodeItem(parent_scope)) = self.tcx.hir.find(id) {
|
||||
if let hir::ItemImpl(_, _, _, None, _, _) = parent_scope.node {
|
||||
// this impl scope implements a trait, do not recomend
|
||||
// using explicit lifetimes (#37363)
|
||||
@ -1106,7 +1106,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
None
|
||||
}
|
||||
},
|
||||
ast_map::NodeTraitItem(item) => {
|
||||
hir_map::NodeTraitItem(item) => {
|
||||
match item.node {
|
||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||
Some((&sig.decl,
|
||||
@ -1657,7 +1657,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
generics: &hir::Generics,
|
||||
span: Span,
|
||||
body: hir::BodyId) {
|
||||
let s = hir::print::to_string(&self.tcx.map, |s| {
|
||||
let s = hir::print::to_string(&self.tcx.hir, |s| {
|
||||
use syntax::abi::Abi;
|
||||
use syntax::print::pprust::PrintState;
|
||||
|
||||
@ -1894,17 +1894,17 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
scope_id: ast::NodeId)
|
||||
-> Vec<hir::LifetimeDef> {
|
||||
let mut taken = Vec::new();
|
||||
let parent = tcx.map.get_parent(scope_id);
|
||||
let method_id_opt = match tcx.map.find(parent) {
|
||||
let parent = tcx.hir.get_parent(scope_id);
|
||||
let method_id_opt = match tcx.hir.find(parent) {
|
||||
Some(node) => match node {
|
||||
ast_map::NodeItem(item) => match item.node {
|
||||
hir_map::NodeItem(item) => match item.node {
|
||||
hir::ItemFn(.., ref gen, _) => {
|
||||
taken.extend_from_slice(&gen.lifetimes);
|
||||
None
|
||||
},
|
||||
_ => None
|
||||
},
|
||||
ast_map::NodeImplItem(ii) => {
|
||||
hir_map::NodeImplItem(ii) => {
|
||||
match ii.node {
|
||||
hir::ImplItemKind::Method(ref sig, _) => {
|
||||
taken.extend_from_slice(&sig.generics.lifetimes);
|
||||
@ -1918,10 +1918,10 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
None => None
|
||||
};
|
||||
if let Some(method_id) = method_id_opt {
|
||||
let parent = tcx.map.get_parent(method_id);
|
||||
if let Some(node) = tcx.map.find(parent) {
|
||||
let parent = tcx.hir.get_parent(method_id);
|
||||
if let Some(node) = tcx.hir.find(parent) {
|
||||
match node {
|
||||
ast_map::NodeItem(item) => match item.node {
|
||||
hir_map::NodeItem(item) => match item.node {
|
||||
hir::ItemImpl(_, _, ref gen, ..) => {
|
||||
taken.extend_from_slice(&gen.lifetimes);
|
||||
}
|
||||
|
@ -453,8 +453,8 @@ impl<'a, 'tcx> InferEnv<'a, 'tcx> for hir::BodyId {
|
||||
-> (Option<&'a ty::TypeckTables<'tcx>>,
|
||||
Option<ty::TypeckTables<'tcx>>,
|
||||
Option<ty::ParameterEnvironment<'tcx>>) {
|
||||
let item_id = tcx.map.body_owner(self);
|
||||
(Some(tcx.item_tables(tcx.map.local_def_id(item_id))),
|
||||
let item_id = tcx.hir.body_owner(self);
|
||||
(Some(tcx.item_tables(tcx.hir.local_def_id(item_id))),
|
||||
None,
|
||||
Some(ty::ParameterEnvironment::for_item(tcx, item_id)))
|
||||
}
|
||||
@ -1269,7 +1269,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
self.tcx.types.err,
|
||||
None => {
|
||||
bug!("no type for node {}: {} in fcx",
|
||||
id, self.tcx.map.node_to_string(id));
|
||||
id, self.tcx.hir.node_to_string(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1639,7 +1639,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
-> Option<ty::ClosureKind>
|
||||
{
|
||||
if let InferTables::InProgress(tables) = self.tables {
|
||||
if let Some(id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
return tables.borrow().closure_kinds.get(&id).cloned();
|
||||
}
|
||||
}
|
||||
@ -1657,7 +1657,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
-> ty::ClosureTy<'tcx>
|
||||
{
|
||||
if let InferTables::InProgress(tables) = self.tables {
|
||||
if let Some(id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
if let Some(ty) = tables.borrow().closure_tys.get(&id) {
|
||||
return ty.subst(self.tcx, substs.substs);
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
/// items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> {
|
||||
hir_visit::NestedVisitorMap::All(&self.tcx.map)
|
||||
hir_visit::NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
// Output any lints that were previously added to the session.
|
||||
@ -784,7 +784,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body);
|
||||
let body = self.tcx.map.body(body);
|
||||
let body = self.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.tables = old_tables;
|
||||
}
|
||||
@ -834,7 +834,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
// in order for `check_fn` to be able to use them.
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body_id);
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
run_lints!(self, check_fn, late_passes, fk, decl, body, span, id);
|
||||
hir_visit::walk_fn(self, fk, decl, body_id, span, id);
|
||||
run_lints!(self, check_fn_post, late_passes, fk, decl, body, span, id);
|
||||
@ -1206,7 +1206,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &AccessLevels) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck);
|
||||
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
|
||||
// We want to own the lint store, so move it out of the session.
|
||||
let lint_store = mem::replace(&mut *tcx.sess.lint_store.borrow_mut(), LintStore::new());
|
||||
@ -1236,7 +1236,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
for early_lint in v {
|
||||
span_bug!(early_lint.diagnostic.span.clone(),
|
||||
"unprocessed lint {:?} at {}",
|
||||
early_lint, tcx.map.node_to_string(*id));
|
||||
early_lint, tcx.hir.node_to_string(*id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
|
||||
|
||||
impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> {
|
||||
fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> {
|
||||
pprust::PpAnn::nested(&self.tcx.map, state, nested)
|
||||
pprust::PpAnn::nested(&self.tcx.hir, state, nested)
|
||||
}
|
||||
fn pre(&self,
|
||||
ps: &mut pprust::State,
|
||||
|
@ -13,7 +13,7 @@
|
||||
// from live codes are live, and everything else is dead.
|
||||
|
||||
use dep_graph::DepNode;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use hir::{self, PatKind};
|
||||
use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use hir::itemlikevisit::ItemLikeVisitor;
|
||||
@ -35,11 +35,11 @@ use syntax_pos;
|
||||
// may need to be marked as live.
|
||||
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
node_id: ast::NodeId) -> bool {
|
||||
match tcx.map.find(node_id) {
|
||||
Some(ast_map::NodeItem(..)) |
|
||||
Some(ast_map::NodeImplItem(..)) |
|
||||
Some(ast_map::NodeForeignItem(..)) |
|
||||
Some(ast_map::NodeTraitItem(..)) =>
|
||||
match tcx.hir.find(node_id) {
|
||||
Some(hir_map::NodeItem(..)) |
|
||||
Some(hir_map::NodeImplItem(..)) |
|
||||
Some(hir_map::NodeForeignItem(..)) |
|
||||
Some(hir_map::NodeTraitItem(..)) =>
|
||||
true,
|
||||
_ =>
|
||||
false
|
||||
@ -59,7 +59,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
fn check_def_id(&mut self, def_id: DefId) {
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
if should_explore(self.tcx, node_id) {
|
||||
self.worklist.push(node_id);
|
||||
}
|
||||
@ -68,7 +68,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn insert_def_id(&mut self, def_id: DefId) {
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
debug_assert!(!should_explore(self.tcx, node_id));
|
||||
self.live_symbols.insert(node_id);
|
||||
}
|
||||
@ -143,20 +143,20 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
scanned.insert(id);
|
||||
|
||||
if let Some(ref node) = self.tcx.map.find(id) {
|
||||
if let Some(ref node) = self.tcx.hir.find(id) {
|
||||
self.live_symbols.insert(id);
|
||||
self.visit_node(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_node(&mut self, node: &ast_map::Node<'tcx>) {
|
||||
fn visit_node(&mut self, node: &hir_map::Node<'tcx>) {
|
||||
let had_extern_repr = self.struct_has_extern_repr;
|
||||
self.struct_has_extern_repr = false;
|
||||
let had_inherited_pub_visibility = self.inherited_pub_visibility;
|
||||
self.inherited_pub_visibility = false;
|
||||
match *node {
|
||||
ast_map::NodeItem(item) => {
|
||||
hir_map::NodeItem(item) => {
|
||||
match item.node {
|
||||
hir::ItemStruct(..) | hir::ItemUnion(..) => {
|
||||
self.struct_has_extern_repr = item.attrs.iter().any(|attr| {
|
||||
@ -179,13 +179,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
ast_map::NodeTraitItem(trait_item) => {
|
||||
hir_map::NodeTraitItem(trait_item) => {
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
ast_map::NodeImplItem(impl_item) => {
|
||||
hir_map::NodeImplItem(impl_item) => {
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
ast_map::NodeForeignItem(foreign_item) => {
|
||||
hir_map::NodeForeignItem(foreign_item) => {
|
||||
intravisit::walk_foreign_item(self, &foreign_item);
|
||||
}
|
||||
_ => ()
|
||||
@ -203,7 +203,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body);
|
||||
let body = self.tcx.map.body(body);
|
||||
let body = self.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.tables = old_tables;
|
||||
}
|
||||
@ -434,7 +434,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
||||
let field_type = self.tcx.item_type(self.tcx.map.local_def_id(field.id));
|
||||
let field_type = self.tcx.item_type(self.tcx.hir.local_def_id(field.id));
|
||||
let is_marker_field = match field_type.ty_to_def_id() {
|
||||
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
|
||||
_ => false
|
||||
@ -478,10 +478,10 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
// method of a private type is used, but the type itself is never
|
||||
// called directly.
|
||||
if let Some(impl_list) =
|
||||
self.tcx.inherent_impls.borrow().get(&self.tcx.map.local_def_id(id)) {
|
||||
self.tcx.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) {
|
||||
for &impl_did in impl_list.iter() {
|
||||
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
|
||||
if let Some(item_node_id) = self.tcx.map.as_local_node_id(item_did) {
|
||||
if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) {
|
||||
if self.live_symbols.contains(&item_node_id) {
|
||||
return true;
|
||||
}
|
||||
@ -514,7 +514,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
/// an error. We could do this also by checking the parents, but
|
||||
/// this is how the code is setup and it seems harmless enough.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &privacy::AccessLevels) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::DeadCheck);
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
let live_symbols = find_live(tcx, access_levels, krate);
|
||||
let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols };
|
||||
intravisit::walk_crate(&mut visitor, krate);
|
||||
|
@ -101,7 +101,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> {
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body);
|
||||
let body = self.tcx.map.body(body);
|
||||
let body = self.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.tables = old_tables;
|
||||
}
|
||||
@ -203,7 +203,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> {
|
||||
if let Def::Static(def_id, mutbl) = path.def {
|
||||
if mutbl {
|
||||
self.require_unsafe(expr.span, "use of mutable static");
|
||||
} else if match self.tcx.map.get_if_local(def_id) {
|
||||
} else if match self.tcx.hir.get_if_local(def_id) {
|
||||
Some(hir::map::NodeForeignItem(..)) => true,
|
||||
Some(..) => false,
|
||||
None => self.tcx.sess.cstore.is_foreign_item(def_id),
|
||||
@ -249,5 +249,5 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
unsafe_context: UnsafeContext::new(SafeContext),
|
||||
};
|
||||
|
||||
tcx.map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
use dep_graph::DepNode;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use hir::def_id::{CRATE_DEF_INDEX};
|
||||
use session::{config, Session};
|
||||
use syntax::ast::NodeId;
|
||||
@ -23,7 +23,7 @@ use hir::itemlikevisit::ItemLikeVisitor;
|
||||
struct EntryContext<'a, 'tcx: 'a> {
|
||||
session: &'a Session,
|
||||
|
||||
map: &'a ast_map::Map<'tcx>,
|
||||
map: &'a hir_map::Map<'tcx>,
|
||||
|
||||
// The top-level function called 'main'
|
||||
main_fn: Option<(NodeId, Span)>,
|
||||
@ -56,8 +56,8 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
|
||||
let _task = ast_map.dep_graph.in_task(DepNode::EntryPoint);
|
||||
pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
|
||||
let _task = hir_map.dep_graph.in_task(DepNode::EntryPoint);
|
||||
|
||||
let any_exe = session.crate_types.borrow().iter().any(|ty| {
|
||||
*ty == config::CrateTypeExecutable
|
||||
@ -68,21 +68,21 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
|
||||
}
|
||||
|
||||
// If the user wants no main function at all, then stop here.
|
||||
if attr::contains_name(&ast_map.krate().attrs, "no_main") {
|
||||
if attr::contains_name(&hir_map.krate().attrs, "no_main") {
|
||||
session.entry_type.set(Some(config::EntryNone));
|
||||
return
|
||||
}
|
||||
|
||||
let mut ctxt = EntryContext {
|
||||
session: session,
|
||||
map: ast_map,
|
||||
map: hir_map,
|
||||
main_fn: None,
|
||||
attr_main_fn: None,
|
||||
start_fn: None,
|
||||
non_main_fns: Vec::new(),
|
||||
};
|
||||
|
||||
ast_map.krate().visit_all_item_likes(&mut ctxt);
|
||||
hir_map.krate().visit_all_item_likes(&mut ctxt);
|
||||
|
||||
configure_main(&mut ctxt);
|
||||
}
|
||||
|
@ -1020,7 +1020,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||
self.tcx().with_freevars(closure_expr.id, |freevars| {
|
||||
for freevar in freevars {
|
||||
let def_id = freevar.def.def_id();
|
||||
let id_var = self.tcx().map.as_local_node_id(def_id).unwrap();
|
||||
let id_var = self.tcx().hir.as_local_node_id(def_id).unwrap();
|
||||
let upvar_id = ty::UpvarId { var_id: id_var,
|
||||
closure_expr_id: closure_expr.id };
|
||||
let upvar_capture = self.mc.infcx.upvar_capture(upvar_id).unwrap();
|
||||
@ -1052,7 +1052,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||
-> mc::McResult<mc::cmt<'tcx>> {
|
||||
// Create the cmt for the variable being borrowed, from the
|
||||
// caller's perspective
|
||||
let var_id = self.tcx().map.as_local_node_id(upvar_def.def_id()).unwrap();
|
||||
let var_id = self.tcx().hir.as_local_node_id(upvar_def.def_id()).unwrap();
|
||||
let var_ty = self.mc.infcx.node_ty(var_id)?;
|
||||
self.mc.cat_def(closure_id, closure_span, var_ty, upvar_def)
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
self.tcx.infer_ctxt(body_id, Reveal::All).enter(|infcx| {
|
||||
let mut visitor = ExprVisitor {
|
||||
infcx: &infcx
|
||||
|
@ -117,7 +117,7 @@ impl LanguageItems {
|
||||
struct LanguageItemCollector<'a, 'tcx: 'a> {
|
||||
items: LanguageItems,
|
||||
|
||||
ast_map: &'a hir_map::Map<'tcx>,
|
||||
hir_map: &'a hir_map::Map<'tcx>,
|
||||
|
||||
session: &'a Session,
|
||||
|
||||
@ -130,9 +130,9 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
|
||||
let item_index = self.item_refs.get(&*value.as_str()).cloned();
|
||||
|
||||
if let Some(item_index) = item_index {
|
||||
self.collect_item(item_index, self.ast_map.local_def_id(item.id))
|
||||
self.collect_item(item_index, self.hir_map.local_def_id(item.id))
|
||||
} else {
|
||||
let span = self.ast_map.span(item.id);
|
||||
let span = self.hir_map.span(item.id);
|
||||
span_err!(self.session, span, E0522,
|
||||
"definition of an unknown language item: `{}`.",
|
||||
value);
|
||||
@ -150,7 +150,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
||||
pub fn new(session: &'a Session, ast_map: &'a hir_map::Map<'tcx>)
|
||||
pub fn new(session: &'a Session, hir_map: &'a hir_map::Map<'tcx>)
|
||||
-> LanguageItemCollector<'a, 'tcx> {
|
||||
let mut item_refs = FxHashMap();
|
||||
|
||||
@ -158,7 +158,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
||||
|
||||
LanguageItemCollector {
|
||||
session: session,
|
||||
ast_map: ast_map,
|
||||
hir_map: hir_map,
|
||||
items: LanguageItems::new(),
|
||||
item_refs: item_refs,
|
||||
}
|
||||
@ -171,7 +171,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
||||
Some(original_def_id) if original_def_id != item_def_id => {
|
||||
let cstore = &self.session.cstore;
|
||||
let name = LanguageItems::item_name(item_index);
|
||||
let mut err = match self.ast_map.span_if_local(item_def_id) {
|
||||
let mut err = match self.hir_map.span_if_local(item_def_id) {
|
||||
Some(span) => struct_span_err!(
|
||||
self.session,
|
||||
span,
|
||||
@ -183,7 +183,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
||||
cstore.crate_name(item_def_id.krate),
|
||||
name)),
|
||||
};
|
||||
if let Some(span) = self.ast_map.span_if_local(original_def_id) {
|
||||
if let Some(span) = self.hir_map.span_if_local(original_def_id) {
|
||||
span_note!(&mut err, span,
|
||||
"first defined here.");
|
||||
} else {
|
||||
|
@ -183,7 +183,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String {
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
|
||||
@ -197,7 +197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
|
||||
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::Liveness);
|
||||
tcx.map.krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor());
|
||||
tcx.hir.krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor());
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
|
||||
|
||||
debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps);
|
||||
|
||||
let body = ir.tcx.map.body(body_id);
|
||||
let body = ir.tcx.hir.body(body_id);
|
||||
|
||||
for arg in &body.arguments {
|
||||
arg.pat.each_binding(|_bm, arg_id, _x, path1| {
|
||||
@ -440,7 +440,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
ir.tcx.with_freevars(expr.id, |freevars| {
|
||||
for fv in freevars {
|
||||
if let Def::Local(def_id) = fv.def {
|
||||
let rv = ir.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let rv = ir.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
|
||||
call_caps.push(CaptureInfo {ln: fv_ln,
|
||||
var_nid: rv});
|
||||
@ -807,7 +807,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
// effectively a return---this only occurs in `for` loops,
|
||||
// where the body is really a closure.
|
||||
|
||||
debug!("compute: using id for body, {}", self.ir.tcx.map.node_to_pretty_string(body.id));
|
||||
debug!("compute: using id for body, {}", self.ir.tcx.hir.node_to_pretty_string(body.id));
|
||||
|
||||
let exit_ln = self.s.exit_ln;
|
||||
let entry_ln: LiveNode = self.with_loop_nodes(body.id, exit_ln, exit_ln, |this| {
|
||||
@ -900,7 +900,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
|
||||
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
|
||||
-> LiveNode {
|
||||
debug!("propagate_through_expr: {}", self.ir.tcx.map.node_to_pretty_string(expr.id));
|
||||
debug!("propagate_through_expr: {}", self.ir.tcx.hir.node_to_pretty_string(expr.id));
|
||||
|
||||
match expr.node {
|
||||
// Interesting cases with control flow or which gen/kill
|
||||
@ -919,7 +919,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
|
||||
hir::ExprClosure(.., blk_id, _) => {
|
||||
debug!("{} is an ExprClosure",
|
||||
self.ir.tcx.map.node_to_pretty_string(expr.id));
|
||||
self.ir.tcx.hir.node_to_pretty_string(expr.id));
|
||||
|
||||
/*
|
||||
The next-node for a break is the successor of the entire
|
||||
@ -1241,7 +1241,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
-> LiveNode {
|
||||
match path.def {
|
||||
Def::Local(def_id) => {
|
||||
let nid = self.ir.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let nid = self.ir.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let ln = self.live_node(id, path.span);
|
||||
if acc != 0 {
|
||||
self.init_from_succ(ln, succ);
|
||||
@ -1295,7 +1295,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
debug!("propagate_through_loop: using id for loop body {} {}",
|
||||
expr.id, self.ir.tcx.map.node_to_pretty_string(body.id));
|
||||
expr.id, self.ir.tcx.hir.node_to_pretty_string(body.id));
|
||||
|
||||
let cond_ln = match kind {
|
||||
LoopLoop => ln,
|
||||
@ -1440,7 +1440,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
entry_ln: LiveNode,
|
||||
body: &hir::Body)
|
||||
{
|
||||
let fn_ty = self.ir.tcx.item_type(self.ir.tcx.map.local_def_id(id));
|
||||
let fn_ty = self.ir.tcx.item_type(self.ir.tcx.hir.local_def_id(id));
|
||||
let fn_ret = match fn_ty.sty {
|
||||
ty::TyClosure(closure_def_id, substs) =>
|
||||
self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
|
||||
@ -1477,7 +1477,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
// if there is no later assignment. If this local is actually
|
||||
// mutable, then check for a reassignment to flag the mutability
|
||||
// as being used.
|
||||
let nid = self.ir.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let nid = self.ir.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let ln = self.live_node(expr.id, expr.span);
|
||||
let var = self.variable(nid, expr.span);
|
||||
self.warn_about_dead_assign(expr.span, expr.id, ln, var);
|
||||
|
@ -71,7 +71,7 @@ pub use self::Note::*;
|
||||
use self::Aliasability::*;
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use infer::InferCtxt;
|
||||
use hir::def::{Def, CtorKind};
|
||||
use ty::adjustment;
|
||||
@ -268,8 +268,8 @@ impl MutabilityCategory {
|
||||
}
|
||||
|
||||
fn from_local(tcx: TyCtxt, id: ast::NodeId) -> MutabilityCategory {
|
||||
let ret = match tcx.map.get(id) {
|
||||
ast_map::NodeLocal(p) => match p.node {
|
||||
let ret = match tcx.hir.get(id) {
|
||||
hir_map::NodeLocal(p) => match p.node {
|
||||
PatKind::Binding(bind_mode, ..) => {
|
||||
if bind_mode == hir::BindByValue(hir::MutMutable) {
|
||||
McDeclared
|
||||
@ -279,7 +279,7 @@ impl MutabilityCategory {
|
||||
}
|
||||
_ => span_bug!(p.span, "expected identifier pattern")
|
||||
},
|
||||
_ => span_bug!(tcx.map.span(id), "expected identifier pattern")
|
||||
_ => span_bug!(tcx.hir.span(id), "expected identifier pattern")
|
||||
};
|
||||
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
|
||||
"from_local", id, ret);
|
||||
@ -539,7 +539,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
Def::Upvar(def_id, _, fn_node_id) => {
|
||||
let var_id = self.tcx().map.as_local_node_id(def_id).unwrap();
|
||||
let var_id = self.tcx().hir.as_local_node_id(def_id).unwrap();
|
||||
let ty = self.node_ty(fn_node_id)?;
|
||||
match ty.sty {
|
||||
ty::TyClosure(closure_id, _) => {
|
||||
@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
Def::Local(def_id) => {
|
||||
let vid = self.tcx().map.as_local_node_id(def_id).unwrap();
|
||||
let vid = self.tcx().hir.as_local_node_id(def_id).unwrap();
|
||||
Ok(Rc::new(cmt_ {
|
||||
id: id,
|
||||
span: span,
|
||||
@ -698,8 +698,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||
// Look up the node ID of the closure body so we can construct
|
||||
// a free region within it
|
||||
let fn_body_id = {
|
||||
let fn_expr = match self.tcx().map.find(upvar_id.closure_expr_id) {
|
||||
Some(ast_map::NodeExpr(e)) => e,
|
||||
let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) {
|
||||
Some(hir_map::NodeExpr(e)) => e,
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
@ -1313,7 +1313,7 @@ impl<'tcx> cmt_<'tcx> {
|
||||
"non-lvalue".to_string()
|
||||
}
|
||||
Categorization::Local(vid) => {
|
||||
if tcx.map.is_argument(vid) {
|
||||
if tcx.hir.is_argument(vid) {
|
||||
"argument".to_string()
|
||||
} else {
|
||||
"local variable".to_string()
|
||||
|
@ -16,7 +16,7 @@
|
||||
// reachable as well.
|
||||
|
||||
use dep_graph::DepNode;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use hir::def::Def;
|
||||
use hir::def_id::DefId;
|
||||
use ty::{self, TyCtxt};
|
||||
@ -63,9 +63,9 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
generics_require_inlining(&sig.generics) {
|
||||
return true
|
||||
}
|
||||
if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_src) {
|
||||
match tcx.map.find(impl_node_id) {
|
||||
Some(ast_map::NodeItem(item)) =>
|
||||
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
|
||||
match tcx.hir.find(impl_node_id) {
|
||||
Some(hir_map::NodeItem(item)) =>
|
||||
item_might_be_inlined(&item),
|
||||
Some(..) | None =>
|
||||
span_bug!(impl_item.span, "impl did is not an item")
|
||||
@ -97,7 +97,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body);
|
||||
let body = self.tcx.map.body(body);
|
||||
let body = self.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.tables = old_tables;
|
||||
}
|
||||
@ -117,7 +117,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
|
||||
|
||||
if let Some(def) = def {
|
||||
let def_id = def.def_id();
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
if self.def_id_represents_local_inlined_item(def_id) {
|
||||
self.worklist.push(node_id);
|
||||
} else {
|
||||
@ -147,19 +147,19 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
// Returns true if the given def ID represents a local item that is
|
||||
// eligible for inlining and false otherwise.
|
||||
fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool {
|
||||
let node_id = match self.tcx.map.as_local_node_id(def_id) {
|
||||
let node_id = match self.tcx.hir.as_local_node_id(def_id) {
|
||||
Some(node_id) => node_id,
|
||||
None => { return false; }
|
||||
};
|
||||
|
||||
match self.tcx.map.find(node_id) {
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
match self.tcx.hir.find(node_id) {
|
||||
Some(hir_map::NodeItem(item)) => {
|
||||
match item.node {
|
||||
hir::ItemFn(..) => item_might_be_inlined(&item),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeTraitItem(trait_method)) => {
|
||||
Some(hir_map::NodeTraitItem(trait_method)) => {
|
||||
match trait_method.node {
|
||||
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
|
||||
@ -167,7 +167,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
hir::TraitItemKind::Type(..) => false,
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeImplItem(impl_item)) => {
|
||||
Some(hir_map::NodeImplItem(impl_item)) => {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(ref sig, _) => {
|
||||
@ -176,13 +176,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
true
|
||||
} else {
|
||||
let impl_did = self.tcx
|
||||
.map
|
||||
.hir
|
||||
.get_parent_did(node_id);
|
||||
// Check the impl. If the generics on the self
|
||||
// type of the impl require inlining, this method
|
||||
// does too.
|
||||
let impl_node_id = self.tcx.map.as_local_node_id(impl_did).unwrap();
|
||||
match self.tcx.map.expect_item(impl_node_id).node {
|
||||
let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap();
|
||||
match self.tcx.hir.expect_item(impl_node_id).node {
|
||||
hir::ItemImpl(_, _, ref generics, ..) => {
|
||||
generics_require_inlining(generics)
|
||||
}
|
||||
@ -210,18 +210,18 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
continue
|
||||
}
|
||||
|
||||
if let Some(ref item) = self.tcx.map.find(search_item) {
|
||||
if let Some(ref item) = self.tcx.hir.find(search_item) {
|
||||
self.propagate_node(item, search_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn propagate_node(&mut self, node: &ast_map::Node<'tcx>,
|
||||
fn propagate_node(&mut self, node: &hir_map::Node<'tcx>,
|
||||
search_item: ast::NodeId) {
|
||||
if !self.any_library {
|
||||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
if let ast_map::NodeItem(item) = *node {
|
||||
if let hir_map::NodeItem(item) = *node {
|
||||
let reachable = if let hir::ItemFn(.., abi, _, _) = item.node {
|
||||
abi != Abi::Rust
|
||||
} else {
|
||||
@ -242,7 +242,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
match *node {
|
||||
ast_map::NodeItem(item) => {
|
||||
hir_map::NodeItem(item) => {
|
||||
match item.node {
|
||||
hir::ItemFn(.., body) => {
|
||||
if item_might_be_inlined(&item) {
|
||||
@ -268,7 +268,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
hir::ItemUnion(..) | hir::ItemDefaultImpl(..) => {}
|
||||
}
|
||||
}
|
||||
ast_map::NodeTraitItem(trait_method) => {
|
||||
hir_map::NodeTraitItem(trait_method) => {
|
||||
match trait_method.node {
|
||||
hir::TraitItemKind::Const(_, None) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
|
||||
@ -281,13 +281,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
hir::TraitItemKind::Type(..) => {}
|
||||
}
|
||||
}
|
||||
ast_map::NodeImplItem(impl_item) => {
|
||||
hir_map::NodeImplItem(impl_item) => {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(_, body) => {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
hir::ImplItemKind::Method(ref sig, body) => {
|
||||
let did = self.tcx.map.get_parent_did(search_item);
|
||||
let did = self.tcx.hir.get_parent_did(search_item);
|
||||
if method_might_be_inlined(self.tcx, sig, impl_item, did) {
|
||||
self.visit_nested_body(body)
|
||||
}
|
||||
@ -296,14 +296,14 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
// Nothing to recurse on for these
|
||||
ast_map::NodeForeignItem(_) |
|
||||
ast_map::NodeVariant(_) |
|
||||
ast_map::NodeStructCtor(_) |
|
||||
ast_map::NodeField(_) |
|
||||
ast_map::NodeTy(_) => {}
|
||||
hir_map::NodeForeignItem(_) |
|
||||
hir_map::NodeVariant(_) |
|
||||
hir_map::NodeStructCtor(_) |
|
||||
hir_map::NodeField(_) |
|
||||
hir_map::NodeTy(_) => {}
|
||||
_ => {
|
||||
bug!("found unexpected thingy in worklist: {}",
|
||||
self.tcx.map.node_to_string(search_item))
|
||||
self.tcx.hir.node_to_string(search_item))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -343,7 +343,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
|
||||
|
||||
for default_method in self.tcx.provided_trait_methods(trait_def_id) {
|
||||
let node_id = self.tcx
|
||||
.map
|
||||
.hir
|
||||
.as_local_node_id(default_method.def_id)
|
||||
.unwrap();
|
||||
self.worklist.push(node_id);
|
||||
@ -386,7 +386,7 @@ pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
for item in tcx.lang_items.items().iter() {
|
||||
if let Some(did) = *item {
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(did) {
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(did) {
|
||||
reachable_context.worklist.push(node_id);
|
||||
}
|
||||
}
|
||||
@ -397,7 +397,7 @@ pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: access_levels,
|
||||
worklist: &mut reachable_context.worklist,
|
||||
};
|
||||
tcx.map.krate().visit_all_item_likes(&mut collect_private_impl_items);
|
||||
tcx.hir.krate().visit_all_item_likes(&mut collect_private_impl_items);
|
||||
}
|
||||
|
||||
// Step 2: Mark all symbols that the symbols on the worklist touch.
|
||||
|
@ -17,7 +17,7 @@
|
||||
//! `middle/infer/region_inference/README.md`
|
||||
|
||||
use dep_graph::DepNode;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use session::Session;
|
||||
use util::nodemap::{FxHashMap, NodeMap, NodeSet};
|
||||
use ty;
|
||||
@ -217,9 +217,9 @@ impl CodeExtent {
|
||||
/// Returns the span of this CodeExtent. Note that in general the
|
||||
/// returned span may not correspond to the span of any node id in
|
||||
/// the AST.
|
||||
pub fn span(&self, region_maps: &RegionMaps, ast_map: &ast_map::Map) -> Option<Span> {
|
||||
match ast_map.find(self.node_id(region_maps)) {
|
||||
Some(ast_map::NodeBlock(ref blk)) => {
|
||||
pub fn span(&self, region_maps: &RegionMaps, hir_map: &hir_map::Map) -> Option<Span> {
|
||||
match hir_map.find(self.node_id(region_maps)) {
|
||||
Some(hir_map::NodeBlock(ref blk)) => {
|
||||
match region_maps.code_extent_data(*self) {
|
||||
CodeExtentData::CallSiteScope { .. } |
|
||||
CodeExtentData::ParameterScope { .. } |
|
||||
@ -240,9 +240,9 @@ impl CodeExtent {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeExpr(ref expr)) => Some(expr.span),
|
||||
Some(ast_map::NodeStmt(ref stmt)) => Some(stmt.span),
|
||||
Some(ast_map::NodeItem(ref item)) => Some(item.span),
|
||||
Some(hir_map::NodeExpr(ref expr)) => Some(expr.span),
|
||||
Some(hir_map::NodeStmt(ref stmt)) => Some(stmt.span),
|
||||
Some(hir_map::NodeItem(ref item)) => Some(item.span),
|
||||
Some(_) | None => None,
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ pub struct Context {
|
||||
parent: CodeExtent
|
||||
}
|
||||
|
||||
struct RegionResolutionVisitor<'ast: 'a, 'a> {
|
||||
struct RegionResolutionVisitor<'hir: 'a, 'a> {
|
||||
sess: &'a Session,
|
||||
|
||||
// Generated maps:
|
||||
@ -310,7 +310,7 @@ struct RegionResolutionVisitor<'ast: 'a, 'a> {
|
||||
|
||||
cx: Context,
|
||||
|
||||
map: &'a ast_map::Map<'ast>,
|
||||
map: &'a hir_map::Map<'hir>,
|
||||
|
||||
/// `terminating_scopes` is a set containing the ids of each
|
||||
/// statement, or conditional/repeating expression. These scopes
|
||||
@ -1137,7 +1137,7 @@ fn resolve_fn<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>,
|
||||
visitor.terminating_scopes = outer_ts;
|
||||
}
|
||||
|
||||
impl<'ast, 'a> RegionResolutionVisitor<'ast, 'a> {
|
||||
impl<'hir, 'a> RegionResolutionVisitor<'hir, 'a> {
|
||||
/// Records the current parent (if any) as the parent of `child_scope`.
|
||||
fn new_code_extent(&mut self, child_scope: CodeExtentData) -> CodeExtent {
|
||||
self.region_maps.intern_code_extent(child_scope, self.cx.parent)
|
||||
@ -1173,49 +1173,49 @@ impl<'ast, 'a> RegionResolutionVisitor<'ast, 'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast, 'a> Visitor<'ast> for RegionResolutionVisitor<'ast, 'a> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
impl<'hir, 'a> Visitor<'hir> for RegionResolutionVisitor<'hir, 'a> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
NestedVisitorMap::OnlyBodies(&self.map)
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, b: &'ast Block) {
|
||||
fn visit_block(&mut self, b: &'hir Block) {
|
||||
resolve_block(self, b);
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'ast Item) {
|
||||
fn visit_item(&mut self, i: &'hir Item) {
|
||||
resolve_item_like(self, i.id, |this| intravisit::walk_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) {
|
||||
resolve_item_like(self, ii.id, |this| intravisit::walk_impl_item(this, ii));
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) {
|
||||
resolve_item_like(self, ti.id, |this| intravisit::walk_trait_item(this, ti));
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'ast>, fd: &'ast FnDecl,
|
||||
fn visit_fn(&mut self, fk: FnKind<'hir>, fd: &'hir FnDecl,
|
||||
b: hir::BodyId, s: Span, n: NodeId) {
|
||||
resolve_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
fn visit_arm(&mut self, a: &'ast Arm) {
|
||||
fn visit_arm(&mut self, a: &'hir Arm) {
|
||||
resolve_arm(self, a);
|
||||
}
|
||||
fn visit_pat(&mut self, p: &'ast Pat) {
|
||||
fn visit_pat(&mut self, p: &'hir Pat) {
|
||||
resolve_pat(self, p);
|
||||
}
|
||||
fn visit_stmt(&mut self, s: &'ast Stmt) {
|
||||
fn visit_stmt(&mut self, s: &'hir Stmt) {
|
||||
resolve_stmt(self, s);
|
||||
}
|
||||
fn visit_expr(&mut self, ex: &'ast Expr) {
|
||||
fn visit_expr(&mut self, ex: &'hir Expr) {
|
||||
resolve_expr(self, ex);
|
||||
}
|
||||
fn visit_local(&mut self, l: &'ast Local) {
|
||||
fn visit_local(&mut self, l: &'hir Local) {
|
||||
resolve_local(self, l);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_crate(sess: &Session, map: &ast_map::Map) -> RegionMaps {
|
||||
pub fn resolve_crate(sess: &Session, map: &hir_map::Map) -> RegionMaps {
|
||||
let _task = map.dep_graph.in_task(DepNode::RegionResolveCrate);
|
||||
let krate = map.krate();
|
||||
|
||||
|
@ -178,7 +178,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
self.index.stab_map.insert(def_id, Some(stab));
|
||||
|
||||
let orig_parent_stab = replace(&mut self.parent_stab, Some(stab));
|
||||
@ -188,7 +188,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||
debug!("annotate: not found, parent = {:?}", self.parent_stab);
|
||||
if let Some(stab) = self.parent_stab {
|
||||
if stab.level.is_unstable() {
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
self.index.stab_map.insert(def_id, Some(stab));
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// `Deprecation` is just two pointers, no need to intern it
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
let depr_entry = Some(DeprecationEntry::local(depr, def_id));
|
||||
self.index.depr_map.insert(def_id, depr_entry.clone());
|
||||
|
||||
@ -219,7 +219,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
|
||||
visit_children(self);
|
||||
self.parent_depr = orig_parent_depr;
|
||||
} else if let parent_depr @ Some(_) = self.parent_depr.clone() {
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
self.index.depr_map.insert(def_id, parent_depr);
|
||||
visit_children(self);
|
||||
} else {
|
||||
@ -234,7 +234,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
/// nested items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
@ -313,7 +313,7 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
||||
fn check_missing_stability(&self, id: NodeId, span: Span) {
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
let is_error = !self.tcx.sess.opts.test &&
|
||||
!self.tcx.stability.borrow().stab_map.contains_key(&def_id) &&
|
||||
self.access_levels.is_reachable(id);
|
||||
@ -325,7 +325,7 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
@ -348,7 +348,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
|
||||
let impl_def_id = self.tcx.map.local_def_id(self.tcx.map.get_parent(ii.id));
|
||||
let impl_def_id = self.tcx.hir.local_def_id(self.tcx.hir.get_parent(ii.id));
|
||||
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
|
||||
self.check_missing_stability(ii.id, ii.span);
|
||||
}
|
||||
@ -384,7 +384,7 @@ impl<'a, 'tcx> Index<'tcx> {
|
||||
self.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
|
||||
|
||||
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
let mut annotator = Annotator {
|
||||
tcx: tcx,
|
||||
index: self,
|
||||
@ -484,7 +484,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
let skip = if id == ast::DUMMY_NODE_ID {
|
||||
true
|
||||
} else {
|
||||
let parent_def_id = self.map.local_def_id(self.map.get_parent(id));
|
||||
let parent_def_id = self.hir.local_def_id(self.hir.get_parent(id));
|
||||
self.lookup_deprecation_entry(parent_def_id).map_or(false, |parent_depr| {
|
||||
parent_depr.same_origin(&depr_entry)
|
||||
})
|
||||
@ -555,7 +555,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||
/// nested items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
@ -578,7 +578,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||
hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => {
|
||||
if let Def::Trait(trait_did) = t.path.def {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
let trait_item_def_id = self.tcx.associated_items(trait_did)
|
||||
.find(|item| item.name == impl_item.name).map(|item| item.def_id);
|
||||
if let Some(def_id) = trait_item_def_id {
|
||||
@ -658,7 +658,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
let mut missing = MissingStabilityAnnotations {
|
||||
tcx: tcx,
|
||||
access_levels: access_levels,
|
||||
|
@ -1163,14 +1163,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||
}
|
||||
|
||||
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||
let name = format!("[closure@{:?}]", tcx.map.span(node_id));
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
|
||||
let name = format!("[closure@{:?}]", tcx.hir.span(node_id));
|
||||
let mut struct_fmt = fmt.debug_struct(&name);
|
||||
|
||||
tcx.with_freevars(node_id, |freevars| {
|
||||
for (freevar, lv) in freevars.iter().zip(lvs) {
|
||||
let def_id = freevar.def.def_id();
|
||||
let var_id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let var_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let var_name = tcx.local_var_name_str(var_id);
|
||||
struct_fmt.field(&var_name, lv);
|
||||
}
|
||||
|
@ -40,13 +40,13 @@ impl<'a, 'tcx> MirSource {
|
||||
use hir::*;
|
||||
|
||||
// Handle constants in enum discriminants, types, and repeat expressions.
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
let def_key = tcx.def_key(def_id);
|
||||
if def_key.disambiguated_data.data == DefPathData::Initializer {
|
||||
return MirSource::Const(id);
|
||||
}
|
||||
|
||||
match tcx.map.get(id) {
|
||||
match tcx.hir.get(id) {
|
||||
map::NodeItem(&Item { node: ItemConst(..), .. }) |
|
||||
map::NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
||||
map::NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) => {
|
||||
@ -124,7 +124,7 @@ impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
|
||||
let mir = &mut tcx.mir_map.borrow()[&def_id].borrow_mut();
|
||||
tcx.dep_graph.write(DepNode::Mir(def_id));
|
||||
|
||||
let id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let src = MirSource::from_node(tcx, id);
|
||||
|
||||
for hook in &mut *hooks {
|
||||
|
@ -441,7 +441,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
E0276,
|
||||
"impl has stricter requirements than trait");
|
||||
|
||||
if let Some(trait_item_span) = self.tcx.map.span_if_local(trait_item_def_id) {
|
||||
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
|
||||
err.span_label(trait_item_span,
|
||||
&format!("definition of `{}` from trait", item_name));
|
||||
}
|
||||
@ -594,7 +594,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
ty::Predicate::ClosureKind(closure_def_id, kind) => {
|
||||
let found_kind = self.closure_kind(closure_def_id).unwrap();
|
||||
let closure_span = self.tcx.map.span_if_local(closure_def_id).unwrap();
|
||||
let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap();
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess, closure_span, E0525,
|
||||
"expected a closure that implements the `{}` trait, \
|
||||
@ -653,7 +653,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
assert!(type_def_id.is_local());
|
||||
let span = self.map.span_if_local(type_def_id).unwrap();
|
||||
let span = self.hir.span_if_local(type_def_id).unwrap();
|
||||
let mut err = struct_span_err!(self.sess, span, E0072,
|
||||
"recursive type `{}` has infinite size",
|
||||
self.item_path_str(type_def_id));
|
||||
|
@ -16,7 +16,7 @@ use middle;
|
||||
use hir::TraitMap;
|
||||
use hir::def::Def;
|
||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use hir::map::DisambiguatedDefPathData;
|
||||
use middle::free_region::FreeRegionMap;
|
||||
use middle::region::RegionMaps;
|
||||
@ -265,7 +265,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
||||
Some(ty) => ty,
|
||||
None => {
|
||||
bug!("node_id_to_type: no type for node `{}`",
|
||||
tls::with(|tcx| tcx.map.node_to_string(id)))
|
||||
tls::with(|tcx| tcx.hir.node_to_string(id)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -428,7 +428,7 @@ pub struct GlobalCtxt<'tcx> {
|
||||
/// additional acyclicity requirements).
|
||||
pub super_predicates: RefCell<DepTrackingMap<maps::Predicates<'tcx>>>,
|
||||
|
||||
pub map: ast_map::Map<'tcx>,
|
||||
pub hir: hir_map::Map<'tcx>,
|
||||
|
||||
/// Maps from the def-id of a function/method or const/static
|
||||
/// to its MIR. Mutation is done at an item granularity to
|
||||
@ -628,7 +628,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
debug!("retrace_path(path={:?}, krate={:?})", path_data, self.crate_name(krate));
|
||||
|
||||
if krate == LOCAL_CRATE {
|
||||
self.map
|
||||
self.hir
|
||||
.definitions()
|
||||
.def_path_table()
|
||||
.retrace_path(path_data)
|
||||
@ -730,7 +730,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
arena: &'tcx DroplessArena,
|
||||
resolutions: ty::Resolutions,
|
||||
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||
map: ast_map::Map<'tcx>,
|
||||
hir: hir_map::Map<'tcx>,
|
||||
region_maps: RegionMaps,
|
||||
lang_items: middle::lang_items::LanguageItems,
|
||||
stability: stability::Index<'tcx>,
|
||||
@ -741,7 +741,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
let data_layout = TargetDataLayout::parse(s);
|
||||
let interners = CtxtInterners::new(arena);
|
||||
let common_types = CommonTypes::new(&interners);
|
||||
let dep_graph = map.dep_graph.clone();
|
||||
let dep_graph = hir.dep_graph.clone();
|
||||
let fulfilled_predicates = traits::GlobalFulfilledPredicates::new(dep_graph.clone());
|
||||
tls::enter_global(GlobalCtxt {
|
||||
specializes_cache: RefCell::new(traits::SpecializesCache::new()),
|
||||
@ -765,7 +765,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
|
||||
super_predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
|
||||
fulfilled_predicates: RefCell::new(fulfilled_predicates),
|
||||
map: map,
|
||||
hir: hir,
|
||||
mir_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
|
||||
freevars: RefCell::new(resolutions.freevars),
|
||||
maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
|
||||
|
@ -283,7 +283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
expected.ty,
|
||||
found.ty));
|
||||
|
||||
match self.map.span_if_local(expected.def_id) {
|
||||
match self.hir.span_if_local(expected.def_id) {
|
||||
Some(span) => {
|
||||
db.span_note(span, "a default was defined here...");
|
||||
}
|
||||
@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
expected.origin_span,
|
||||
"...that was applied to an unconstrained type variable here");
|
||||
|
||||
match self.map.span_if_local(found.def_id) {
|
||||
match self.hir.span_if_local(found.def_id) {
|
||||
Some(span) => {
|
||||
db.span_note(span, "a second default was defined here...");
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
|
||||
/// crate.
|
||||
#[inline]
|
||||
pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest {
|
||||
let crate_id = tcx.map.local_def_id(CRATE_NODE_ID);
|
||||
let crate_id = tcx.hir.local_def_id(CRATE_NODE_ID);
|
||||
DefIdForest::from_id(crate_id)
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
/// 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))
|
||||
self.item_path_str(self.hir.local_def_id(id))
|
||||
}
|
||||
|
||||
/// Returns a string identifying this def-id. This string is
|
||||
@ -286,8 +286,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
// only occur very early in the compiler pipeline.
|
||||
let parent_def_id = self.parent_def_id(impl_def_id).unwrap();
|
||||
self.push_item_path(buffer, parent_def_id);
|
||||
let node_id = self.map.as_local_node_id(impl_def_id).unwrap();
|
||||
let item = self.map.expect_item(node_id);
|
||||
let node_id = self.hir.as_local_node_id(impl_def_id).unwrap();
|
||||
let item = self.hir.expect_item(node_id);
|
||||
let span_str = self.sess.codemap().span_to_string(item.span);
|
||||
buffer.push(&format!("<impl at {}>", span_str));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ pub use self::LvaluePreference::*;
|
||||
pub use self::fold::TypeFoldable;
|
||||
|
||||
use dep_graph::{self, DepNode};
|
||||
use hir::{map as ast_map, FreevarMap, TraitMap};
|
||||
use hir::{map as hir_map, FreevarMap, TraitMap};
|
||||
use middle;
|
||||
use hir::def::{Def, CtorKind, ExportMap};
|
||||
use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
@ -261,7 +261,7 @@ impl Visibility {
|
||||
def => Visibility::Restricted(def.def_id()),
|
||||
},
|
||||
hir::Inherited => {
|
||||
Visibility::Restricted(tcx.map.local_def_id(tcx.map.get_module_parent(id)))
|
||||
Visibility::Restricted(tcx.hir.local_def_id(tcx.hir.get_module_parent(id)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1198,14 +1198,14 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
/// Construct a parameter environment given an item, impl item, or trait item
|
||||
pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId)
|
||||
-> ParameterEnvironment<'tcx> {
|
||||
match tcx.map.find(id) {
|
||||
Some(ast_map::NodeImplItem(ref impl_item)) => {
|
||||
match tcx.hir.find(id) {
|
||||
Some(hir_map::NodeImplItem(ref impl_item)) => {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Type(_) | hir::ImplItemKind::Const(..) => {
|
||||
// associated types don't have their own entry (for some reason),
|
||||
// so for now just grab environment for the impl
|
||||
let impl_id = tcx.map.get_parent(id);
|
||||
let impl_def_id = tcx.map.local_def_id(impl_id);
|
||||
let impl_id = tcx.hir.get_parent(id);
|
||||
let impl_def_id = tcx.hir.local_def_id(impl_id);
|
||||
tcx.construct_parameter_environment(impl_item.span,
|
||||
impl_def_id,
|
||||
tcx.region_maps.item_extent(id))
|
||||
@ -1213,18 +1213,18 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
hir::ImplItemKind::Method(_, ref body) => {
|
||||
tcx.construct_parameter_environment(
|
||||
impl_item.span,
|
||||
tcx.map.local_def_id(id),
|
||||
tcx.hir.local_def_id(id),
|
||||
tcx.region_maps.call_site_extent(id, body.node_id))
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeTraitItem(trait_item)) => {
|
||||
Some(hir_map::NodeTraitItem(trait_item)) => {
|
||||
match trait_item.node {
|
||||
hir::TraitItemKind::Type(..) | hir::TraitItemKind::Const(..) => {
|
||||
// associated types don't have their own entry (for some reason),
|
||||
// so for now just grab environment for the trait
|
||||
let trait_id = tcx.map.get_parent(id);
|
||||
let trait_def_id = tcx.map.local_def_id(trait_id);
|
||||
let trait_id = tcx.hir.get_parent(id);
|
||||
let trait_def_id = tcx.hir.local_def_id(trait_id);
|
||||
tcx.construct_parameter_environment(trait_item.span,
|
||||
trait_def_id,
|
||||
tcx.region_maps.item_extent(id))
|
||||
@ -1242,16 +1242,16 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
};
|
||||
tcx.construct_parameter_environment(
|
||||
trait_item.span,
|
||||
tcx.map.local_def_id(id),
|
||||
tcx.hir.local_def_id(id),
|
||||
extent)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
Some(hir_map::NodeItem(item)) => {
|
||||
match item.node {
|
||||
hir::ItemFn(.., body_id) => {
|
||||
// We assume this is a function.
|
||||
let fn_def_id = tcx.map.local_def_id(id);
|
||||
let fn_def_id = tcx.hir.local_def_id(id);
|
||||
|
||||
tcx.construct_parameter_environment(
|
||||
item.span,
|
||||
@ -1265,13 +1265,13 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
hir::ItemImpl(..) |
|
||||
hir::ItemConst(..) |
|
||||
hir::ItemStatic(..) => {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
tcx.construct_parameter_environment(item.span,
|
||||
def_id,
|
||||
tcx.region_maps.item_extent(id))
|
||||
}
|
||||
hir::ItemTrait(..) => {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
tcx.construct_parameter_environment(item.span,
|
||||
def_id,
|
||||
tcx.region_maps.item_extent(id))
|
||||
@ -1284,10 +1284,10 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeExpr(expr)) => {
|
||||
Some(hir_map::NodeExpr(expr)) => {
|
||||
// This is a convenience to allow closures to work.
|
||||
if let hir::ExprClosure(.., body, _) = expr.node {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
let base_def_id = tcx.closure_base_def_id(def_id);
|
||||
tcx.construct_parameter_environment(
|
||||
expr.span,
|
||||
@ -1297,8 +1297,8 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
tcx.empty_parameter_environment()
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeForeignItem(item)) => {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
Some(hir_map::NodeForeignItem(item)) => {
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
tcx.construct_parameter_environment(item.span,
|
||||
def_id,
|
||||
ROOT_CODE_EXTENT)
|
||||
@ -1306,7 +1306,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
||||
_ => {
|
||||
bug!("ParameterEnvironment::from_item(): \
|
||||
`{}` is not an item",
|
||||
tcx.map.node_to_string(id))
|
||||
tcx.hir.node_to_string(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1918,7 +1918,7 @@ impl BorrowKind {
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
|
||||
self.item_tables(self.map.body_owner_def_id(body))
|
||||
self.item_tables(self.hir.body_owner_def_id(body))
|
||||
}
|
||||
|
||||
pub fn item_tables(self, def_id: DefId) -> &'gcx TypeckTables<'gcx> {
|
||||
@ -1944,8 +1944,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn expr_span(self, id: NodeId) -> Span {
|
||||
match self.map.find(id) {
|
||||
Some(ast_map::NodeExpr(e)) => {
|
||||
match self.hir.find(id) {
|
||||
Some(hir_map::NodeExpr(e)) => {
|
||||
e.span
|
||||
}
|
||||
Some(f) => {
|
||||
@ -1958,8 +1958,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn local_var_name_str(self, id: NodeId) -> InternedString {
|
||||
match self.map.find(id) {
|
||||
Some(ast_map::NodeLocal(pat)) => {
|
||||
match self.hir.find(id) {
|
||||
Some(hir_map::NodeLocal(pat)) => {
|
||||
match pat.node {
|
||||
hir::PatKind::Binding(_, _, ref path1, _) => path1.node.as_str(),
|
||||
_ => {
|
||||
@ -2031,8 +2031,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn trait_impl_polarity(self, id: DefId) -> hir::ImplPolarity {
|
||||
if let Some(id) = self.map.as_local_node_id(id) {
|
||||
match self.map.expect_item(id).node {
|
||||
if let Some(id) = self.hir.as_local_node_id(id) {
|
||||
match self.hir.expect_item(id).node {
|
||||
hir::ItemImpl(_, polarity, ..) => polarity,
|
||||
ref item => bug!("trait_impl_polarity: {:?} not an impl", item)
|
||||
}
|
||||
@ -2077,10 +2077,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
// those tasks that just need to scan the names of items
|
||||
// and so forth.
|
||||
|
||||
let id = self.map.as_local_node_id(def_id).unwrap();
|
||||
let parent_id = self.map.get_parent(id);
|
||||
let parent_def_id = self.map.local_def_id(parent_id);
|
||||
let parent_item = self.map.expect_item(parent_id);
|
||||
let id = self.hir.as_local_node_id(def_id).unwrap();
|
||||
let parent_id = self.hir.get_parent(id);
|
||||
let parent_def_id = self.hir.local_def_id(parent_id);
|
||||
let parent_item = self.hir.expect_item(parent_id);
|
||||
match parent_item.node {
|
||||
hir::ItemImpl(.., ref impl_trait_ref, _, ref impl_item_refs) => {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
@ -2115,7 +2115,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
parent_def_id: DefId,
|
||||
trait_item_ref: &hir::TraitItemRef)
|
||||
-> AssociatedItem {
|
||||
let def_id = self.map.local_def_id(trait_item_ref.id.node_id);
|
||||
let def_id = self.hir.local_def_id(trait_item_ref.id.node_id);
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
|
||||
hir::AssociatedItemKind::Method { has_self } => {
|
||||
@ -2140,7 +2140,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
from_trait_impl: bool,
|
||||
impl_item_ref: &hir::ImplItemRef)
|
||||
-> AssociatedItem {
|
||||
let def_id = self.map.local_def_id(impl_item_ref.id.node_id);
|
||||
let def_id = self.hir.local_def_id(impl_item_ref.id.node_id);
|
||||
let (kind, has_self) = match impl_item_ref.kind {
|
||||
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
|
||||
hir::AssociatedItemKind::Method { has_self } => {
|
||||
@ -2170,19 +2170,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
return Rc::new(self.sess.cstore.associated_item_def_ids(def_id));
|
||||
}
|
||||
|
||||
let id = self.map.as_local_node_id(def_id).unwrap();
|
||||
let item = self.map.expect_item(id);
|
||||
let id = self.hir.as_local_node_id(def_id).unwrap();
|
||||
let item = self.hir.expect_item(id);
|
||||
let vec: Vec<_> = match item.node {
|
||||
hir::ItemTrait(.., ref trait_item_refs) => {
|
||||
trait_item_refs.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| self.map.local_def_id(id.node_id))
|
||||
.map(|id| self.hir.local_def_id(id.node_id))
|
||||
.collect()
|
||||
}
|
||||
hir::ItemImpl(.., ref impl_item_refs) => {
|
||||
impl_item_refs.iter()
|
||||
.map(|impl_item_ref| impl_item_ref.id)
|
||||
.map(|id| self.map.local_def_id(id.node_id))
|
||||
.map(|id| self.hir.local_def_id(id.node_id))
|
||||
.collect()
|
||||
}
|
||||
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
|
||||
@ -2225,9 +2225,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn def_key(self, id: DefId) -> ast_map::DefKey {
|
||||
pub fn def_key(self, id: DefId) -> hir_map::DefKey {
|
||||
if id.is_local() {
|
||||
self.map.def_key(id)
|
||||
self.hir.def_key(id)
|
||||
} else {
|
||||
self.sess.cstore.def_key(id)
|
||||
}
|
||||
@ -2238,35 +2238,35 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
///
|
||||
/// Note that if `id` is not local to this crate, the result will
|
||||
// be a non-local `DefPath`.
|
||||
pub fn def_path(self, id: DefId) -> ast_map::DefPath {
|
||||
pub fn def_path(self, id: DefId) -> hir_map::DefPath {
|
||||
if id.is_local() {
|
||||
self.map.def_path(id)
|
||||
self.hir.def_path(id)
|
||||
} else {
|
||||
self.sess.cstore.def_path(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn def_span(self, def_id: DefId) -> Span {
|
||||
if let Some(id) = self.map.as_local_node_id(def_id) {
|
||||
self.map.span(id)
|
||||
if let Some(id) = self.hir.as_local_node_id(def_id) {
|
||||
self.hir.span(id)
|
||||
} else {
|
||||
self.sess.cstore.def_span(&self.sess, def_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vis_is_accessible_from(self, vis: Visibility, block: NodeId) -> bool {
|
||||
vis.is_accessible_from(self.map.local_def_id(self.map.get_module_parent(block)), self)
|
||||
vis.is_accessible_from(self.hir.local_def_id(self.hir.get_module_parent(block)), self)
|
||||
}
|
||||
|
||||
pub fn item_name(self, id: DefId) -> ast::Name {
|
||||
if let Some(id) = self.map.as_local_node_id(id) {
|
||||
self.map.name(id)
|
||||
if let Some(id) = self.hir.as_local_node_id(id) {
|
||||
self.hir.name(id)
|
||||
} else if id.index == CRATE_DEF_INDEX {
|
||||
self.sess.cstore.original_crate_name(id.krate)
|
||||
} else {
|
||||
let def_key = self.sess.cstore.def_key(id);
|
||||
// The name of a StructCtor is that of its struct parent.
|
||||
if let ast_map::DefPathData::StructCtor = def_key.disambiguated_data.data {
|
||||
if let hir_map::DefPathData::StructCtor = def_key.disambiguated_data.data {
|
||||
self.item_name(DefId {
|
||||
krate: id.krate,
|
||||
index: def_key.parent.unwrap()
|
||||
@ -2372,8 +2372,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
/// Get the attributes of a definition.
|
||||
pub fn get_attrs(self, did: DefId) -> Cow<'gcx, [ast::Attribute]> {
|
||||
if let Some(id) = self.map.as_local_node_id(did) {
|
||||
Cow::Borrowed(self.map.attrs(id))
|
||||
if let Some(id) = self.hir.as_local_node_id(did) {
|
||||
Cow::Borrowed(self.hir.attrs(id))
|
||||
} else {
|
||||
Cow::Owned(self.sess.cstore.item_attrs(did))
|
||||
}
|
||||
@ -2656,8 +2656,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
/// with the name of the crate containing the impl.
|
||||
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
|
||||
if impl_did.is_local() {
|
||||
let node_id = self.map.as_local_node_id(impl_did).unwrap();
|
||||
Ok(self.map.span(node_id))
|
||||
let node_id = self.hir.as_local_node_id(impl_did).unwrap();
|
||||
Ok(self.hir.span(node_id))
|
||||
} else {
|
||||
Err(self.sess.cstore.crate_name(impl_did.krate))
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
use hir::def_id::DefId;
|
||||
use hir::map::DefPathData;
|
||||
use infer::InferCtxt;
|
||||
use hir::map as ast_map;
|
||||
use hir::map as hir_map;
|
||||
use traits::{self, Reveal};
|
||||
use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
|
||||
use ty::{Disr, ParameterEnvironment};
|
||||
@ -429,7 +429,7 @@ impl<'a, 'gcx, 'tcx, W> TypeIdHasher<'a, 'gcx, 'tcx, W>
|
||||
self.def_path(&path)
|
||||
}
|
||||
|
||||
pub fn def_path(&mut self, def_path: &ast_map::DefPath) {
|
||||
pub fn def_path(&mut self, def_path: &hir_map::DefPath) {
|
||||
def_path.deterministic_hash_to(self.tcx, &mut self.state);
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ fn in_binder<'a, 'gcx, 'tcx, T, U>(f: &mut fmt::Formatter,
|
||||
ty::BrEnv => {
|
||||
let name = Symbol::intern("'r");
|
||||
let _ = write!(f, "{}", name);
|
||||
ty::BrNamed(tcx.map.local_def_id(CRATE_NODE_ID),
|
||||
ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID),
|
||||
name,
|
||||
ty::Issue32330::WontChange)
|
||||
}
|
||||
@ -833,13 +833,13 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
||||
let upvar_tys = substs.upvar_tys(did, tcx);
|
||||
write!(f, "[closure")?;
|
||||
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(did) {
|
||||
write!(f, "@{:?}", tcx.map.span(node_id))?;
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(did) {
|
||||
write!(f, "@{:?}", tcx.hir.span(node_id))?;
|
||||
let mut sep = " ";
|
||||
tcx.with_freevars(node_id, |freevars| {
|
||||
for (freevar, upvar_ty) in freevars.iter().zip(upvar_tys) {
|
||||
let def_id = freevar.def.def_id();
|
||||
let node_id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
write!(f,
|
||||
"{}{}:{}",
|
||||
sep,
|
||||
|
@ -460,7 +460,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
// 3. Where does old loan expire.
|
||||
|
||||
let previous_end_span =
|
||||
self.tcx().map.span(old_loan.kill_scope.node_id(&self.tcx().region_maps))
|
||||
self.tcx().hir.span(old_loan.kill_scope.node_id(&self.tcx().region_maps))
|
||||
.end_point();
|
||||
|
||||
let mut err = match (new_loan.kind, old_loan.kind) {
|
||||
@ -704,7 +704,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||
borrow_kind: ty::BorrowKind)
|
||||
-> UseError<'tcx> {
|
||||
debug!("analyze_restrictions_on_use(expr_id={}, use_path={:?})",
|
||||
self.tcx().map.node_to_string(expr_id),
|
||||
self.tcx().hir.node_to_string(expr_id),
|
||||
use_path);
|
||||
|
||||
let mut ret = UseOk;
|
||||
|
@ -132,7 +132,7 @@ pub fn build_unfragmented_map(this: &mut borrowck::BorrowckCtxt,
|
||||
}
|
||||
|
||||
let mut fraginfo_map = this.tcx.fragment_infos.borrow_mut();
|
||||
let fn_did = this.tcx.map.local_def_id(id);
|
||||
let fn_did = this.tcx.hir.local_def_id(id);
|
||||
let prev = fraginfo_map.insert(fn_did, fragment_infos);
|
||||
assert!(prev.is_none());
|
||||
}
|
||||
@ -202,7 +202,7 @@ pub fn instrument_move_fragments<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sp: Span,
|
||||
id: ast::NodeId) {
|
||||
let span_err = tcx.map.attrs(id).iter()
|
||||
let span_err = tcx.hir.attrs(id).iter()
|
||||
.any(|a| a.check_name("rustc_move_fragments"));
|
||||
let print = tcx.sess.opts.debugging_opts.print_move_fragments;
|
||||
|
||||
@ -496,7 +496,7 @@ fn add_fragment_siblings_for_extension<'a, 'tcx>(this: &MoveData<'tcx>,
|
||||
},
|
||||
|
||||
ref ty => {
|
||||
let span = origin_id.map_or(DUMMY_SP, |id| tcx.map.span(id));
|
||||
let span = origin_id.map_or(DUMMY_SP, |id| tcx.hir.span(id));
|
||||
span_bug!(span,
|
||||
"type {:?} ({:?}) is not fragmentable",
|
||||
parent_ty, ty);
|
||||
|
@ -53,7 +53,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_error_collector: move_error::MoveErrorCollector::new(),
|
||||
};
|
||||
|
||||
let body = glcx.bccx.tcx.map.body(body);
|
||||
let body = glcx.bccx.tcx.hir.body(body);
|
||||
euv::ExprUseVisitor::new(&mut glcx, &infcx).consume_body(body);
|
||||
|
||||
glcx.report_potential_errors();
|
||||
@ -553,6 +553,6 @@ pub fn gather_loans_in_static_initializer(bccx: &mut BorrowckCtxt, body: hir::Bo
|
||||
body_id: body
|
||||
};
|
||||
|
||||
let body = sicx.bccx.tcx.map.body(body);
|
||||
let body = sicx.bccx.tcx.hir.body(body);
|
||||
sicx.visit_body(body);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ pub fn borrowck_mir(bcx: &mut BorrowckCtxt,
|
||||
id: ast::NodeId,
|
||||
attributes: &[ast::Attribute]) {
|
||||
let tcx = bcx.tcx;
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
debug!("borrowck_mir({}) UNIMPLEMENTED", tcx.item_path_str(def_id));
|
||||
|
||||
let mir = &tcx.item_mir(def_id);
|
||||
|
@ -64,7 +64,7 @@ pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for BorrowckCtxt<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
|
||||
@ -167,7 +167,7 @@ fn borrowck_fn<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
||||
attributes: &[ast::Attribute]) {
|
||||
debug!("borrowck_fn(id={})", id);
|
||||
|
||||
let body = this.tcx.map.body(body_id);
|
||||
let body = this.tcx.hir.body(body_id);
|
||||
|
||||
if attributes.iter().any(|item| item.check_name("rustc_mir_borrowck")) {
|
||||
this.with_temp_region_map(id, |this| {
|
||||
@ -201,9 +201,9 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
||||
{
|
||||
// Check the body of fn items.
|
||||
let tcx = this.tcx;
|
||||
let body = tcx.map.body(body_id);
|
||||
let body = tcx.hir.body(body_id);
|
||||
let id_range = {
|
||||
let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.map);
|
||||
let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir);
|
||||
visitor.visit_body(body);
|
||||
visitor.result()
|
||||
};
|
||||
@ -398,7 +398,7 @@ pub enum LoanPathElem<'tcx> {
|
||||
|
||||
pub fn closure_to_block(closure_id: ast::NodeId,
|
||||
tcx: TyCtxt) -> ast::NodeId {
|
||||
match tcx.map.get(closure_id) {
|
||||
match tcx.hir.get(closure_id) {
|
||||
hir_map::NodeExpr(expr) => match expr.node {
|
||||
hir::ExprClosure(.., body_id, _) => {
|
||||
body_id.node_id
|
||||
@ -685,10 +685,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
|
||||
move_data::MoveExpr |
|
||||
move_data::MovePat =>
|
||||
(self.tcx.map.span(the_move.id), ""),
|
||||
(self.tcx.hir.span(the_move.id), ""),
|
||||
|
||||
move_data::Captured =>
|
||||
(match self.tcx.map.expect_expr(the_move.id).node {
|
||||
(match self.tcx.hir.expect_expr(the_move.id).node {
|
||||
hir::ExprClosure(.., fn_decl_span) => fn_decl_span,
|
||||
ref r => bug!("Captured({}) maps to non-closure: {:?}",
|
||||
the_move.id, r),
|
||||
@ -882,10 +882,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
// happen for nested closures, so we know the enclosing
|
||||
// closure incorrectly accepts an `Fn` while it needs to
|
||||
// be `FnMut`.
|
||||
span_help!(&mut err, self.tcx.map.span(id),
|
||||
span_help!(&mut err, self.tcx.hir.span(id),
|
||||
"consider changing this to accept closures that implement `FnMut`");
|
||||
} else {
|
||||
span_help!(&mut err, self.tcx.map.span(id),
|
||||
span_help!(&mut err, self.tcx.hir.span(id),
|
||||
"consider changing this closure to take self by mutable reference");
|
||||
}
|
||||
err
|
||||
@ -948,7 +948,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
fn region_end_span(&self, region: &'tcx ty::Region) -> Option<Span> {
|
||||
match *region {
|
||||
ty::ReScope(scope) => {
|
||||
match scope.span(&self.tcx.region_maps, &self.tcx.map) {
|
||||
match scope.span(&self.tcx.region_maps, &self.tcx.hir) {
|
||||
Some(s) => {
|
||||
Some(s.end_point())
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
_ => bug!()
|
||||
};
|
||||
if kind == ty::ClosureKind::Fn {
|
||||
db.span_help(self.tcx.map.span(upvar_id.closure_expr_id),
|
||||
db.span_help(self.tcx.hir.span(upvar_id.closure_expr_id),
|
||||
"consider changing this closure to take \
|
||||
self by mutable reference");
|
||||
}
|
||||
@ -1105,10 +1105,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
_ => {
|
||||
if let Categorization::Deref(ref inner_cmt, ..) = err.cmt.cat {
|
||||
if let Categorization::Local(local_id) = inner_cmt.cat {
|
||||
let parent = self.tcx.map.get_parent_node(local_id);
|
||||
let parent = self.tcx.hir.get_parent_node(local_id);
|
||||
|
||||
if let Some(fn_like) = FnLikeNode::from_node(self.tcx.map.get(parent)) {
|
||||
if let Some(i) = self.tcx.map.body(fn_like.body()).arguments.iter()
|
||||
if let Some(fn_like) = FnLikeNode::from_node(self.tcx.hir.get(parent)) {
|
||||
if let Some(i) = self.tcx.hir.body(fn_like.body()).arguments.iter()
|
||||
.position(|arg| arg.pat.id == local_id) {
|
||||
let arg_ty = &fn_like.decl().inputs[i];
|
||||
if let hir::TyRptr(
|
||||
@ -1141,7 +1141,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
} else if let Categorization::Local(local_id) = err.cmt.cat {
|
||||
let span = self.tcx.map.span(local_id);
|
||||
let span = self.tcx.hir.span(local_id);
|
||||
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
|
||||
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
|
||||
db.span_label(*error_span, &format!("cannot reborrow mutably"));
|
||||
@ -1253,7 +1253,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
fn statement_scope_span(tcx: TyCtxt, region: &ty::Region) -> Option<Span> {
|
||||
match *region {
|
||||
ty::ReScope(scope) => {
|
||||
match tcx.map.find(scope.node_id(&tcx.region_maps)) {
|
||||
match tcx.hir.find(scope.node_id(&tcx.region_maps)) {
|
||||
Some(hir_map::NodeStmt(stmt)) => Some(stmt.span),
|
||||
_ => None
|
||||
}
|
||||
@ -1302,11 +1302,11 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => {
|
||||
let s = ty::tls::with(|tcx| tcx.map.node_to_string(var_id));
|
||||
let s = ty::tls::with(|tcx| tcx.hir.node_to_string(var_id));
|
||||
write!(f, "$({} captured by id={})", s, closure_expr_id)
|
||||
}
|
||||
|
||||
@ -1334,11 +1334,11 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_user_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_id, closure_expr_id: _ }) => {
|
||||
let s = ty::tls::with(|tcx| tcx.map.node_to_user_string(var_id));
|
||||
let s = ty::tls::with(|tcx| tcx.hir.node_to_user_string(var_id));
|
||||
write!(f, "$({} captured by closure)", s)
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
||||
/// Adds a new record for a match of `base_lp`, downcast to
|
||||
/// variant `lp`, that occurs at location `pattern_id`. (One
|
||||
/// should be able to recover the span info from the
|
||||
/// `pattern_id` and the ast_map, I think.)
|
||||
/// `pattern_id` and the hir_map, I think.)
|
||||
pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
lp: Rc<LoanPath<'tcx>>,
|
||||
pattern_id: ast::NodeId,
|
||||
|
@ -42,7 +42,7 @@ struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> }
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
|
||||
@ -53,7 +53,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
|
||||
tcx: self.tcx,
|
||||
tables: self.tcx.body_tables(b),
|
||||
param_env: &ty::ParameterEnvironment::for_item(self.tcx, id)
|
||||
}.visit_body(self.tcx.map.body(b));
|
||||
}.visit_body(self.tcx.hir.body(b));
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let module = self.tcx.map.local_def_id(self.tcx.map.get_module_parent(scrut.id));
|
||||
let module = self.tcx.hir.local_def_id(self.tcx.hir.get_module_parent(scrut.id));
|
||||
MatchCheckCtxt::create_and_enter(self.tcx, module, |ref mut cx| {
|
||||
let mut have_errors = false;
|
||||
|
||||
@ -195,7 +195,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||
"local binding"
|
||||
};
|
||||
|
||||
let module = self.tcx.map.local_def_id(self.tcx.map.get_module_parent(pat.id));
|
||||
let module = self.tcx.hir.local_def_id(self.tcx.hir.get_module_parent(pat.id));
|
||||
MatchCheckCtxt::create_and_enter(self.tcx, module, |ref mut cx| {
|
||||
let mut patcx = PatternContext::new(self.tcx, self.tables);
|
||||
let pattern = patcx.lower_pattern(pat);
|
||||
|
@ -15,7 +15,7 @@ use rustc::middle::const_val::ConstVal;
|
||||
use self::ErrKind::*;
|
||||
use self::EvalHint::*;
|
||||
|
||||
use rustc::hir::map as ast_map;
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::hir::map::blocks::FnLikeNode;
|
||||
use rustc::traits;
|
||||
use rustc::hir::def::Def;
|
||||
@ -53,15 +53,15 @@ macro_rules! math {
|
||||
fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
variant_def: DefId)
|
||||
-> Option<(&'tcx Expr, Option<&'a ty::TypeckTables<'tcx>>)> {
|
||||
if let Some(variant_node_id) = tcx.map.as_local_node_id(variant_def) {
|
||||
let enum_node_id = tcx.map.get_parent(variant_node_id);
|
||||
if let Some(ast_map::NodeItem(it)) = tcx.map.find(enum_node_id) {
|
||||
if let Some(variant_node_id) = tcx.hir.as_local_node_id(variant_def) {
|
||||
let enum_node_id = tcx.hir.get_parent(variant_node_id);
|
||||
if let Some(hir_map::NodeItem(it)) = tcx.hir.find(enum_node_id) {
|
||||
if let hir::ItemEnum(ref edef, _) = it.node {
|
||||
for variant in &edef.variants {
|
||||
if variant.node.data.id() == variant_node_id {
|
||||
return variant.node.disr_expr.map(|e| {
|
||||
let def_id = tcx.map.body_owner_def_id(e);
|
||||
(&tcx.map.body(e).value,
|
||||
let def_id = tcx.hir.body_owner_def_id(e);
|
||||
(&tcx.hir.body(e).value,
|
||||
tcx.tables.borrow().get(&def_id).cloned())
|
||||
});
|
||||
}
|
||||
@ -83,29 +83,29 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> Option<(&'tcx Expr,
|
||||
Option<&'a ty::TypeckTables<'tcx>>,
|
||||
Option<ty::Ty<'tcx>>)> {
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||
match tcx.map.find(node_id) {
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
|
||||
match tcx.hir.find(node_id) {
|
||||
None => None,
|
||||
Some(ast_map::NodeItem(&hir::Item {
|
||||
Some(hir_map::NodeItem(&hir::Item {
|
||||
node: hir::ItemConst(ref ty, body), ..
|
||||
})) |
|
||||
Some(ast_map::NodeImplItem(&hir::ImplItem {
|
||||
Some(hir_map::NodeImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Const(ref ty, body), ..
|
||||
})) => {
|
||||
Some((&tcx.map.body(body).value,
|
||||
Some((&tcx.hir.body(body).value,
|
||||
tcx.tables.borrow().get(&def_id).cloned(),
|
||||
tcx.ast_ty_to_prim_ty(ty)))
|
||||
}
|
||||
Some(ast_map::NodeTraitItem(ti)) => match ti.node {
|
||||
Some(hir_map::NodeTraitItem(ti)) => match ti.node {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
if let Some(substs) = substs {
|
||||
// If we have a trait item and the substitutions for it,
|
||||
// `resolve_trait_associated_const` will select an impl
|
||||
// or the default.
|
||||
let trait_id = tcx.map.get_parent(node_id);
|
||||
let trait_id = tcx.map.local_def_id(trait_id);
|
||||
let trait_id = tcx.hir.get_parent(node_id);
|
||||
let trait_id = tcx.hir.local_def_id(trait_id);
|
||||
let default_value = default.map(|body| {
|
||||
(&tcx.map.body(body).value,
|
||||
(&tcx.hir.body(body).value,
|
||||
tcx.tables.borrow().get(&def_id).cloned(),
|
||||
tcx.ast_ty_to_prim_ty(ty))
|
||||
});
|
||||
@ -156,10 +156,10 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> Option<(&'tcx hir::Body, Option<&'a ty::TypeckTables<'tcx>>)>
|
||||
{
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||
FnLikeNode::from_node(tcx.map.get(node_id)).and_then(|fn_like| {
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
|
||||
FnLikeNode::from_node(tcx.hir.get(node_id)).and_then(|fn_like| {
|
||||
if fn_like.constness() == hir::Constness::Const {
|
||||
Some((tcx.map.body(fn_like.body()),
|
||||
Some((tcx.hir.body(fn_like.body()),
|
||||
tcx.tables.borrow().get(&def_id).cloned()))
|
||||
} else {
|
||||
None
|
||||
@ -232,7 +232,7 @@ pub struct ConstContext<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> ConstContext<'a, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, body: hir::BodyId) -> Self {
|
||||
let def_id = tcx.map.body_owner_def_id(body);
|
||||
let def_id = tcx.hir.body_owner_def_id(body);
|
||||
ConstContext {
|
||||
tcx: tcx,
|
||||
tables: tcx.tables.borrow().get(&def_id).cloned(),
|
||||
@ -808,7 +808,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
|
||||
_ => bug!()
|
||||
}
|
||||
} else {
|
||||
let n = &tcx.map.body(count).value;
|
||||
let n = &tcx.hir.body(count).value;
|
||||
match ConstContext::new(tcx, count).eval(n, len_hint)? {
|
||||
Integral(Usize(i)) => i.as_u64(tcx.sess.target.uint_type),
|
||||
Integral(_) => signal!(e, RepeatCountNotNatural),
|
||||
@ -1203,7 +1203,7 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> Result<usize, ErrorReported>
|
||||
{
|
||||
let hint = UncheckedExprHint(tcx.types.usize);
|
||||
let count_expr = &tcx.map.body(count).value;
|
||||
let count_expr = &tcx.hir.body(count).value;
|
||||
match ConstContext::new(tcx, count).eval(count_expr, hint) {
|
||||
Ok(Integral(Usize(count))) => {
|
||||
let val = count.as_u64(tcx.sess.target.uint_type);
|
||||
@ -1227,7 +1227,7 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
if let hir::ExprPath(hir::QPath::Resolved(None, ref path)) = count_expr.node {
|
||||
if let Def::Local(..) = path.def {
|
||||
diag.note(&format!("`{}` is a variable",
|
||||
tcx.map.node_to_pretty_string(count_expr.id)));
|
||||
tcx.hir.node_to_pretty_string(count_expr.id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ impl<'a, 'gcx, 'tcx> PatternContext<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
PatKind::Binding(bm, def_id, ref ident, ref sub) => {
|
||||
let id = self.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let var_ty = self.tables.node_id_to_type(pat.id);
|
||||
let region = match var_ty.sty {
|
||||
ty::TyRef(r, _) => Some(r),
|
||||
|
@ -181,7 +181,7 @@ pub fn compile_input(sess: &Session,
|
||||
outdir,
|
||||
output,
|
||||
opt_crate,
|
||||
tcx.map.krate(),
|
||||
tcx.hir.krate(),
|
||||
&analysis,
|
||||
tcx,
|
||||
&crate_name);
|
||||
@ -340,7 +340,7 @@ pub struct CompileState<'a, 'tcx: 'a> {
|
||||
pub arenas: Option<&'tcx GlobalArenas<'tcx>>,
|
||||
pub expanded_crate: Option<&'a ast::Crate>,
|
||||
pub hir_crate: Option<&'a hir::Crate>,
|
||||
pub ast_map: Option<&'a hir_map::Map<'tcx>>,
|
||||
pub hir_map: Option<&'a hir_map::Map<'tcx>>,
|
||||
pub resolutions: Option<&'a Resolutions>,
|
||||
pub analysis: Option<&'a ty::CrateAnalysis<'tcx>>,
|
||||
pub tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
|
||||
@ -366,7 +366,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
|
||||
output_filenames: None,
|
||||
expanded_crate: None,
|
||||
hir_crate: None,
|
||||
ast_map: None,
|
||||
hir_map: None,
|
||||
resolutions: None,
|
||||
analysis: None,
|
||||
tcx: None,
|
||||
@ -427,7 +427,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
|
||||
arena: Some(arena),
|
||||
arenas: Some(arenas),
|
||||
cstore: Some(cstore),
|
||||
ast_map: Some(hir_map),
|
||||
hir_map: Some(hir_map),
|
||||
analysis: Some(analysis),
|
||||
resolutions: Some(resolutions),
|
||||
expanded_crate: Some(krate),
|
||||
|
@ -454,7 +454,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
||||
};
|
||||
control.after_hir_lowering.callback = box move |state| {
|
||||
pretty::print_after_hir_lowering(state.session,
|
||||
state.ast_map.unwrap(),
|
||||
state.hir_map.unwrap(),
|
||||
state.analysis.unwrap(),
|
||||
state.resolutions.unwrap(),
|
||||
state.input,
|
||||
|
@ -167,7 +167,7 @@ impl PpSourceMode {
|
||||
/// Constructs a `PrinterSupport` object and passes it to `f`.
|
||||
fn call_with_pp_support<'tcx, A, B, F>(&self,
|
||||
sess: &'tcx Session,
|
||||
ast_map: Option<&hir_map::Map<'tcx>>,
|
||||
hir_map: Option<&hir_map::Map<'tcx>>,
|
||||
payload: B,
|
||||
f: F)
|
||||
-> A
|
||||
@ -177,7 +177,7 @@ impl PpSourceMode {
|
||||
PpmNormal | PpmEveryBodyLoops | PpmExpanded => {
|
||||
let annotation = NoAnn {
|
||||
sess: sess,
|
||||
ast_map: ast_map.map(|m| m.clone()),
|
||||
hir_map: hir_map.map(|m| m.clone()),
|
||||
};
|
||||
f(&annotation, payload)
|
||||
}
|
||||
@ -185,14 +185,13 @@ impl PpSourceMode {
|
||||
PpmIdentified | PpmExpandedIdentified => {
|
||||
let annotation = IdentifiedAnnotation {
|
||||
sess: sess,
|
||||
ast_map: ast_map.map(|m| m.clone()),
|
||||
hir_map: hir_map.map(|m| m.clone()),
|
||||
};
|
||||
f(&annotation, payload)
|
||||
}
|
||||
PpmExpandedHygiene => {
|
||||
let annotation = HygieneAnnotation {
|
||||
sess: sess,
|
||||
ast_map: ast_map.map(|m| m.clone()),
|
||||
};
|
||||
f(&annotation, payload)
|
||||
}
|
||||
@ -201,7 +200,7 @@ impl PpSourceMode {
|
||||
}
|
||||
fn call_with_pp_support_hir<'tcx, A, B, F>(&self,
|
||||
sess: &'tcx Session,
|
||||
ast_map: &hir_map::Map<'tcx>,
|
||||
hir_map: &hir_map::Map<'tcx>,
|
||||
analysis: &ty::CrateAnalysis<'tcx>,
|
||||
resolutions: &Resolutions,
|
||||
arena: &'tcx DroplessArena,
|
||||
@ -216,21 +215,21 @@ impl PpSourceMode {
|
||||
PpmNormal => {
|
||||
let annotation = NoAnn {
|
||||
sess: sess,
|
||||
ast_map: Some(ast_map.clone()),
|
||||
hir_map: Some(hir_map.clone()),
|
||||
};
|
||||
f(&annotation, payload, ast_map.forest.krate())
|
||||
f(&annotation, payload, hir_map.forest.krate())
|
||||
}
|
||||
|
||||
PpmIdentified => {
|
||||
let annotation = IdentifiedAnnotation {
|
||||
sess: sess,
|
||||
ast_map: Some(ast_map.clone()),
|
||||
hir_map: Some(hir_map.clone()),
|
||||
};
|
||||
f(&annotation, payload, ast_map.forest.krate())
|
||||
f(&annotation, payload, hir_map.forest.krate())
|
||||
}
|
||||
PpmTyped => {
|
||||
abort_on_err(driver::phase_3_run_analysis_passes(sess,
|
||||
ast_map.clone(),
|
||||
hir_map.clone(),
|
||||
analysis.clone(),
|
||||
resolutions.clone(),
|
||||
arena,
|
||||
@ -243,7 +242,7 @@ impl PpSourceMode {
|
||||
tables: Cell::new(&empty_tables)
|
||||
};
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
f(&annotation, payload, ast_map.forest.krate())
|
||||
f(&annotation, payload, hir_map.forest.krate())
|
||||
}),
|
||||
sess)
|
||||
}
|
||||
@ -252,15 +251,11 @@ impl PpSourceMode {
|
||||
}
|
||||
}
|
||||
|
||||
trait PrinterSupport<'ast>: pprust::PpAnn {
|
||||
trait PrinterSupport: pprust::PpAnn {
|
||||
/// Provides a uniform interface for re-extracting a reference to a
|
||||
/// `Session` from a value that now owns it.
|
||||
fn sess<'a>(&'a self) -> &'a Session;
|
||||
|
||||
/// Provides a uniform interface for re-extracting a reference to an
|
||||
/// `hir_map::Map` from a value that now owns it.
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>>;
|
||||
|
||||
/// Produces the pretty-print annotation object.
|
||||
///
|
||||
/// (Rust does not yet support upcasting from a trait object to
|
||||
@ -268,14 +263,14 @@ trait PrinterSupport<'ast>: pprust::PpAnn {
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn;
|
||||
}
|
||||
|
||||
trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
|
||||
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
|
||||
/// Provides a uniform interface for re-extracting a reference to a
|
||||
/// `Session` from a value that now owns it.
|
||||
fn sess<'a>(&'a self) -> &'a Session;
|
||||
|
||||
/// Provides a uniform interface for re-extracting a reference to an
|
||||
/// `hir_map::Map` from a value that now owns it.
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>>;
|
||||
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>;
|
||||
|
||||
/// Produces the pretty-print annotation object.
|
||||
///
|
||||
@ -285,7 +280,7 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
|
||||
|
||||
/// Computes an user-readable representation of a path, if possible.
|
||||
fn node_path(&self, id: ast::NodeId) -> Option<String> {
|
||||
self.ast_map().and_then(|map| map.def_path_from_id(id)).map(|path| {
|
||||
self.hir_map().and_then(|map| map.def_path_from_id(id)).map(|path| {
|
||||
path.data
|
||||
.into_iter()
|
||||
.map(|elem| elem.data.to_string())
|
||||
@ -295,32 +290,28 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
|
||||
}
|
||||
}
|
||||
|
||||
struct NoAnn<'ast> {
|
||||
sess: &'ast Session,
|
||||
ast_map: Option<hir_map::Map<'ast>>,
|
||||
struct NoAnn<'hir> {
|
||||
sess: &'hir Session,
|
||||
hir_map: Option<hir_map::Map<'hir>>,
|
||||
}
|
||||
|
||||
impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> {
|
||||
impl<'hir> PrinterSupport for NoAnn<'hir> {
|
||||
fn sess<'a>(&'a self) -> &'a Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
|
||||
self.ast_map.as_ref()
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> HirPrinterSupport<'ast> for NoAnn<'ast> {
|
||||
impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
|
||||
fn sess<'a>(&'a self) -> &'a Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
|
||||
self.ast_map.as_ref()
|
||||
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
|
||||
self.hir_map.as_ref()
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn {
|
||||
@ -328,11 +319,11 @@ impl<'ast> HirPrinterSupport<'ast> for NoAnn<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> pprust::PpAnn for NoAnn<'ast> {}
|
||||
impl<'ast> pprust_hir::PpAnn for NoAnn<'ast> {
|
||||
impl<'hir> pprust::PpAnn for NoAnn<'hir> {}
|
||||
impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> {
|
||||
fn nested(&self, state: &mut pprust_hir::State, nested: pprust_hir::Nested)
|
||||
-> io::Result<()> {
|
||||
if let Some(ref map) = self.ast_map {
|
||||
if let Some(ref map) = self.hir_map {
|
||||
pprust_hir::PpAnn::nested(map, state, nested)
|
||||
} else {
|
||||
Ok(())
|
||||
@ -340,26 +331,22 @@ impl<'ast> pprust_hir::PpAnn for NoAnn<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
struct IdentifiedAnnotation<'ast> {
|
||||
sess: &'ast Session,
|
||||
ast_map: Option<hir_map::Map<'ast>>,
|
||||
struct IdentifiedAnnotation<'hir> {
|
||||
sess: &'hir Session,
|
||||
hir_map: Option<hir_map::Map<'hir>>,
|
||||
}
|
||||
|
||||
impl<'ast> PrinterSupport<'ast> for IdentifiedAnnotation<'ast> {
|
||||
impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
|
||||
fn sess<'a>(&'a self) -> &'a Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
|
||||
self.ast_map.as_ref()
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> {
|
||||
impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> {
|
||||
fn pre(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
|
||||
match node {
|
||||
pprust::NodeExpr(_) => s.popen(),
|
||||
@ -396,13 +383,13 @@ impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> HirPrinterSupport<'ast> for IdentifiedAnnotation<'ast> {
|
||||
impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
|
||||
fn sess<'a>(&'a self) -> &'a Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
|
||||
self.ast_map.as_ref()
|
||||
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
|
||||
self.hir_map.as_ref()
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn {
|
||||
@ -410,10 +397,10 @@ impl<'ast> HirPrinterSupport<'ast> for IdentifiedAnnotation<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> pprust_hir::PpAnn for IdentifiedAnnotation<'ast> {
|
||||
impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
|
||||
fn nested(&self, state: &mut pprust_hir::State, nested: pprust_hir::Nested)
|
||||
-> io::Result<()> {
|
||||
if let Some(ref map) = self.ast_map {
|
||||
if let Some(ref map) = self.hir_map {
|
||||
pprust_hir::PpAnn::nested(map, state, nested)
|
||||
} else {
|
||||
Ok(())
|
||||
@ -453,26 +440,21 @@ impl<'ast> pprust_hir::PpAnn for IdentifiedAnnotation<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
struct HygieneAnnotation<'ast> {
|
||||
sess: &'ast Session,
|
||||
ast_map: Option<hir_map::Map<'ast>>,
|
||||
struct HygieneAnnotation<'a> {
|
||||
sess: &'a Session
|
||||
}
|
||||
|
||||
impl<'ast> PrinterSupport<'ast> for HygieneAnnotation<'ast> {
|
||||
fn sess<'a>(&'a self) -> &'a Session {
|
||||
impl<'a> PrinterSupport for HygieneAnnotation<'a> {
|
||||
fn sess(&self) -> &Session {
|
||||
self.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> {
|
||||
self.ast_map.as_ref()
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn {
|
||||
fn pp_ann(&self) -> &pprust::PpAnn {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> {
|
||||
impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
|
||||
fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
|
||||
match node {
|
||||
pprust::NodeIdent(&ast::Ident { name, ctxt }) => {
|
||||
@ -501,8 +483,8 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
|
||||
&self.tcx.sess
|
||||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
|
||||
Some(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn {
|
||||
@ -521,7 +503,7 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
|
||||
if let pprust_hir::Nested::Body(id) = nested {
|
||||
self.tables.set(self.tcx.body_tables(id));
|
||||
}
|
||||
pprust_hir::PpAnn::nested(&self.tcx.map, state, nested)?;
|
||||
pprust_hir::PpAnn::nested(&self.tcx.hir, state, nested)?;
|
||||
self.tables.set(old_tables);
|
||||
Ok(())
|
||||
}
|
||||
@ -579,12 +561,12 @@ impl FromStr for UserIdentifiedItem {
|
||||
}
|
||||
}
|
||||
|
||||
enum NodesMatchingUII<'a, 'ast: 'a> {
|
||||
enum NodesMatchingUII<'a, 'hir: 'a> {
|
||||
NodesMatchingDirect(option::IntoIter<ast::NodeId>),
|
||||
NodesMatchingSuffix(hir_map::NodesMatchingSuffix<'a, 'ast>),
|
||||
NodesMatchingSuffix(hir_map::NodesMatchingSuffix<'a, 'hir>),
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Iterator for NodesMatchingUII<'a, 'ast> {
|
||||
impl<'a, 'hir> Iterator for NodesMatchingUII<'a, 'hir> {
|
||||
type Item = ast::NodeId;
|
||||
|
||||
fn next(&mut self) -> Option<ast::NodeId> {
|
||||
@ -603,9 +585,9 @@ impl UserIdentifiedItem {
|
||||
}
|
||||
}
|
||||
|
||||
fn all_matching_node_ids<'a, 'ast>(&'a self,
|
||||
map: &'a hir_map::Map<'ast>)
|
||||
-> NodesMatchingUII<'a, 'ast> {
|
||||
fn all_matching_node_ids<'a, 'hir>(&'a self,
|
||||
map: &'a hir_map::Map<'hir>)
|
||||
-> NodesMatchingUII<'a, 'hir> {
|
||||
match *self {
|
||||
ItemViaNode(node_id) => NodesMatchingDirect(Some(node_id).into_iter()),
|
||||
ItemViaPath(ref parts) => NodesMatchingSuffix(map.nodes_matching_suffix(&parts[..])),
|
||||
@ -739,13 +721,13 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||
let cfg = match code {
|
||||
blocks::Code::Expr(expr) => cfg::CFG::new(tcx, expr),
|
||||
blocks::Code::FnLike(fn_like) => {
|
||||
let body = tcx.map.body(fn_like.body());
|
||||
let body = tcx.hir.body(fn_like.body());
|
||||
cfg::CFG::new(tcx, &body.value)
|
||||
},
|
||||
};
|
||||
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
|
||||
let lcfg = LabelledCFG {
|
||||
ast_map: &tcx.map,
|
||||
hir_map: &tcx.hir,
|
||||
cfg: &cfg,
|
||||
name: format!("node_{}", code.id()),
|
||||
labelled_edges: labelled_edges,
|
||||
@ -855,7 +837,7 @@ pub fn print_after_parsing(sess: &Session,
|
||||
}
|
||||
|
||||
pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
ast_map: &hir_map::Map<'tcx>,
|
||||
hir_map: &hir_map::Map<'tcx>,
|
||||
analysis: &ty::CrateAnalysis<'tcx>,
|
||||
resolutions: &Resolutions,
|
||||
input: &Input,
|
||||
@ -871,7 +853,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
|
||||
if ppm.needs_analysis() {
|
||||
print_with_analysis(sess,
|
||||
ast_map,
|
||||
hir_map,
|
||||
analysis,
|
||||
resolutions,
|
||||
crate_name,
|
||||
@ -892,7 +874,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
(PpmSource(s), _) => {
|
||||
// Silently ignores an identified node.
|
||||
let out: &mut Write = &mut out;
|
||||
s.call_with_pp_support(sess, Some(ast_map), box out, |annotation, out| {
|
||||
s.call_with_pp_support(sess, Some(hir_map), box out, |annotation, out| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
@ -909,7 +891,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
(PpmHir(s), None) => {
|
||||
let out: &mut Write = &mut out;
|
||||
s.call_with_pp_support_hir(sess,
|
||||
ast_map,
|
||||
hir_map,
|
||||
analysis,
|
||||
resolutions,
|
||||
arena,
|
||||
@ -933,7 +915,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
(PpmHir(s), Some(uii)) => {
|
||||
let out: &mut Write = &mut out;
|
||||
s.call_with_pp_support_hir(sess,
|
||||
ast_map,
|
||||
hir_map,
|
||||
analysis,
|
||||
resolutions,
|
||||
arena,
|
||||
@ -943,7 +925,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
|annotation, (out, uii), _| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let ast_map = annotation.ast_map().expect("--unpretty missing HIR map");
|
||||
let hir_map = annotation.hir_map().expect("--unpretty missing HIR map");
|
||||
let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(),
|
||||
&sess.parse_sess,
|
||||
src_name.to_string(),
|
||||
@ -951,8 +933,8 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
box out,
|
||||
annotation.pp_ann(),
|
||||
true);
|
||||
for node_id in uii.all_matching_node_ids(ast_map) {
|
||||
let node = ast_map.get(node_id);
|
||||
for node_id in uii.all_matching_node_ids(hir_map) {
|
||||
let node = hir_map.get(node_id);
|
||||
pp_state.print_node(node)?;
|
||||
pp::space(&mut pp_state.s)?;
|
||||
let path = annotation.node_path(node_id)
|
||||
@ -975,7 +957,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
// with a different callback than the standard driver, so that isn't easy.
|
||||
// Instead, we call that function ourselves.
|
||||
fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
ast_map: &hir_map::Map<'tcx>,
|
||||
hir_map: &hir_map::Map<'tcx>,
|
||||
analysis: &ty::CrateAnalysis<'tcx>,
|
||||
resolutions: &Resolutions,
|
||||
crate_name: &str,
|
||||
@ -986,7 +968,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
ofile: Option<&Path>) {
|
||||
let nodeid = if let Some(uii) = uii {
|
||||
debug!("pretty printing for {:?}", uii);
|
||||
Some(uii.to_one_node_id("--unpretty", sess, &ast_map))
|
||||
Some(uii.to_one_node_id("--unpretty", sess, &hir_map))
|
||||
} else {
|
||||
debug!("pretty printing for whole crate");
|
||||
None
|
||||
@ -995,7 +977,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
let mut out = Vec::new();
|
||||
|
||||
abort_on_err(driver::phase_3_run_analysis_passes(sess,
|
||||
ast_map.clone(),
|
||||
hir_map.clone(),
|
||||
analysis.clone(),
|
||||
resolutions.clone(),
|
||||
arena,
|
||||
@ -1005,7 +987,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
match ppm {
|
||||
PpmMir | PpmMirCFG => {
|
||||
if let Some(nodeid) = nodeid {
|
||||
let def_id = tcx.map.local_def_id(nodeid);
|
||||
let def_id = tcx.hir.local_def_id(nodeid);
|
||||
match ppm {
|
||||
PpmMir => write_mir_pretty(tcx, iter::once(def_id), &mut out),
|
||||
PpmMirCFG => write_mir_graphviz(tcx, iter::once(def_id), &mut out),
|
||||
@ -1030,11 +1012,11 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
let nodeid =
|
||||
nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
|
||||
suffix (b::c::d)");
|
||||
let node = tcx.map.find(nodeid).unwrap_or_else(|| {
|
||||
let node = tcx.hir.find(nodeid).unwrap_or_else(|| {
|
||||
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
|
||||
});
|
||||
|
||||
match blocks::Code::from_node(&tcx.map, nodeid) {
|
||||
match blocks::Code::from_node(&tcx.hir, nodeid) {
|
||||
Some(code) => {
|
||||
let variants = gather_flowgraph_variants(tcx.sess);
|
||||
|
||||
@ -1047,7 +1029,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
|
||||
got {:?}",
|
||||
node);
|
||||
|
||||
tcx.sess.span_fatal(tcx.map.span(nodeid), &message)
|
||||
tcx.sess.span_fatal(tcx.hir.span(nodeid), &message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,19 +131,19 @@ fn test_env<F>(source_string: &str,
|
||||
|
||||
let arena = DroplessArena::new();
|
||||
let arenas = ty::GlobalArenas::new();
|
||||
let ast_map = hir_map::map_crate(&mut hir_forest, defs);
|
||||
let hir_map = hir_map::map_crate(&mut hir_forest, defs);
|
||||
|
||||
// run just enough stuff to build a tcx:
|
||||
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
|
||||
let named_region_map = resolve_lifetime::krate(&sess, &ast_map);
|
||||
let region_map = region::resolve_crate(&sess, &ast_map);
|
||||
let index = stability::Index::new(&ast_map);
|
||||
let lang_items = lang_items::collect_language_items(&sess, &hir_map);
|
||||
let named_region_map = resolve_lifetime::krate(&sess, &hir_map);
|
||||
let region_map = region::resolve_crate(&sess, &hir_map);
|
||||
let index = stability::Index::new(&hir_map);
|
||||
TyCtxt::create_and_enter(&sess,
|
||||
&arenas,
|
||||
&arena,
|
||||
resolutions,
|
||||
named_region_map.unwrap(),
|
||||
ast_map,
|
||||
hir_map,
|
||||
region_map,
|
||||
lang_items,
|
||||
index,
|
||||
@ -197,7 +197,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
|
||||
|
||||
#[allow(dead_code)] // this seems like it could be useful, even if we don't use it now
|
||||
pub fn lookup_item(&self, names: &[String]) -> ast::NodeId {
|
||||
return match search_mod(self, &self.infcx.tcx.map.krate().module, 0, names) {
|
||||
return match search_mod(self, &self.infcx.tcx.hir.krate().module, 0, names) {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
panic!("no item found: `{}`", names.join("::"));
|
||||
@ -211,7 +211,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
|
||||
-> Option<ast::NodeId> {
|
||||
assert!(idx < names.len());
|
||||
for item in &m.item_ids {
|
||||
let item = this.infcx.tcx.map.expect_item(item.id);
|
||||
let item = this.infcx.tcx.hir.expect_item(item.id);
|
||||
if item.name.to_string() == names[idx] {
|
||||
return search(this, item, idx + 1, names);
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let mut visitor = IfThisChanged { tcx: tcx,
|
||||
if_this_changed: vec![],
|
||||
then_this_would_need: vec![] };
|
||||
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.map.krate().attrs);
|
||||
tcx.map.krate().visit_all_item_likes(&mut visitor);
|
||||
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir.krate().attrs);
|
||||
tcx.hir.krate().visit_all_item_likes(&mut visitor);
|
||||
(visitor.if_this_changed, visitor.then_this_would_need)
|
||||
};
|
||||
|
||||
@ -120,7 +120,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
|
||||
let def_id = self.tcx.map.local_def_id(node_id);
|
||||
let def_id = self.tcx.hir.local_def_id(node_id);
|
||||
for attr in attrs {
|
||||
if attr.check_name(ATTR_IF_THIS_CHANGED) {
|
||||
let dep_node_interned = self.argument(attr);
|
||||
|
@ -102,7 +102,7 @@ impl<'a> ::std::ops::Index<&'a DepNode<DefId>> for IncrementalHashesMap {
|
||||
pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
-> IncrementalHashesMap {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
let hash_spans = tcx.sess.opts.debuginfo != NoDebugInfo;
|
||||
let mut visitor = HashItemsVisitor {
|
||||
tcx: tcx,
|
||||
@ -141,7 +141,7 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
|
||||
fn calculate_node_id<W>(&mut self, id: ast::NodeId, walk_op: W)
|
||||
where W: for<'v> FnMut(&mut StrictVersionHashVisitor<'v, 'a, 'tcx>)
|
||||
{
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
let def_id = self.tcx.hir.local_def_id(id);
|
||||
self.calculate_def_id(def_id, walk_op)
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn compute_crate_hash(&mut self) {
|
||||
let krate = self.tcx.map.krate();
|
||||
let krate = self.tcx.hir.krate();
|
||||
|
||||
let mut crate_state = IchHasher::new();
|
||||
|
||||
|
@ -561,7 +561,7 @@ macro_rules! hash_span {
|
||||
impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'hash, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> visit::NestedVisitorMap<'this, 'tcx> {
|
||||
if self.hash_bodies {
|
||||
visit::NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
visit::NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
} else {
|
||||
visit::NestedVisitorMap::None
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
.collect();
|
||||
let query = tcx.dep_graph.query();
|
||||
debug!("query-nodes: {:?}", query.nodes());
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
krate.visit_all_item_likes(&mut DirtyCleanVisitor {
|
||||
tcx: tcx,
|
||||
query: &query,
|
||||
@ -171,7 +171,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let def_id = self.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
for attr in self.tcx.get_attrs(def_id).iter() {
|
||||
if attr.check_name(ATTR_DIRTY) {
|
||||
if check_config(self.tcx, attr) {
|
||||
@ -200,7 +200,7 @@ pub fn check_dirty_clean_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
tcx.dep_graph.with_ignore(||{
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
krate.visit_all_item_likes(&mut DirtyCleanMetadataVisitor {
|
||||
tcx: tcx,
|
||||
prev_metadata_hashes: prev_metadata_hashes,
|
||||
@ -217,7 +217,7 @@ pub struct DirtyCleanMetadataVisitor<'a, 'tcx:'a, 'm> {
|
||||
|
||||
impl<'a, 'tcx, 'm> ItemLikeVisitor<'tcx> for DirtyCleanMetadataVisitor<'a, 'tcx, 'm> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let def_id = self.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
|
||||
for attr in self.tcx.get_attrs(def_id).iter() {
|
||||
if attr.check_name(ATTR_DIRTY_METADATA) {
|
||||
|
@ -28,7 +28,7 @@ pub enum MethodLateContext {
|
||||
}
|
||||
|
||||
pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext {
|
||||
let def_id = cx.tcx.map.local_def_id(id);
|
||||
let def_id = cx.tcx.hir.local_def_id(id);
|
||||
match cx.tcx.associated_items.borrow().get(&def_id) {
|
||||
None => span_bug!(span, "missing method descriptor?!"),
|
||||
Some(item) => {
|
||||
|
@ -117,7 +117,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||
hir::ItemEnum(..) |
|
||||
hir::ItemStruct(..) |
|
||||
hir::ItemUnion(..) => {
|
||||
let def_id = cx.tcx.map.local_def_id(it.id);
|
||||
let def_id = cx.tcx.hir.local_def_id(it.id);
|
||||
self.check_heap_type(cx, it.span, cx.tcx.item_type(def_id))
|
||||
}
|
||||
_ => ()
|
||||
@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||
hir::ItemStruct(ref struct_def, _) |
|
||||
hir::ItemUnion(ref struct_def, _) => {
|
||||
for struct_field in struct_def.fields() {
|
||||
let def_id = cx.tcx.map.local_def_id(struct_field.id);
|
||||
let def_id = cx.tcx.hir.local_def_id(struct_field.id);
|
||||
self.check_heap_type(cx, struct_field.span,
|
||||
cx.tcx.item_type(def_id));
|
||||
}
|
||||
@ -390,8 +390,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
// If the trait is private, add the impl items to private_traits so they don't get
|
||||
// reported for missing docs.
|
||||
let real_trait = trait_ref.path.def.def_id();
|
||||
if let Some(node_id) = cx.tcx.map.as_local_node_id(real_trait) {
|
||||
match cx.tcx.map.find(node_id) {
|
||||
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
|
||||
match cx.tcx.hir.find(node_id) {
|
||||
Some(hir_map::NodeItem(item)) => {
|
||||
if item.vis == hir::Visibility::Inherited {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
@ -504,21 +504,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
||||
if ast_generics.is_parameterized() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemUnion(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemEnum(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id));
|
||||
let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
_ => return,
|
||||
@ -586,7 +586,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
||||
let mut impls = NodeSet();
|
||||
debug_def.for_each_impl(cx.tcx, |d| {
|
||||
if let Some(ty_def) = cx.tcx.item_type(d).ty_to_def_id() {
|
||||
if let Some(node_id) = cx.tcx.map.as_local_node_id(ty_def) {
|
||||
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) {
|
||||
impls.insert(node_id);
|
||||
}
|
||||
}
|
||||
@ -680,7 +680,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
let method = match fn_kind {
|
||||
FnKind::ItemFn(..) => None,
|
||||
FnKind::Method(..) => {
|
||||
Some(cx.tcx.associated_item(cx.tcx.map.local_def_id(id)))
|
||||
Some(cx.tcx.associated_item(cx.tcx.hir.local_def_id(id)))
|
||||
}
|
||||
// closures can't recur, so they don't matter.
|
||||
FnKind::Closure(_) => return,
|
||||
@ -745,7 +745,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
false
|
||||
};
|
||||
if self_recursive {
|
||||
self_call_spans.push(cx.tcx.map.span(node_id));
|
||||
self_call_spans.push(cx.tcx.hir.span(node_id));
|
||||
// this is a self call, so we shouldn't explore past
|
||||
// this node in the CFG.
|
||||
continue;
|
||||
@ -788,14 +788,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
// represents a call to the function `fn_id`/method `method`.
|
||||
|
||||
fn expr_refers_to_this_fn(cx: &LateContext, fn_id: ast::NodeId, id: ast::NodeId) -> bool {
|
||||
match cx.tcx.map.get(id) {
|
||||
match cx.tcx.hir.get(id) {
|
||||
hir_map::NodeExpr(&hir::Expr { node: hir::ExprCall(ref callee, _), .. }) => {
|
||||
let def = if let hir::ExprPath(ref qpath) = callee.node {
|
||||
cx.tables.qpath_def(qpath, callee.id)
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
def.def_id() == cx.tcx.map.local_def_id(fn_id)
|
||||
def.def_id() == cx.tcx.hir.local_def_id(fn_id)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
@ -830,7 +830,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
}
|
||||
|
||||
// Check for calls to methods via explicit paths (e.g. `T::method()`).
|
||||
match cx.tcx.map.get(id) {
|
||||
match cx.tcx.hir.get(id) {
|
||||
hir_map::NodeExpr(&hir::Expr { node: hir::ExprCall(ref callee, _), .. }) => {
|
||||
let def = if let hir::ExprPath(ref qpath) = callee.node {
|
||||
cx.tables.qpath_def(qpath, callee.id)
|
||||
@ -871,7 +871,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
ty::TraitContainer(trait_def_id) => {
|
||||
let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, callee_substs);
|
||||
let trait_ref = ty::Binder(trait_ref);
|
||||
let span = tcx.map.span(expr_id);
|
||||
let span = tcx.hir.span(expr_id);
|
||||
let obligation =
|
||||
traits::Obligation::new(traits::ObligationCause::misc(span, expr_id),
|
||||
trait_ref.to_poly_trait_predicate());
|
||||
@ -879,7 +879,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
|
||||
// unwrap() is ok here b/c `method` is the method
|
||||
// defined in this crate whose body we are
|
||||
// checking, so it's always local
|
||||
let node_id = tcx.map.as_local_node_id(method.def_id).unwrap();
|
||||
let node_id = tcx.hir.as_local_node_id(method.def_id).unwrap();
|
||||
|
||||
let param_env = ty::ParameterEnvironment::for_item(tcx, node_id);
|
||||
tcx.infer_ctxt(param_env, Reveal::NotSpecializable).enter(|infcx| {
|
||||
@ -1151,7 +1151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
||||
if let hir::ItemUnion(ref vdata, _) = item.node {
|
||||
let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id);
|
||||
for field in vdata.fields() {
|
||||
let field_ty = ctx.tcx.item_type(ctx.tcx.map.local_def_id(field.id));
|
||||
let field_ty = ctx.tcx.item_type(ctx.tcx.hir.local_def_id(field.id));
|
||||
if ctx.tcx.type_needs_drop_given_env(field_ty, param_env) {
|
||||
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
||||
field.span,
|
||||
|
@ -631,7 +631,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
|
||||
let def_id = self.cx.tcx.map.local_def_id(id);
|
||||
let def_id = self.cx.tcx.hir.local_def_id(id);
|
||||
let sig = self.cx.tcx.item_type(def_id).fn_sig();
|
||||
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
|
||||
|
||||
@ -648,7 +648,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
|
||||
let def_id = self.cx.tcx.map.local_def_id(id);
|
||||
let def_id = self.cx.tcx.hir.local_def_id(id);
|
||||
let ty = self.cx.tcx.item_type(def_id);
|
||||
self.check_type_for_ffi_and_report_errors(span, ty);
|
||||
}
|
||||
@ -696,7 +696,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
||||
if let hir::ItemEnum(ref enum_definition, ref gens) = it.node {
|
||||
if gens.ty_params.is_empty() {
|
||||
// sizes only make sense for non-generic types
|
||||
let t = cx.tcx.item_type(cx.tcx.map.local_def_id(it.id));
|
||||
let t = cx.tcx.item_type(cx.tcx.hir.local_def_id(it.id));
|
||||
let layout = cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
|
||||
let ty = cx.tcx.erase_regions(&t);
|
||||
ty.layout(&infcx).unwrap_or_else(|e| {
|
||||
|
@ -64,7 +64,7 @@ impl UnusedMut {
|
||||
for (_, v) in &mutables {
|
||||
if !v.iter().any(|e| used_mutables.contains(e)) {
|
||||
cx.span_lint(UNUSED_MUT,
|
||||
cx.tcx.map.span(v[0]),
|
||||
cx.tcx.hir.span(v[0]),
|
||||
"variable does not need to be mutable");
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub struct Ast<'tcx> {
|
||||
|
||||
impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
pub fn encode_body(&mut self, body_id: hir::BodyId) -> Lazy<Ast<'tcx>> {
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
let lazy_body = self.lazy(body);
|
||||
|
||||
let tables = self.tcx.body_tables(body_id);
|
||||
@ -67,7 +67,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for NestedBodyEncodingVisitor<'a, 'b, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let body = self.ecx.tcx.map.body(body);
|
||||
let body = self.ecx.tcx.hir.body(body);
|
||||
body.encode(self.ecx).unwrap();
|
||||
self.count += 1;
|
||||
|
||||
|
@ -428,7 +428,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
||||
def_id: DefId)
|
||||
-> Option<&'tcx hir::Body>
|
||||
{
|
||||
if let Some(cached) = tcx.map.get_inlined_body(def_id) {
|
||||
if let Some(cached) = tcx.hir.get_inlined_body(def_id) {
|
||||
return Some(cached);
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
tcx.tables.borrow_mut().insert(def_id, tcx.alloc_tables(tables));
|
||||
|
||||
let body = ast.body.decode((self, tcx));
|
||||
tcx.map.intern_inlined_body(def_id, body)
|
||||
tcx.hir.intern_inlined_body(def_id, body)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -267,8 +267,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
struct_ctor: None,
|
||||
};
|
||||
|
||||
let enum_id = tcx.map.as_local_node_id(enum_did).unwrap();
|
||||
let enum_vis = &tcx.map.expect_item(enum_id).vis;
|
||||
let enum_id = tcx.hir.as_local_node_id(enum_did).unwrap();
|
||||
let enum_vis = &tcx.hir.expect_item(enum_id).vis;
|
||||
|
||||
Entry {
|
||||
kind: EntryKind::Variant(self.lazy(&data)),
|
||||
@ -299,7 +299,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
&hir::Visibility)>)
|
||||
-> Entry<'tcx> {
|
||||
let tcx = self.tcx;
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
|
||||
let data = ModData {
|
||||
reexports: match self.reexports.get(&id) {
|
||||
@ -314,7 +314,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
span: self.lazy(&md.inner),
|
||||
attributes: self.encode_attributes(attrs),
|
||||
children: self.lazy_seq(md.item_ids.iter().map(|item_id| {
|
||||
tcx.map.local_def_id(item_id.id).index
|
||||
tcx.hir.local_def_id(item_id.id).index
|
||||
})),
|
||||
stability: self.encode_stability(def_id),
|
||||
deprecation: self.encode_deprecation(def_id),
|
||||
@ -361,8 +361,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
let field = &variant.fields[field_index];
|
||||
|
||||
let def_id = field.did;
|
||||
let variant_id = tcx.map.as_local_node_id(variant.did).unwrap();
|
||||
let variant_data = tcx.map.expect_variant_data(variant_id);
|
||||
let variant_id = tcx.hir.as_local_node_id(variant.did).unwrap();
|
||||
let variant_data = tcx.hir.expect_variant_data(variant_id);
|
||||
|
||||
Entry {
|
||||
kind: EntryKind::Field,
|
||||
@ -394,8 +394,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
struct_ctor: Some(def_id.index),
|
||||
};
|
||||
|
||||
let struct_id = tcx.map.as_local_node_id(adt_def_id).unwrap();
|
||||
let struct_vis = &tcx.map.expect_item(struct_id).vis;
|
||||
let struct_id = tcx.hir.as_local_node_id(adt_def_id).unwrap();
|
||||
let struct_vis = &tcx.hir.expect_item(struct_id).vis;
|
||||
|
||||
Entry {
|
||||
kind: EntryKind::Struct(self.lazy(&data)),
|
||||
@ -430,8 +430,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
|
||||
let tcx = self.tcx;
|
||||
|
||||
let node_id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let ast_item = tcx.map.expect_trait_item(node_id);
|
||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let ast_item = tcx.hir.expect_trait_item(node_id);
|
||||
let trait_item = tcx.associated_item(def_id);
|
||||
|
||||
let container = match trait_item.defaultness {
|
||||
@ -508,8 +508,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'tcx> {
|
||||
let node_id = self.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let ast_item = self.tcx.map.expect_impl_item(node_id);
|
||||
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let ast_item = self.tcx.hir.expect_impl_item(node_id);
|
||||
let impl_item = self.tcx.associated_item(def_id);
|
||||
|
||||
let container = match impl_item.defaultness {
|
||||
@ -576,7 +576,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId)
|
||||
-> LazySeq<ast::Name> {
|
||||
let _ignore = self.tcx.dep_graph.in_ignore();
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
self.lazy_seq(body.arguments.iter().map(|arg| {
|
||||
match arg.pat.node {
|
||||
PatKind::Binding(_, _, name, _) => name.node,
|
||||
@ -646,7 +646,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
// for methods, write all the stuff get_trait_method
|
||||
// needs to know
|
||||
let struct_ctor = if !struct_def.is_struct() {
|
||||
Some(tcx.map.local_def_id(struct_def.id()).index)
|
||||
Some(tcx.hir.local_def_id(struct_def.id()).index)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -725,7 +725,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
hir::ItemForeignMod(ref fm) => {
|
||||
self.lazy_seq(fm.items
|
||||
.iter()
|
||||
.map(|foreign_item| tcx.map.local_def_id(foreign_item.id).index))
|
||||
.map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index))
|
||||
}
|
||||
hir::ItemEnum(..) => {
|
||||
let def = self.tcx.lookup_adt_def(def_id);
|
||||
@ -855,7 +855,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
/// so it's easier to do that here then to wait until we would encounter
|
||||
/// normally in the visitor walk.
|
||||
fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
match item.node {
|
||||
hir::ItemStatic(..) |
|
||||
hir::ItemConst(..) |
|
||||
@ -883,7 +883,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
// If the struct has a constructor, encode it.
|
||||
if !struct_def.is_struct() {
|
||||
let ctor_def_id = self.tcx.map.local_def_id(struct_def.id());
|
||||
let ctor_def_id = self.tcx.hir.local_def_id(struct_def.id());
|
||||
self.record(ctor_def_id,
|
||||
EncodeContext::encode_struct_ctor,
|
||||
(def_id, ctor_def_id));
|
||||
@ -957,7 +957,7 @@ struct EncodeVisitor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
|
||||
impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.index.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.index.tcx.hir)
|
||||
}
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
intravisit::walk_expr(self, ex);
|
||||
@ -965,7 +965,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
}
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
intravisit::walk_item(self, item);
|
||||
let def_id = self.index.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.index.tcx.hir.local_def_id(item.id);
|
||||
match item.node {
|
||||
hir::ItemExternCrate(_) |
|
||||
hir::ItemUse(..) => (), // ignore these
|
||||
@ -975,7 +975,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
}
|
||||
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
|
||||
intravisit::walk_foreign_item(self, ni);
|
||||
let def_id = self.index.tcx.map.local_def_id(ni.id);
|
||||
let def_id = self.index.tcx.hir.local_def_id(ni.id);
|
||||
self.index.record(def_id,
|
||||
EncodeContext::encode_info_for_foreign_item,
|
||||
(def_id, ni));
|
||||
@ -985,7 +985,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
self.index.encode_info_for_ty(ty);
|
||||
}
|
||||
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
|
||||
let def_id = self.index.tcx.map.local_def_id(macro_def.id);
|
||||
let def_id = self.index.tcx.hir.local_def_id(macro_def.id);
|
||||
self.index.record(def_id, EncodeContext::encode_info_for_macro_def, macro_def);
|
||||
}
|
||||
}
|
||||
@ -993,7 +993,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
|
||||
if let hir::TyImplTrait(_) = ty.node {
|
||||
let def_id = self.tcx.map.local_def_id(ty.id);
|
||||
let def_id = self.tcx.hir.local_def_id(ty.id);
|
||||
self.record(def_id, EncodeContext::encode_info_for_anon_ty, def_id);
|
||||
}
|
||||
}
|
||||
@ -1001,7 +1001,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprClosure(..) => {
|
||||
let def_id = self.tcx.map.local_def_id(expr.id);
|
||||
let def_id = self.tcx.hir.local_def_id(expr.id);
|
||||
self.record(def_id, EncodeContext::encode_info_for_closure, def_id);
|
||||
}
|
||||
_ => {}
|
||||
@ -1061,7 +1061,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn encode_info_for_items(&mut self) -> Index {
|
||||
let krate = self.tcx.map.krate();
|
||||
let krate = self.tcx.hir.krate();
|
||||
let mut index = IndexBuilder::new(self);
|
||||
index.record(DefId::local(CRATE_DEF_INDEX),
|
||||
EncodeContext::encode_info_for_mod,
|
||||
@ -1145,7 +1145,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn encode_def_path_table(&mut self) -> Lazy<DefPathTable> {
|
||||
let definitions = self.tcx.map.definitions();
|
||||
let definitions = self.tcx.hir.definitions();
|
||||
self.lazy(definitions.def_path_table())
|
||||
}
|
||||
}
|
||||
@ -1158,7 +1158,7 @@ struct ImplVisitor<'a, 'tcx: 'a> {
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemImpl(..) = item.node {
|
||||
let impl_id = self.tcx.map.local_def_id(item.id);
|
||||
let impl_id = self.tcx.hir.local_def_id(item.id);
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
|
||||
self.impls
|
||||
.entry(trait_ref.def_id)
|
||||
@ -1182,7 +1182,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
tcx: self.tcx,
|
||||
impls: FxHashMap(),
|
||||
};
|
||||
self.tcx.map.krate().visit_all_item_likes(&mut visitor);
|
||||
self.tcx.hir.krate().visit_all_item_likes(&mut visitor);
|
||||
|
||||
let all_impls: Vec<_> = visitor.impls
|
||||
.into_iter()
|
||||
@ -1206,7 +1206,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
fn encode_exported_symbols(&mut self) -> LazySeq<DefIndex> {
|
||||
let exported_symbols = self.exported_symbols;
|
||||
let tcx = self.tcx;
|
||||
self.lazy_seq(exported_symbols.iter().map(|&id| tcx.map.local_def_id(id).index))
|
||||
self.lazy_seq(exported_symbols.iter().map(|&id| tcx.hir.local_def_id(id).index))
|
||||
}
|
||||
|
||||
fn encode_dylib_dependency_formats(&mut self) -> LazySeq<Option<LinkagePreference>> {
|
||||
@ -1283,10 +1283,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
plugin_registrar_fn: tcx.sess
|
||||
.plugin_registrar_fn
|
||||
.get()
|
||||
.map(|id| tcx.map.local_def_id(id).index),
|
||||
.map(|id| tcx.hir.local_def_id(id).index),
|
||||
macro_derive_registrar: if is_proc_macro {
|
||||
let id = tcx.sess.derive_registrar_fn.get().unwrap();
|
||||
Some(tcx.map.local_def_id(id).index)
|
||||
Some(tcx.hir.local_def_id(id).index)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ impl<'a, 'b, 'tcx> DerefMut for IndexBuilder<'a, 'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
pub fn new(ecx: &'a mut EncodeContext<'b, 'tcx>) -> Self {
|
||||
IndexBuilder {
|
||||
items: Index::new(ecx.tcx.map.num_local_def_ids()),
|
||||
items: Index::new(ecx.tcx.hir.num_local_def_ids()),
|
||||
ecx: ecx,
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ macro_rules! read_hir {
|
||||
($t:ty) => {
|
||||
impl<'tcx> DepGraphRead for &'tcx $t {
|
||||
fn read(&self, tcx: TyCtxt) {
|
||||
tcx.map.read(self.id);
|
||||
tcx.hir.read(self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,6 +220,6 @@ pub struct FromId<T>(pub ast::NodeId, pub T);
|
||||
|
||||
impl<T> DepGraphRead for FromId<T> {
|
||||
fn read(&self, tcx: TyCtxt) {
|
||||
tcx.map.read(self.0);
|
||||
tcx.hir.read(self.0);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
let_extent_stack.push(remainder_scope);
|
||||
|
||||
// Declare the bindings, which may create a visibility scope.
|
||||
let remainder_span = remainder_scope.span(&tcx.region_maps, &tcx.map);
|
||||
let remainder_span = remainder_scope.span(&tcx.region_maps, &tcx.hir);
|
||||
let remainder_span = remainder_span.unwrap_or(span);
|
||||
let scope = this.declare_bindings(None, remainder_span, &pattern);
|
||||
|
||||
|
@ -133,7 +133,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
let arguments: Vec<_> = arguments.collect();
|
||||
|
||||
let tcx = hir.tcx();
|
||||
let span = tcx.map.span(fn_id);
|
||||
let span = tcx.hir.span(fn_id);
|
||||
let mut builder = Builder::new(hir, span, arguments.len(), return_ty);
|
||||
|
||||
let call_site_extent =
|
||||
@ -168,7 +168,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
// Gather the upvars of a closure, if any.
|
||||
let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| {
|
||||
freevars.iter().map(|fv| {
|
||||
let var_id = tcx.map.as_local_node_id(fv.def.def_id()).unwrap();
|
||||
let var_id = tcx.hir.as_local_node_id(fv.def.def_id()).unwrap();
|
||||
let by_ref = hir.tables().upvar_capture(ty::UpvarId {
|
||||
var_id: var_id,
|
||||
closure_expr_id: fn_id
|
||||
@ -180,7 +180,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
debug_name: keywords::Invalid.name(),
|
||||
by_ref: by_ref
|
||||
};
|
||||
if let Some(hir::map::NodeLocal(pat)) = tcx.map.find(var_id) {
|
||||
if let Some(hir::map::NodeLocal(pat)) = tcx.hir.find(var_id) {
|
||||
if let hir::PatKind::Binding(_, _, ref ident, _) = pat.node {
|
||||
decl.debug_name = ident.node;
|
||||
}
|
||||
@ -198,9 +198,9 @@ pub fn construct_const<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
body_id: hir::BodyId)
|
||||
-> Mir<'tcx> {
|
||||
let tcx = hir.tcx();
|
||||
let ast_expr = &tcx.map.body(body_id).value;
|
||||
let ast_expr = &tcx.hir.body(body_id).value;
|
||||
let ty = hir.tables().expr_ty_adjusted(ast_expr);
|
||||
let span = tcx.map.span(tcx.map.body_owner(body_id));
|
||||
let span = tcx.hir.span(tcx.hir.body_owner(body_id));
|
||||
let mut builder = Builder::new(hir, span, 0, ty);
|
||||
|
||||
let extent = tcx.region_maps.temporary_scope(ast_expr.id)
|
||||
|
@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
scope.needs_cleanup = true;
|
||||
}
|
||||
let tcx = self.hir.tcx();
|
||||
let extent_span = extent.span(&tcx.region_maps, &tcx.map).unwrap();
|
||||
let extent_span = extent.span(&tcx.region_maps, &tcx.hir).unwrap();
|
||||
// Attribute scope exit drops to scope's closing brace
|
||||
let scope_end = Span { lo: extent_span.hi, .. extent_span};
|
||||
scope.drops.push(DropData {
|
||||
|
@ -26,7 +26,7 @@ pub fn write_mir_graphviz<'a, 'b, 'tcx, W, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
where W: Write, I: Iterator<Item=DefId>
|
||||
{
|
||||
for def_id in iter {
|
||||
let nodeid = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let nodeid = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let mir = &tcx.item_mir(def_id);
|
||||
|
||||
writeln!(w, "digraph Mir_{} {{", nodeid)?;
|
||||
|
@ -574,7 +574,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
// Now comes the rote stuff:
|
||||
hir::ExprRepeat(ref v, count) => {
|
||||
let tcx = cx.tcx.global_tcx();
|
||||
let c = &cx.tcx.map.body(count).value;
|
||||
let c = &cx.tcx.hir.body(count).value;
|
||||
let count = match ConstContext::new(tcx, count).eval(c, EvalHint::ExprTypeChecked) {
|
||||
Ok(ConstVal::Integral(ConstInt::Usize(u))) => u,
|
||||
Ok(other) => bug!("constant evaluation of repeat count yielded {:?}", other),
|
||||
@ -765,19 +765,19 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
|
||||
match def {
|
||||
Def::Local(def_id) => {
|
||||
let node_id = cx.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let node_id = cx.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
ExprKind::VarRef { id: node_id }
|
||||
}
|
||||
|
||||
Def::Upvar(def_id, index, closure_expr_id) => {
|
||||
let id_var = cx.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let id_var = cx.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
debug!("convert_var(upvar({:?}, {:?}, {:?}))",
|
||||
id_var,
|
||||
index,
|
||||
closure_expr_id);
|
||||
let var_ty = cx.tables().node_id_to_type(id_var);
|
||||
|
||||
let body_id = match cx.tcx.map.find(closure_expr_id) {
|
||||
let body_id = match cx.tcx.hir.find(closure_expr_id) {
|
||||
Some(map::NodeExpr(expr)) => {
|
||||
match expr.node {
|
||||
hir::ExprClosure(.., body, _) => body.node_id,
|
||||
@ -803,7 +803,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
});
|
||||
let region = cx.tcx.mk_region(region);
|
||||
|
||||
let self_expr = match cx.tcx.closure_kind(cx.tcx.map.local_def_id(closure_expr_id)) {
|
||||
let self_expr = match cx.tcx.closure_kind(cx.tcx.hir.local_def_id(closure_expr_id)) {
|
||||
ty::ClosureKind::Fn => {
|
||||
let ref_closure_ty = cx.tcx.mk_ref(region,
|
||||
ty::TypeAndMut {
|
||||
@ -1013,7 +1013,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
freevar: &hir::Freevar,
|
||||
freevar_ty: Ty<'tcx>)
|
||||
-> ExprRef<'tcx> {
|
||||
let id_var = cx.tcx.map.as_local_node_id(freevar.def.def_id()).unwrap();
|
||||
let id_var = cx.tcx.hir.as_local_node_id(freevar.def.def_id()).unwrap();
|
||||
let upvar_id = ty::UpvarId {
|
||||
var_id: id_var,
|
||||
closure_expr_id: closure_expr.id,
|
||||
|
@ -45,13 +45,13 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||
MirSource::Const(_) |
|
||||
MirSource::Static(..) => hir::Constness::Const,
|
||||
MirSource::Fn(id) => {
|
||||
let fn_like = FnLikeNode::from_node(infcx.tcx.map.get(id));
|
||||
let fn_like = FnLikeNode::from_node(infcx.tcx.hir.get(id));
|
||||
fn_like.map_or(hir::Constness::NotConst, |f| f.constness())
|
||||
}
|
||||
MirSource::Promoted(..) => bug!(),
|
||||
};
|
||||
|
||||
let attrs = infcx.tcx.map.attrs(src.item_id());
|
||||
let attrs = infcx.tcx.hir.attrs(src.item_id());
|
||||
|
||||
// Some functions always have overflow checks enabled,
|
||||
// however, they may not get codegen'd, depending on
|
||||
|
@ -84,7 +84,7 @@ fn build<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
-> (Mir<'tcx>, MirSource) {
|
||||
let tcx = infcx.tcx.global_tcx();
|
||||
|
||||
let item_id = tcx.map.body_owner(body_id);
|
||||
let item_id = tcx.hir.body_owner(body_id);
|
||||
let src = MirSource::from_node(tcx, item_id);
|
||||
let cx = Cx::new(infcx, src);
|
||||
if let MirSource::Fn(id) = src {
|
||||
@ -92,14 +92,14 @@ fn build<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
// types/lifetimes replaced)
|
||||
let fn_sig = cx.tables().liberated_fn_sigs[&id].clone();
|
||||
|
||||
let ty = tcx.item_type(tcx.map.local_def_id(id));
|
||||
let ty = tcx.item_type(tcx.hir.local_def_id(id));
|
||||
let (abi, implicit_argument) = if let ty::TyClosure(..) = ty.sty {
|
||||
(Abi::Rust, Some((closure_self_ty(tcx, id, body_id), None)))
|
||||
} else {
|
||||
(ty.fn_abi(), None)
|
||||
};
|
||||
|
||||
let body = tcx.map.body(body_id);
|
||||
let body = tcx.hir.body(body_id);
|
||||
let explicit_arguments =
|
||||
body.arguments
|
||||
.iter()
|
||||
@ -138,11 +138,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
||||
pretty::dump_mir(tcx, "mir_map", &0, src, &mir);
|
||||
|
||||
let mir = tcx.alloc_mir(mir);
|
||||
let def_id = tcx.map.local_def_id(src.item_id());
|
||||
let def_id = tcx.hir.local_def_id(src.item_id());
|
||||
assert!(tcx.mir_map.borrow_mut().insert(def_id, mir).is_none());
|
||||
});
|
||||
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
self.visit_body(body);
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
});
|
||||
let region = tcx.mk_region(region);
|
||||
|
||||
match tcx.closure_kind(tcx.map.local_def_id(closure_expr_id)) {
|
||||
match tcx.closure_kind(tcx.hir.local_def_id(closure_expr_id)) {
|
||||
ty::ClosureKind::Fn =>
|
||||
tcx.mk_ref(region,
|
||||
ty::TypeAndMut { ty: closure_ty,
|
||||
|
@ -48,7 +48,7 @@ pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
Some(ref filters) => filters,
|
||||
};
|
||||
let node_id = src.item_id();
|
||||
let node_path = tcx.item_path_str(tcx.map.local_def_id(node_id));
|
||||
let node_path = tcx.item_path_str(tcx.hir.local_def_id(node_id));
|
||||
let is_matched =
|
||||
filters.split("&")
|
||||
.any(|filter| {
|
||||
@ -102,7 +102,7 @@ pub fn write_mir_pretty<'a, 'b, 'tcx, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>,
|
||||
writeln!(w, "")?;
|
||||
}
|
||||
|
||||
let id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let src = MirSource::from_node(tcx, id);
|
||||
write_mir_fn(tcx, src, mir, w)?;
|
||||
|
||||
|
@ -57,7 +57,7 @@ impl<'tcx> MirPass<'tcx> for CopyPropagation {
|
||||
return
|
||||
}
|
||||
MirSource::Fn(function_node_id) => {
|
||||
if qualify_consts::is_const_fn(tcx, tcx.map.local_def_id(function_node_id)) {
|
||||
if qualify_consts::is_const_fn(tcx, tcx.hir.local_def_id(function_node_id)) {
|
||||
// Don't run on const functions, as, again, trans might not be able to evaluate
|
||||
// the optimized IR.
|
||||
return
|
||||
|
@ -21,7 +21,7 @@ impl<'tcx> MirPass<'tcx> for Deaggregator {
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource, mir: &mut Mir<'tcx>) {
|
||||
let node_id = source.item_id();
|
||||
let node_path = tcx.item_path_str(tcx.map.local_def_id(node_id));
|
||||
let node_path = tcx.item_path_str(tcx.hir.local_def_id(node_id));
|
||||
debug!("running on: {:?}", node_path);
|
||||
// we only run when mir_opt_level > 2
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 {
|
||||
|
@ -115,8 +115,8 @@ impl fmt::Display for Mode {
|
||||
}
|
||||
|
||||
pub fn is_const_fn(tcx: TyCtxt, def_id: DefId) -> bool {
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(fn_like) = FnLikeNode::from_node(tcx.map.get(node_id)) {
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
|
||||
if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) {
|
||||
fn_like.constness() == hir::Constness::Const
|
||||
} else {
|
||||
false
|
||||
@ -267,15 +267,15 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
||||
self.tcx
|
||||
.lookup_trait_def(drop_trait_id)
|
||||
.for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| {
|
||||
self.tcx.map
|
||||
self.tcx.hir
|
||||
.as_local_node_id(impl_did)
|
||||
.and_then(|impl_node_id| self.tcx.map.find(impl_node_id))
|
||||
.and_then(|impl_node_id| self.tcx.hir.find(impl_node_id))
|
||||
.map(|node| {
|
||||
if let hir_map::NodeItem(item) = node {
|
||||
if let hir::ItemImpl(.., ref impl_item_refs) = item.node {
|
||||
span = impl_item_refs.first()
|
||||
.map(|iiref| {
|
||||
self.tcx.map.impl_item(iiref.id)
|
||||
self.tcx.hir.impl_item(iiref.id)
|
||||
.span
|
||||
});
|
||||
}
|
||||
@ -953,7 +953,7 @@ fn qualify_const_item_cached<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
let param_env = if def_id.is_local() {
|
||||
let node_id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
ty::ParameterEnvironment::for_item(tcx, node_id)
|
||||
} else {
|
||||
// These should only be monomorphic constants.
|
||||
@ -978,7 +978,7 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants {
|
||||
fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource, mir: &mut Mir<'tcx>) {
|
||||
let id = src.item_id();
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
let mode = match src {
|
||||
MirSource::Fn(_) => {
|
||||
if is_const_fn(tcx, def_id) {
|
||||
|
@ -98,8 +98,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
fn handle_const_fn_call(&mut self, def_id: DefId, ret_ty: Ty<'gcx>) {
|
||||
self.add_type(ret_ty);
|
||||
|
||||
self.promotable &= if let Some(fn_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
FnLikeNode::from_node(self.tcx.map.get(fn_id)).map_or(false, |fn_like| {
|
||||
self.promotable &= if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
FnLikeNode::from_node(self.tcx.hir.get(fn_id)).map_or(false, |fn_like| {
|
||||
fn_like.constness() == hir::Constness::Const
|
||||
})
|
||||
} else {
|
||||
@ -122,7 +122,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let item_id = self.tcx.map.body_owner(body_id);
|
||||
let item_id = self.tcx.hir.body_owner(body_id);
|
||||
|
||||
let outer_in_fn = self.in_fn;
|
||||
self.in_fn = match MirSource::from_node(self.tcx, item_id) {
|
||||
@ -131,9 +131,9 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||
};
|
||||
|
||||
let outer_tables = self.tables;
|
||||
self.tables = self.tcx.item_tables(self.tcx.map.local_def_id(item_id));
|
||||
self.tables = self.tcx.item_tables(self.tcx.hir.local_def_id(item_id));
|
||||
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
if !self.in_fn {
|
||||
self.check_const_eval(&body.value);
|
||||
}
|
||||
@ -329,8 +329,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
|
||||
Def::Fn(..) | Def::Method(..) => {}
|
||||
Def::AssociatedConst(_) => v.add_type(node_ty),
|
||||
Def::Const(did) => {
|
||||
v.promotable &= if let Some(node_id) = v.tcx.map.as_local_node_id(did) {
|
||||
match v.tcx.map.expect_item(node_id).node {
|
||||
v.promotable &= if let Some(node_id) = v.tcx.hir.as_local_node_id(did) {
|
||||
match v.tcx.hir.expect_item(node_id).node {
|
||||
hir::ItemConst(_, body) => {
|
||||
v.visit_nested_body(body);
|
||||
v.tcx.rvalue_promotable_to_static.borrow()[&body.node_id]
|
||||
|
@ -43,9 +43,9 @@ enum Context {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct CheckLoopVisitor<'a, 'ast: 'a> {
|
||||
struct CheckLoopVisitor<'a, 'hir: 'a> {
|
||||
sess: &'a Session,
|
||||
hir_map: &'a Map<'ast>,
|
||||
hir_map: &'a Map<'hir>,
|
||||
cx: Context,
|
||||
}
|
||||
|
||||
@ -59,20 +59,20 @@ pub fn check_crate(sess: &Session, map: &Map) {
|
||||
}.as_deep_visitor());
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
NestedVisitorMap::OnlyBodies(&self.hir_map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'ast hir::Item) {
|
||||
fn visit_item(&mut self, i: &'hir hir::Item) {
|
||||
self.with_context(Normal, |v| intravisit::walk_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &'ast hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, i: &'hir hir::ImplItem) {
|
||||
self.with_context(Normal, |v| intravisit::walk_impl_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &'ast hir::Expr) {
|
||||
fn visit_expr(&mut self, e: &'hir hir::Expr) {
|
||||
match e.node {
|
||||
hir::ExprWhile(ref e, ref b, _) => {
|
||||
self.with_context(Loop(LoopKind::WhileLoop), |v| {
|
||||
@ -125,9 +125,9 @@ impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'ast> CheckLoopVisitor<'a, 'ast> {
|
||||
impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
|
||||
fn with_context<F>(&mut self, cx: Context, f: F)
|
||||
where F: FnOnce(&mut CheckLoopVisitor<'a, 'ast>)
|
||||
where F: FnOnce(&mut CheckLoopVisitor<'a, 'hir>)
|
||||
{
|
||||
let old_cx = self.cx;
|
||||
self.cx = cx;
|
||||
|
@ -37,7 +37,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
self.tcx.infer_ctxt(body_id, Reveal::NotSpecializable).enter(|infcx| {
|
||||
let mut delegate = RvalueContextDelegate {
|
||||
tcx: infcx.tcx,
|
||||
|
@ -12,7 +12,7 @@
|
||||
// recursively.
|
||||
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::hir::map as ast_map;
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::session::{CompileResult, Session};
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::util::nodemap::{NodeMap, NodeSet};
|
||||
@ -23,9 +23,9 @@ use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir;
|
||||
|
||||
struct CheckCrateVisitor<'a, 'ast: 'a> {
|
||||
struct CheckCrateVisitor<'a, 'hir: 'a> {
|
||||
sess: &'a Session,
|
||||
ast_map: &'a ast_map::Map<'ast>,
|
||||
hir_map: &'a hir_map::Map<'hir>,
|
||||
// `discriminant_map` is a cache that associates the `NodeId`s of local
|
||||
// variant definitions with the discriminant expression that applies to
|
||||
// each one. If the variant uses the default values (starting from `0`),
|
||||
@ -34,12 +34,12 @@ struct CheckCrateVisitor<'a, 'ast: 'a> {
|
||||
detected_recursive_ids: NodeSet,
|
||||
}
|
||||
|
||||
impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
impl<'a, 'hir: 'a> Visitor<'hir> for CheckCrateVisitor<'a, 'hir> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
fn visit_item(&mut self, it: &'hir hir::Item) {
|
||||
match it.node {
|
||||
hir::ItemStatic(..) |
|
||||
hir::ItemConst(..) => {
|
||||
@ -64,7 +64,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
intravisit::walk_item(self, it)
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) {
|
||||
match ti.node {
|
||||
hir::TraitItemKind::Const(_, ref default) => {
|
||||
if let Some(_) = *default {
|
||||
@ -77,7 +77,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
intravisit::walk_trait_item(self, ti)
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) {
|
||||
match ii.node {
|
||||
hir::ImplItemKind::Const(..) => {
|
||||
let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &ii.span);
|
||||
@ -89,36 +89,36 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_crate<'ast>(sess: &Session, ast_map: &ast_map::Map<'ast>) -> CompileResult {
|
||||
let _task = ast_map.dep_graph.in_task(DepNode::CheckStaticRecursion);
|
||||
pub fn check_crate<'hir>(sess: &Session, hir_map: &hir_map::Map<'hir>) -> CompileResult {
|
||||
let _task = hir_map.dep_graph.in_task(DepNode::CheckStaticRecursion);
|
||||
|
||||
let mut visitor = CheckCrateVisitor {
|
||||
sess: sess,
|
||||
ast_map: ast_map,
|
||||
hir_map: hir_map,
|
||||
discriminant_map: NodeMap(),
|
||||
detected_recursive_ids: NodeSet(),
|
||||
};
|
||||
sess.track_errors(|| {
|
||||
// FIXME(#37712) could use ItemLikeVisitor if trait items were item-like
|
||||
ast_map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
hir_map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
})
|
||||
}
|
||||
|
||||
struct CheckItemRecursionVisitor<'a, 'b: 'a, 'ast: 'b> {
|
||||
struct CheckItemRecursionVisitor<'a, 'b: 'a, 'hir: 'b> {
|
||||
root_span: &'b Span,
|
||||
sess: &'b Session,
|
||||
ast_map: &'b ast_map::Map<'ast>,
|
||||
hir_map: &'b hir_map::Map<'hir>,
|
||||
discriminant_map: &'a mut NodeMap<Option<hir::BodyId>>,
|
||||
idstack: Vec<ast::NodeId>,
|
||||
detected_recursive_ids: &'a mut NodeSet,
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> {
|
||||
fn new(v: &'a mut CheckCrateVisitor<'b, 'ast>, span: &'b Span) -> Self {
|
||||
impl<'a, 'b: 'a, 'hir: 'b> CheckItemRecursionVisitor<'a, 'b, 'hir> {
|
||||
fn new(v: &'a mut CheckCrateVisitor<'b, 'hir>, span: &'b Span) -> Self {
|
||||
CheckItemRecursionVisitor {
|
||||
root_span: span,
|
||||
sess: v.sess,
|
||||
ast_map: v.ast_map,
|
||||
hir_map: v.hir_map,
|
||||
discriminant_map: &mut v.discriminant_map,
|
||||
idstack: Vec::new(),
|
||||
detected_recursive_ids: &mut v.detected_recursive_ids,
|
||||
@ -133,7 +133,7 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> {
|
||||
}
|
||||
self.detected_recursive_ids.insert(id);
|
||||
let any_static = self.idstack.iter().any(|&x| {
|
||||
if let ast_map::NodeItem(item) = self.ast_map.get(x) {
|
||||
if let hir_map::NodeItem(item) = self.hir_map.get(x) {
|
||||
if let hir::ItemStatic(..) = item.node {
|
||||
true
|
||||
} else {
|
||||
@ -170,7 +170,7 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> {
|
||||
// So for every variant, we need to track whether there is an expression
|
||||
// somewhere in the enum definition that controls its discriminant. We do
|
||||
// this by starting from the end and searching backward.
|
||||
fn populate_enum_discriminants(&mut self, enum_definition: &'ast hir::EnumDef) {
|
||||
fn populate_enum_discriminants(&mut self, enum_definition: &'hir hir::EnumDef) {
|
||||
// Get the map, and return if we already processed this enum or if it
|
||||
// has no variants.
|
||||
match enum_definition.variants.first() {
|
||||
@ -204,17 +204,17 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, 'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ast_map)
|
||||
impl<'a, 'b: 'a, 'hir: 'b> Visitor<'hir> for CheckItemRecursionVisitor<'a, 'b, 'hir> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
|
||||
NestedVisitorMap::OnlyBodies(&self.hir_map)
|
||||
}
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
fn visit_item(&mut self, it: &'hir hir::Item) {
|
||||
self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it), it.span);
|
||||
}
|
||||
|
||||
fn visit_enum_def(&mut self,
|
||||
enum_definition: &'ast hir::EnumDef,
|
||||
generics: &'ast hir::Generics,
|
||||
enum_definition: &'hir hir::EnumDef,
|
||||
generics: &'hir hir::Generics,
|
||||
item_id: ast::NodeId,
|
||||
_: Span) {
|
||||
self.populate_enum_discriminants(enum_definition);
|
||||
@ -222,8 +222,8 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, '
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self,
|
||||
variant: &'ast hir::Variant,
|
||||
_: &'ast hir::Generics,
|
||||
variant: &'hir hir::Variant,
|
||||
_: &'hir hir::Generics,
|
||||
_: ast::NodeId) {
|
||||
let variant_id = variant.node.data.id();
|
||||
let maybe_expr = *self.discriminant_map.get(&variant_id).unwrap_or_else(|| {
|
||||
@ -234,34 +234,34 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, '
|
||||
// If `maybe_expr` is `None`, that's because no discriminant is
|
||||
// specified that affects this variant. Thus, no risk of recursion.
|
||||
if let Some(expr) = maybe_expr {
|
||||
let expr = &self.ast_map.body(expr).value;
|
||||
let expr = &self.hir_map.body(expr).value;
|
||||
self.with_item_id_pushed(expr.id, |v| intravisit::walk_expr(v, expr), expr.span);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
|
||||
fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) {
|
||||
self.with_item_id_pushed(ti.id, |v| intravisit::walk_trait_item(v, ti), ti.span);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) {
|
||||
self.with_item_id_pushed(ii.id, |v| intravisit::walk_impl_item(v, ii), ii.span);
|
||||
}
|
||||
|
||||
fn visit_path(&mut self, path: &'ast hir::Path, _: ast::NodeId) {
|
||||
fn visit_path(&mut self, path: &'hir hir::Path, _: ast::NodeId) {
|
||||
match path.def {
|
||||
Def::Static(def_id, _) |
|
||||
Def::AssociatedConst(def_id) |
|
||||
Def::Const(def_id) => {
|
||||
if let Some(node_id) = self.ast_map.as_local_node_id(def_id) {
|
||||
match self.ast_map.get(node_id) {
|
||||
ast_map::NodeItem(item) => self.visit_item(item),
|
||||
ast_map::NodeTraitItem(item) => self.visit_trait_item(item),
|
||||
ast_map::NodeImplItem(item) => self.visit_impl_item(item),
|
||||
ast_map::NodeForeignItem(_) => {}
|
||||
if let Some(node_id) = self.hir_map.as_local_node_id(def_id) {
|
||||
match self.hir_map.get(node_id) {
|
||||
hir_map::NodeItem(item) => self.visit_item(item),
|
||||
hir_map::NodeTraitItem(item) => self.visit_trait_item(item),
|
||||
hir_map::NodeImplItem(item) => self.visit_impl_item(item),
|
||||
hir_map::NodeForeignItem(_) => {}
|
||||
_ => {
|
||||
span_bug!(path.span,
|
||||
"expected item, found {}",
|
||||
self.ast_map.node_to_string(node_id));
|
||||
self.hir_map.node_to_string(node_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,10 +271,10 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, '
|
||||
// the whole enum definition to see what expression that
|
||||
// might be (if any).
|
||||
Def::VariantCtor(variant_id, CtorKind::Const) => {
|
||||
if let Some(variant_id) = self.ast_map.as_local_node_id(variant_id) {
|
||||
let variant = self.ast_map.expect_variant(variant_id);
|
||||
let enum_id = self.ast_map.get_parent(variant_id);
|
||||
let enum_item = self.ast_map.expect_item(enum_id);
|
||||
if let Some(variant_id) = self.hir_map.as_local_node_id(variant_id) {
|
||||
let variant = self.hir_map.expect_variant(variant_id);
|
||||
let enum_id = self.hir_map.get_parent(variant_id);
|
||||
let enum_item = self.hir_map.expect_item(enum_id);
|
||||
if let hir::ItemEnum(ref enum_def, ref generics) = enum_item.node {
|
||||
self.populate_enum_discriminants(enum_def);
|
||||
self.visit_variant(variant, generics, enum_id);
|
||||
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||
ty::TyProjection(ref proj) => proj.trait_ref.def_id,
|
||||
_ => return Some(AccessLevel::Public)
|
||||
};
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(ty_def_id) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(ty_def_id) {
|
||||
self.get(node_id)
|
||||
} else {
|
||||
Some(AccessLevel::Public)
|
||||
@ -84,7 +84,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||
|
||||
fn impl_trait_level(&self, impl_def_id: DefId) -> Option<AccessLevel> {
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_def_id) {
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(trait_ref.def_id) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(trait_ref.def_id) {
|
||||
return self.get(node_id);
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||
fn reach<'b>(&'b mut self, item_id: ast::NodeId)
|
||||
-> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
|
||||
ReachEverythingInTheInterfaceVisitor {
|
||||
item_def_id: self.tcx.map.local_def_id(item_id),
|
||||
item_def_id: self.tcx.hir.local_def_id(item_id),
|
||||
ev: self,
|
||||
}
|
||||
}
|
||||
@ -121,18 +121,18 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let inherited_item_level = match item.node {
|
||||
// Impls inherit level from their types and traits
|
||||
hir::ItemImpl(..) => {
|
||||
let def_id = self.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id))
|
||||
}
|
||||
hir::ItemDefaultImpl(..) => {
|
||||
let def_id = self.tcx.map.local_def_id(item.id);
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
self.impl_trait_level(def_id)
|
||||
}
|
||||
// Foreign mods inherit level from parents
|
||||
@ -306,7 +306,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||
if self.prev_level.is_some() {
|
||||
if let Some(exports) = self.export_map.get(&id) {
|
||||
for export in exports {
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def.def_id()) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) {
|
||||
self.update(node_id, Some(AccessLevel::Exported));
|
||||
}
|
||||
}
|
||||
@ -366,7 +366,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
|
||||
};
|
||||
|
||||
if let Some(def_id) = ty_def_id {
|
||||
if let Some(node_id) = self.ev.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(node_id) = self.ev.tcx.hir.as_local_node_id(def_id) {
|
||||
self.ev.update(node_id, Some(AccessLevel::Reachable));
|
||||
}
|
||||
}
|
||||
@ -375,8 +375,8 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
|
||||
}
|
||||
|
||||
fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool {
|
||||
if let Some(node_id) = self.ev.tcx.map.as_local_node_id(trait_ref.def_id) {
|
||||
let item = self.ev.tcx.map.expect_item(node_id);
|
||||
if let Some(node_id) = self.ev.tcx.hir.as_local_node_id(trait_ref.def_id) {
|
||||
let item = self.ev.tcx.hir.expect_item(node_id);
|
||||
self.ev.update(item.id, Some(AccessLevel::Reachable));
|
||||
}
|
||||
|
||||
@ -397,9 +397,9 @@ struct PrivacyVisitor<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
fn item_is_accessible(&self, did: DefId) -> bool {
|
||||
match self.tcx.map.as_local_node_id(did) {
|
||||
match self.tcx.hir.as_local_node_id(did) {
|
||||
Some(node_id) =>
|
||||
ty::Visibility::from_hir(&self.tcx.map.expect_item(node_id).vis, node_id, self.tcx),
|
||||
ty::Visibility::from_hir(&self.tcx.hir.expect_item(node_id).vis, node_id, self.tcx),
|
||||
None => self.tcx.sess.cstore.visibility(did),
|
||||
}.is_accessible_from(self.curitem, self.tcx)
|
||||
}
|
||||
@ -433,19 +433,19 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_tables = self.tables;
|
||||
self.tables = self.tcx.body_tables(body);
|
||||
let body = self.tcx.map.body(body);
|
||||
let body = self.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.tables = old_tables;
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let orig_curitem = replace(&mut self.curitem, self.tcx.map.local_def_id(item.id));
|
||||
let orig_curitem = replace(&mut self.curitem, self.tcx.hir.local_def_id(item.id));
|
||||
intravisit::walk_item(self, item);
|
||||
self.curitem = orig_curitem;
|
||||
}
|
||||
@ -492,8 +492,8 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> {
|
||||
error.span_label(expr.span,
|
||||
&format!("cannot construct with a private field"));
|
||||
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(adt_def.did) {
|
||||
let node = self.tcx.map.find(node_id);
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(adt_def.did) {
|
||||
let node = self.tcx.hir.find(node_id);
|
||||
if let Some(hir::map::NodeStructCtor(vdata)) = node {
|
||||
for i in private_indexes {
|
||||
error.span_label(vdata.fields()[i].span,
|
||||
@ -590,10 +590,10 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
|
||||
// A path can only be private if:
|
||||
// it's in this crate...
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(did) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(did) {
|
||||
// .. and it corresponds to a private type in the AST (this returns
|
||||
// None for type parameters)
|
||||
match self.tcx.map.find(node_id) {
|
||||
match self.tcx.hir.find(node_id) {
|
||||
Some(hir::map::NodeItem(ref item)) => item.vis != hir::Public,
|
||||
Some(_) | None => false,
|
||||
}
|
||||
@ -653,7 +653,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
NestedVisitorMap::All(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
@ -709,7 +709,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
|tr| {
|
||||
let did = tr.path.def.def_id();
|
||||
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(did) {
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(did) {
|
||||
self.trait_is_public(node_id)
|
||||
} else {
|
||||
true // external traits must be public
|
||||
@ -728,7 +728,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
trait_ref.is_some() ||
|
||||
impl_item_refs.iter()
|
||||
.any(|impl_item_ref| {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
@ -752,7 +752,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
// should only walk into public items so that we
|
||||
// don't erroneously report errors for private
|
||||
// types in private items.
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..)
|
||||
@ -785,7 +785,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
|
||||
// Those in 3. are warned with this call.
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
if let hir::ImplItemKind::Type(ref ty) = impl_item.node {
|
||||
self.visit_ty(ty);
|
||||
}
|
||||
@ -798,7 +798,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
let mut found_pub_static = false;
|
||||
for impl_item_ref in impl_item_refs {
|
||||
if self.item_is_public(&impl_item_ref.id.node_id, &impl_item_ref.vis) {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
match impl_item_ref.kind {
|
||||
hir::AssociatedItemKind::Const => {
|
||||
found_pub_static = true;
|
||||
@ -962,8 +962,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
|
||||
|
||||
if let Some(def_id) = ty_def_id {
|
||||
// Non-local means public (private items can't leave their crate, modulo bugs)
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
let item = self.tcx.map.expect_item(node_id);
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
let item = self.tcx.hir.expect_item(node_id);
|
||||
let vis = ty::Visibility::from_hir(&item.vis, node_id, self.tcx);
|
||||
|
||||
if !vis.is_at_least(self.min_visibility, self.tcx) {
|
||||
@ -997,8 +997,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
|
||||
|
||||
fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool {
|
||||
// Non-local means public (private items can't leave their crate, modulo bugs)
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(trait_ref.def_id) {
|
||||
let item = self.tcx.map.expect_item(node_id);
|
||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(trait_ref.def_id) {
|
||||
let item = self.tcx.hir.expect_item(node_id);
|
||||
let vis = ty::Visibility::from_hir(&item.vis, node_id, self.tcx);
|
||||
|
||||
if !vis.is_at_least(self.min_visibility, self.tcx) {
|
||||
@ -1045,7 +1045,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
has_old_errors = true;
|
||||
break;
|
||||
}
|
||||
let parent = self.tcx.map.get_parent_node(id);
|
||||
let parent = self.tcx.hir.get_parent_node(id);
|
||||
if parent == id {
|
||||
break;
|
||||
}
|
||||
@ -1059,8 +1059,8 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
|
||||
SearchInterfaceForPrivateItemsVisitor {
|
||||
tcx: self.tcx,
|
||||
item_def_id: self.tcx.map.local_def_id(item_id),
|
||||
span: self.tcx.map.span(item_id),
|
||||
item_def_id: self.tcx.hir.local_def_id(item_id),
|
||||
span: self.tcx.hir.span(item_id),
|
||||
min_visibility: ty::Visibility::Public,
|
||||
required_visibility: required_visibility,
|
||||
has_old_errors: has_old_errors,
|
||||
@ -1070,7 +1070,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
@ -1148,7 +1148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
self.check(item.id, ty_vis).generics().predicates();
|
||||
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
let impl_item_vis =
|
||||
ty::Visibility::from_hir(&impl_item.vis, item.id, tcx);
|
||||
self.check(impl_item.id, min(impl_item_vis, ty_vis))
|
||||
@ -1166,7 +1166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
.item_type().impl_trait_ref().min_visibility;
|
||||
self.check(item.id, vis).generics().predicates();
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
|
||||
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
|
||||
self.check(impl_item.id, vis).generics().predicates().item_type();
|
||||
|
||||
// Recurse for e.g. `impl Trait` (see `visit_ty`).
|
||||
@ -1205,7 +1205,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> AccessLevels {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::Privacy);
|
||||
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
|
||||
// Use the parent map to check the privacy of everything
|
||||
let mut visitor = PrivacyVisitor {
|
||||
|
@ -112,7 +112,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
|
||||
{
|
||||
let old_tables = self.save_ctxt.tables;
|
||||
let item_def_id = self.tcx.map.local_def_id(item_id);
|
||||
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
||||
self.save_ctxt.tables = self.tcx.item_tables(item_def_id);
|
||||
f(self);
|
||||
self.save_ctxt.tables = old_tables;
|
||||
@ -399,7 +399,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
// with the right name.
|
||||
if !self.span.filter_generated(Some(method_data.span), span) {
|
||||
let container =
|
||||
self.tcx.associated_item(self.tcx.map.local_def_id(id)).container;
|
||||
self.tcx.associated_item(self.tcx.hir.local_def_id(id)).container;
|
||||
let mut trait_id;
|
||||
let mut decl_id = None;
|
||||
match container {
|
||||
@ -418,7 +418,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(NodeItem(item)) = self.tcx.map.get_if_local(id) {
|
||||
if let Some(NodeItem(item)) = self.tcx.hir.get_if_local(id) {
|
||||
if let hir::ItemImpl(_, _, _, _, ref ty, _) = item.node {
|
||||
trait_id = self.lookup_def_id(ty.id);
|
||||
}
|
||||
@ -693,7 +693,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
type_value: enum_data.qualname.clone(),
|
||||
value: val,
|
||||
scope: enum_data.scope,
|
||||
parent: Some(make_def_id(item.id, &self.tcx.map)),
|
||||
parent: Some(make_def_id(item.id, &self.tcx.hir)),
|
||||
docs: docs_for_attrs(&variant.node.attrs),
|
||||
sig: sig,
|
||||
}.lower(self.tcx));
|
||||
@ -719,7 +719,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
type_value: enum_data.qualname.clone(),
|
||||
value: val,
|
||||
scope: enum_data.scope,
|
||||
parent: Some(make_def_id(item.id, &self.tcx.map)),
|
||||
parent: Some(make_def_id(item.id, &self.tcx.hir)),
|
||||
docs: docs_for_attrs(&variant.node.attrs),
|
||||
sig: sig,
|
||||
}.lower(self.tcx));
|
||||
@ -775,7 +775,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
}
|
||||
self.process_generic_params(type_parameters, item.span, "", item.id);
|
||||
for impl_item in impl_items {
|
||||
let map = &self.tcx.map;
|
||||
let map = &self.tcx.hir;
|
||||
self.process_impl_item(impl_item, make_def_id(item.id, map));
|
||||
}
|
||||
}
|
||||
@ -848,7 +848,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
|
||||
// walk generics and methods
|
||||
self.process_generic_params(generics, item.span, &qualname, item.id);
|
||||
for method in methods {
|
||||
let map = &self.tcx.map;
|
||||
let map = &self.tcx.hir;
|
||||
self.process_trait_item(method, make_def_id(item.id, map))
|
||||
}
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
|
||||
visit::walk_expr(self, ex);
|
||||
}
|
||||
ast::ExprKind::Struct(ref path, ref fields, ref base) => {
|
||||
let hir_expr = self.save_ctxt.tcx.map.expect_expr(ex.id);
|
||||
let hir_expr = self.save_ctxt.tcx.hir.expect_expr(ex.id);
|
||||
let adt = match self.save_ctxt.tables.expr_ty_opt(&hir_expr) {
|
||||
Some(ty) => ty.ty_adt_def().unwrap(),
|
||||
None => {
|
||||
@ -1408,7 +1408,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
|
||||
ast::ExprKind::TupField(ref sub_ex, idx) => {
|
||||
self.visit_expr(&sub_ex);
|
||||
|
||||
let hir_node = match self.save_ctxt.tcx.map.find(sub_ex.id) {
|
||||
let hir_node = match self.save_ctxt.tcx.hir.find(sub_ex.id) {
|
||||
Some(Node::NodeExpr(expr)) => expr,
|
||||
_ => {
|
||||
debug!("Missing or weird node for sub-expression {} in {:?}",
|
||||
@ -1510,7 +1510,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
|
||||
for &(id, ref p, immut, ref_kind) in &collector.collected_paths {
|
||||
match self.save_ctxt.get_path_def(id) {
|
||||
Def::Local(def_id) => {
|
||||
let id = self.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let mut value = if immut == ast::Mutability::Immutable {
|
||||
self.span.snippet(p.span).to_string()
|
||||
} else {
|
||||
|
@ -105,13 +105,13 @@ impl Lower for data::EnumData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> EnumData {
|
||||
EnumData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
value: self.value,
|
||||
qualname: self.qualname,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
variants: self.variants.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
variants: self.variants.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
|
||||
visibility: self.visibility,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -135,12 +135,12 @@ impl Lower for data::ExternCrateData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> ExternCrateData {
|
||||
ExternCrateData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
crate_num: self.crate_num,
|
||||
location: self.location,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,7 @@ impl Lower for data::FunctionCallData {
|
||||
fn lower(self, tcx: TyCtxt) -> FunctionCallData {
|
||||
FunctionCallData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
}
|
||||
}
|
||||
@ -186,12 +186,12 @@ impl Lower for data::FunctionData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> FunctionData {
|
||||
FunctionData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
qualname: self.qualname,
|
||||
declaration: self.declaration,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
value: self.value,
|
||||
visibility: self.visibility,
|
||||
parent: self.parent,
|
||||
@ -215,7 +215,7 @@ impl Lower for data::FunctionRefData {
|
||||
fn lower(self, tcx: TyCtxt) -> FunctionRefData {
|
||||
FunctionRefData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
}
|
||||
}
|
||||
@ -234,9 +234,9 @@ impl Lower for data::ImplData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> ImplData {
|
||||
ImplData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
trait_ref: self.trait_ref,
|
||||
self_ref: self.self_ref,
|
||||
}
|
||||
@ -257,7 +257,7 @@ impl Lower for data::InheritanceData {
|
||||
InheritanceData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
base_id: self.base_id,
|
||||
deriv_id: make_def_id(self.deriv_id, &tcx.map)
|
||||
deriv_id: make_def_id(self.deriv_id, &tcx.hir)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -305,7 +305,7 @@ impl Lower for data::MacroUseData {
|
||||
name: self.name,
|
||||
qualname: self.qualname,
|
||||
callee_span: SpanData::from_span(self.callee_span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,7 +325,7 @@ impl Lower for data::MethodCallData {
|
||||
fn lower(self, tcx: TyCtxt) -> MethodCallData {
|
||||
MethodCallData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
decl_id: self.decl_id,
|
||||
}
|
||||
@ -355,8 +355,8 @@ impl Lower for data::MethodData {
|
||||
MethodData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
name: self.name,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
qualname: self.qualname,
|
||||
value: self.value,
|
||||
decl_id: self.decl_id,
|
||||
@ -388,13 +388,13 @@ impl Lower for data::ModData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> ModData {
|
||||
ModData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
qualname: self.qualname,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
filename: self.filename,
|
||||
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(),
|
||||
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
|
||||
visibility: self.visibility,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -417,7 +417,7 @@ impl Lower for data::ModRefData {
|
||||
fn lower(self, tcx: TyCtxt) -> ModRefData {
|
||||
ModRefData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
qualname: self.qualname,
|
||||
}
|
||||
@ -446,12 +446,12 @@ impl Lower for data::StructData {
|
||||
StructData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
name: self.name,
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
ctor_id: make_def_id(self.ctor_id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
ctor_id: make_def_id(self.ctor_id, &tcx.hir),
|
||||
qualname: self.qualname,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
value: self.value,
|
||||
fields: self.fields.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(),
|
||||
fields: self.fields.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
|
||||
visibility: self.visibility,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -480,11 +480,11 @@ impl Lower for data::StructVariantData {
|
||||
StructVariantData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
name: self.name,
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
qualname: self.qualname,
|
||||
type_value: self.type_value,
|
||||
value: self.value,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
parent: self.parent,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -513,11 +513,11 @@ impl Lower for data::TraitData {
|
||||
TraitData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
name: self.name,
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
qualname: self.qualname,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
value: self.value,
|
||||
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(),
|
||||
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
|
||||
visibility: self.visibility,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -545,12 +545,12 @@ impl Lower for data::TupleVariantData {
|
||||
fn lower(self, tcx: TyCtxt) -> TupleVariantData {
|
||||
TupleVariantData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
qualname: self.qualname,
|
||||
type_value: self.type_value,
|
||||
value: self.value,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
parent: self.parent,
|
||||
docs: self.docs,
|
||||
sig: self.sig.lower(tcx),
|
||||
@ -577,7 +577,7 @@ impl Lower for data::TypeDefData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> TypeDefData {
|
||||
TypeDefData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
name: self.name,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
qualname: self.qualname,
|
||||
@ -605,7 +605,7 @@ impl Lower for data::TypeRefData {
|
||||
fn lower(self, tcx: TyCtxt) -> TypeRefData {
|
||||
TypeRefData {
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
qualname: self.qualname,
|
||||
}
|
||||
@ -627,11 +627,11 @@ impl Lower for data::UseData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> UseData {
|
||||
UseData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
name: self.name,
|
||||
mod_id: self.mod_id,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
visibility: self.visibility,
|
||||
}
|
||||
}
|
||||
@ -651,10 +651,10 @@ impl Lower for data::UseGlobData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> UseGlobData {
|
||||
UseGlobData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
names: self.names,
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
visibility: self.visibility,
|
||||
}
|
||||
}
|
||||
@ -682,12 +682,12 @@ impl Lower for data::VariableData {
|
||||
|
||||
fn lower(self, tcx: TyCtxt) -> VariableData {
|
||||
VariableData {
|
||||
id: make_def_id(self.id, &tcx.map),
|
||||
id: make_def_id(self.id, &tcx.hir),
|
||||
kind: self.kind,
|
||||
name: self.name,
|
||||
qualname: self.qualname,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
value: self.value,
|
||||
type_value: self.type_value,
|
||||
parent: self.parent,
|
||||
@ -715,7 +715,7 @@ impl Lower for data::VariableRefData {
|
||||
VariableRefData {
|
||||
name: self.name,
|
||||
span: SpanData::from_span(self.span, tcx.sess.codemap()),
|
||||
scope: make_def_id(self.scope, &tcx.map),
|
||||
scope: make_def_id(self.scope, &tcx.hir),
|
||||
ref_id: self.ref_id,
|
||||
}
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
|
||||
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
|
||||
filter!(self.span_utils, sub_span, field.span, None);
|
||||
let def_id = self.tcx.map.local_def_id(field.id);
|
||||
let def_id = self.tcx.hir.local_def_id(field.id);
|
||||
let typ = self.tcx.item_type(def_id).to_string();
|
||||
|
||||
let span = field.span;
|
||||
@ -307,7 +307,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
qualname: qualname,
|
||||
span: sub_span.unwrap(),
|
||||
scope: scope,
|
||||
parent: Some(make_def_id(scope, &self.tcx.map)),
|
||||
parent: Some(make_def_id(scope, &self.tcx.hir)),
|
||||
value: "".to_owned(),
|
||||
type_value: typ,
|
||||
visibility: From::from(&field.vis),
|
||||
@ -326,13 +326,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
// The qualname for a method is the trait name or name of the struct in an impl in
|
||||
// which the method is declared in, followed by the method's name.
|
||||
let (qualname, parent_scope, decl_id, vis, docs) =
|
||||
match self.tcx.impl_of_method(self.tcx.map.local_def_id(id)) {
|
||||
Some(impl_id) => match self.tcx.map.get_if_local(impl_id) {
|
||||
match self.tcx.impl_of_method(self.tcx.hir.local_def_id(id)) {
|
||||
Some(impl_id) => match self.tcx.hir.get_if_local(impl_id) {
|
||||
Some(Node::NodeItem(item)) => {
|
||||
match item.node {
|
||||
hir::ItemImpl(.., ref ty, _) => {
|
||||
let mut result = String::from("<");
|
||||
result.push_str(&self.tcx.map.node_to_pretty_string(ty.id));
|
||||
result.push_str(&self.tcx.hir.node_to_pretty_string(ty.id));
|
||||
|
||||
let trait_id = self.tcx.trait_id_of_impl(impl_id);
|
||||
let mut decl_id = None;
|
||||
@ -365,9 +365,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
r);
|
||||
}
|
||||
},
|
||||
None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
|
||||
None => match self.tcx.trait_of_item(self.tcx.hir.local_def_id(id)) {
|
||||
Some(def_id) => {
|
||||
match self.tcx.map.get_if_local(def_id) {
|
||||
match self.tcx.hir.get_if_local(def_id) {
|
||||
Some(Node::NodeItem(item)) => {
|
||||
(format!("::{}", self.tcx.item_path_str(def_id)),
|
||||
Some(def_id), None,
|
||||
@ -442,14 +442,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
|
||||
let hir_node = self.tcx.map.expect_expr(expr.id);
|
||||
let hir_node = self.tcx.hir.expect_expr(expr.id);
|
||||
let ty = self.tables.expr_ty_adjusted_opt(&hir_node);
|
||||
if ty.is_none() || ty.unwrap().sty == ty::TyError {
|
||||
return None;
|
||||
}
|
||||
match expr.node {
|
||||
ast::ExprKind::Field(ref sub_ex, ident) => {
|
||||
let hir_node = match self.tcx.map.find(sub_ex.id) {
|
||||
let hir_node = match self.tcx.hir.find(sub_ex.id) {
|
||||
Some(Node::NodeExpr(expr)) => expr,
|
||||
_ => {
|
||||
debug!("Missing or weird node for sub-expression {} in {:?}",
|
||||
@ -523,7 +523,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn get_path_def(&self, id: NodeId) -> Def {
|
||||
match self.tcx.map.get(id) {
|
||||
match self.tcx.hir.get(id) {
|
||||
Node::NodeTraitRef(tr) => tr.path.def,
|
||||
|
||||
Node::NodeItem(&hir::Item { node: hir::ItemUse(ref path, _), .. }) |
|
||||
@ -733,7 +733,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
#[inline]
|
||||
pub fn enclosing_scope(&self, id: NodeId) -> NodeId {
|
||||
self.tcx.map.get_enclosing_scope(id).unwrap_or(CRATE_NODE_ID)
|
||||
self.tcx.hir.get_enclosing_scope(id).unwrap_or(CRATE_NODE_ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
let ams = AssertModuleSource { tcx: tcx, modules: modules };
|
||||
for attr in &tcx.map.krate().attrs {
|
||||
for attr in &tcx.hir.krate().attrs {
|
||||
ams.check_attr(attr);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ impl ExportedSymbols {
|
||||
.exported_symbols()
|
||||
.iter()
|
||||
.map(|&node_id| {
|
||||
scx.tcx().map.local_def_id(node_id)
|
||||
scx.tcx().hir.local_def_id(node_id)
|
||||
})
|
||||
.map(|def_id| {
|
||||
let name = symbol_for_def_id(scx, def_id, symbol_map);
|
||||
@ -64,7 +64,7 @@ impl ExportedSymbols {
|
||||
|
||||
if let Some(id) = scx.sess().derive_registrar_fn.get() {
|
||||
let svh = &scx.link_meta().crate_hash;
|
||||
let def_id = scx.tcx().map.local_def_id(id);
|
||||
let def_id = scx.tcx().hir.local_def_id(id);
|
||||
let idx = def_id.index;
|
||||
let registrar = scx.sess().generate_derive_registrar_symbol(svh, idx);
|
||||
local_crate.push((registrar, SymbolExportLevel::C));
|
||||
@ -181,7 +181,7 @@ fn symbol_for_def_id<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
-> String {
|
||||
// Just try to look things up in the symbol map. If nothing's there, we
|
||||
// recompute.
|
||||
if let Some(node_id) = scx.tcx().map.as_local_node_id(def_id) {
|
||||
if let Some(node_id) = scx.tcx().hir.as_local_node_id(def_id) {
|
||||
if let Some(sym) = symbol_map.get(TransItem::Static(node_id)) {
|
||||
return sym.to_owned();
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ impl<'a, 'tcx> Instance<'tcx> {
|
||||
debug!("symbol_name(def_id={:?}, substs={:?})",
|
||||
def_id, substs);
|
||||
|
||||
let node_id = scx.tcx().map.as_local_node_id(def_id);
|
||||
let node_id = scx.tcx().hir.as_local_node_id(def_id);
|
||||
|
||||
if let Some(id) = node_id {
|
||||
if scx.sess().plugin_registrar_fn.get() == Some(id) {
|
||||
@ -193,7 +193,7 @@ impl<'a, 'tcx> Instance<'tcx> {
|
||||
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
|
||||
let attrs = scx.tcx().get_attrs(def_id);
|
||||
let is_foreign = if let Some(id) = node_id {
|
||||
match scx.tcx().map.get(id) {
|
||||
match scx.tcx().hir.get(id) {
|
||||
hir_map::NodeForeignItem(_) => true,
|
||||
_ => false
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ pub fn set_link_section(ccx: &CrateContext,
|
||||
pub fn maybe_create_entry_wrapper(ccx: &CrateContext) {
|
||||
let (main_def_id, span) = match *ccx.sess().entry_fn.borrow() {
|
||||
Some((id, span)) => {
|
||||
(ccx.tcx().map.local_def_id(id), span)
|
||||
(ccx.tcx().hir.local_def_id(id), span)
|
||||
}
|
||||
None => return,
|
||||
};
|
||||
@ -1075,9 +1075,9 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet {
|
||||
//
|
||||
// As a result, if this id is an FFI item (foreign item) then we only
|
||||
// let it through if it's included statically.
|
||||
match tcx.map.get(id) {
|
||||
match tcx.hir.get(id) {
|
||||
hir_map::NodeForeignItem(..) => {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
tcx.sess.cstore.is_statically_included_foreign_item(def_id)
|
||||
}
|
||||
|
||||
@ -1088,7 +1088,7 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet {
|
||||
node: hir::ItemFn(..), .. }) |
|
||||
hir_map::NodeImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(..), .. }) => {
|
||||
let def_id = tcx.map.local_def_id(id);
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
let generics = tcx.item_generics(def_id);
|
||||
let attributes = tcx.get_attrs(def_id);
|
||||
(generics.parent_types == 0 && generics.types.is_empty()) &&
|
||||
@ -1112,7 +1112,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// entire contents of the krate. So if you push any subtasks of
|
||||
// `TransCrate`, you need to be careful to register "reads" of the
|
||||
// particular items that will be processed.
|
||||
let krate = tcx.map.krate();
|
||||
let krate = tcx.hir.krate();
|
||||
|
||||
let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis;
|
||||
let exported_symbols = find_exported_symbols(tcx, reachable);
|
||||
|
@ -309,7 +309,7 @@ fn collect_roots<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
output: &mut roots,
|
||||
};
|
||||
|
||||
scx.tcx().map.krate().visit_all_item_likes(&mut visitor);
|
||||
scx.tcx().hir.krate().visit_all_item_likes(&mut visitor);
|
||||
}
|
||||
|
||||
roots
|
||||
@ -336,7 +336,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(scx: &SharedCrateContext<'a, 'tcx>,
|
||||
recursion_depth_reset = None;
|
||||
}
|
||||
TransItem::Static(node_id) => {
|
||||
let def_id = scx.tcx().map.local_def_id(node_id);
|
||||
let def_id = scx.tcx().hir.local_def_id(node_id);
|
||||
|
||||
// Sanity check whether this ended up being collected accidentally
|
||||
debug_assert!(should_trans_locally(scx.tcx(), def_id));
|
||||
@ -406,8 +406,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
if recursion_depth > tcx.sess.recursion_limit.get() {
|
||||
let error = format!("reached the recursion limit while instantiating `{}`",
|
||||
instance);
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(instance.def) {
|
||||
tcx.sess.span_fatal(tcx.map.span(node_id), &error);
|
||||
if let Some(node_id) = tcx.hir.as_local_node_id(instance.def) {
|
||||
tcx.sess.span_fatal(tcx.hir.span(node_id), &error);
|
||||
} else {
|
||||
tcx.sess.fatal(&error);
|
||||
}
|
||||
@ -438,8 +438,8 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let instance_name = instance.to_string();
|
||||
let msg = format!("reached the type-length limit while instantiating `{:.64}...`",
|
||||
instance_name);
|
||||
let mut diag = if let Some(node_id) = tcx.map.as_local_node_id(instance.def) {
|
||||
tcx.sess.struct_span_fatal(tcx.map.span(node_id), &msg)
|
||||
let mut diag = if let Some(node_id) = tcx.hir.as_local_node_id(instance.def) {
|
||||
tcx.sess.struct_span_fatal(tcx.hir.span(node_id), &msg)
|
||||
} else {
|
||||
tcx.sess.struct_fatal(&msg)
|
||||
};
|
||||
@ -619,7 +619,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
// Some constructors also have type TyFnDef but they are
|
||||
// always instantiated inline and don't result in a
|
||||
// translation item. Same for FFI functions.
|
||||
if let Some(hir_map::NodeForeignItem(_)) = tcx.map.get_if_local(def_id) {
|
||||
if let Some(hir_map::NodeForeignItem(_)) = tcx.hir.get_if_local(def_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1152,7 +1152,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
hir::ItemUnion(_, ref generics) => {
|
||||
if !generics.is_parameterized() {
|
||||
if self.mode == TransItemCollectionMode::Eager {
|
||||
let def_id = self.scx.tcx().map.local_def_id(item.id);
|
||||
let def_id = self.scx.tcx().hir.local_def_id(item.id);
|
||||
debug!("RootCollector: ADT drop-glue for {}",
|
||||
def_id_to_string(self.scx.tcx(), def_id));
|
||||
|
||||
@ -1165,7 +1165,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
hir::ItemStatic(..) => {
|
||||
debug!("RootCollector: ItemStatic({})",
|
||||
def_id_to_string(self.scx.tcx(),
|
||||
self.scx.tcx().map.local_def_id(item.id)));
|
||||
self.scx.tcx().hir.local_def_id(item.id)));
|
||||
self.output.push(TransItem::Static(item.id));
|
||||
}
|
||||
hir::ItemConst(..) => {
|
||||
@ -1174,7 +1174,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
}
|
||||
hir::ItemFn(.., ref generics, _) => {
|
||||
if !generics.is_type_parameterized() {
|
||||
let def_id = self.scx.tcx().map.local_def_id(item.id);
|
||||
let def_id = self.scx.tcx().hir.local_def_id(item.id);
|
||||
|
||||
debug!("RootCollector: ItemFn({})",
|
||||
def_id_to_string(self.scx.tcx(), def_id));
|
||||
@ -1197,7 +1197,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
ref generics,
|
||||
..
|
||||
}, _) => {
|
||||
let hir_map = &self.scx.tcx().map;
|
||||
let hir_map = &self.scx.tcx().hir;
|
||||
let parent_node_id = hir_map.get_parent_node(ii.id);
|
||||
let is_impl_generic = match hir_map.expect_item(parent_node_id) {
|
||||
&hir::Item {
|
||||
@ -1212,7 +1212,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||
};
|
||||
|
||||
if !generics.is_type_parameterized() && !is_impl_generic {
|
||||
let def_id = self.scx.tcx().map.local_def_id(ii.id);
|
||||
let def_id = self.scx.tcx().hir.local_def_id(ii.id);
|
||||
|
||||
debug!("RootCollector: MethodImplItem({})",
|
||||
def_id_to_string(self.scx.tcx(), def_id));
|
||||
@ -1240,7 +1240,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(scx: &SharedCrateContext<'a, '
|
||||
return
|
||||
}
|
||||
|
||||
let impl_def_id = tcx.map.local_def_id(item.id);
|
||||
let impl_def_id = tcx.hir.local_def_id(item.id);
|
||||
|
||||
debug!("create_trans_items_for_default_impls(item={})",
|
||||
def_id_to_string(tcx, impl_def_id));
|
||||
|
@ -85,10 +85,10 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
|
||||
}
|
||||
|
||||
let ty = ccx.tcx().item_type(def_id);
|
||||
let g = if let Some(id) = ccx.tcx().map.as_local_node_id(def_id) {
|
||||
let g = if let Some(id) = ccx.tcx().hir.as_local_node_id(def_id) {
|
||||
|
||||
let llty = type_of::type_of(ccx, ty);
|
||||
let (g, attrs) = match ccx.tcx().map.get(id) {
|
||||
let (g, attrs) = match ccx.tcx().hir.get(id) {
|
||||
hir_map::NodeItem(&hir::Item {
|
||||
ref attrs, span, node: hir::ItemStatic(..), ..
|
||||
}) => {
|
||||
@ -219,7 +219,7 @@ pub fn trans_static(ccx: &CrateContext,
|
||||
attrs: &[ast::Attribute])
|
||||
-> Result<ValueRef, ConstEvalErr> {
|
||||
unsafe {
|
||||
let def_id = ccx.tcx().map.local_def_id(id);
|
||||
let def_id = ccx.tcx().hir.local_def_id(id);
|
||||
let g = get_static(ccx, def_id);
|
||||
|
||||
let v = ::mir::trans_static_initializer(ccx, def_id)?;
|
||||
|
@ -79,7 +79,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
|
||||
|
||||
pub fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
|
||||
let omit_gdb_pretty_printer_section =
|
||||
attr::contains_name(&ccx.tcx().map.krate_attrs(),
|
||||
attr::contains_name(&ccx.tcx().hir.krate_attrs(),
|
||||
"omit_gdb_pretty_printer_section");
|
||||
|
||||
!omit_gdb_pretty_printer_section &&
|
||||
|
@ -1738,7 +1738,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
|
||||
let tcx = cx.tcx();
|
||||
|
||||
let node_def_id = tcx.map.local_def_id(node_id);
|
||||
let node_def_id = tcx.hir.local_def_id(node_id);
|
||||
let (var_scope, span) = get_namespace_and_span_for_item(cx, node_def_id);
|
||||
|
||||
let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP {
|
||||
|
@ -251,7 +251,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let scope_line = span_start(cx, span).line;
|
||||
|
||||
let local_id = cx.tcx().map.as_local_node_id(instance.def);
|
||||
let local_id = cx.tcx().hir.as_local_node_id(instance.def);
|
||||
let is_local_to_unit = local_id.map_or(false, |id| is_node_local_to_unit(cx, id));
|
||||
|
||||
let function_name = CString::new(name).unwrap();
|
||||
|
@ -76,7 +76,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
|
||||
// compiler-rt, then we want to implicitly compile everything with hidden
|
||||
// visibility as we're going to link this object all over the place but
|
||||
// don't want the symbols to get exported.
|
||||
if attr::contains_name(ccx.tcx().map.krate_attrs(), "compiler_builtins") {
|
||||
if attr::contains_name(ccx.tcx().hir.krate_attrs(), "compiler_builtins") {
|
||||
unsafe {
|
||||
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||
symbol_name.hash(&mut state);
|
||||
let exported = match item {
|
||||
TransItem::Fn(ref instance) => {
|
||||
let node_id = scx.tcx().map.as_local_node_id(instance.def);
|
||||
let node_id = scx.tcx().hir.as_local_node_id(instance.def);
|
||||
node_id.map(|node_id| exported_symbols.contains(&node_id))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
@ -241,7 +241,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||
fn local_node_id(tcx: TyCtxt, trans_item: TransItem) -> Option<NodeId> {
|
||||
match trans_item {
|
||||
TransItem::Fn(instance) => {
|
||||
tcx.map.as_local_node_id(instance.def)
|
||||
tcx.hir.as_local_node_id(instance.def)
|
||||
}
|
||||
TransItem::Static(node_id) => Some(node_id),
|
||||
TransItem::DropGlue(_) => None,
|
||||
@ -482,7 +482,7 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 't
|
||||
Some(instance.def)
|
||||
}
|
||||
TransItem::DropGlue(dg) => characteristic_def_id_of_type(dg.ty()),
|
||||
TransItem::Static(node_id) => Some(tcx.map.local_def_id(node_id)),
|
||||
TransItem::Static(node_id) => Some(tcx.hir.local_def_id(node_id)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,12 @@ impl<'tcx> SymbolMap<'tcx> {
|
||||
trans_item: TransItem<'tcx>) -> Option<Span> {
|
||||
match trans_item {
|
||||
TransItem::Fn(Instance { def, .. }) => {
|
||||
tcx.map.as_local_node_id(def)
|
||||
tcx.hir.as_local_node_id(def)
|
||||
}
|
||||
TransItem::Static(node_id) => Some(node_id),
|
||||
TransItem::DropGlue(_) => None,
|
||||
}.map(|node_id| {
|
||||
tcx.map.span(node_id)
|
||||
tcx.hir.span(node_id)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ pub fn report_symbol_names(scx: &SharedCrateContext) {
|
||||
let _ignore = tcx.dep_graph.in_ignore();
|
||||
let mut visitor = SymbolNamesTest { scx: scx };
|
||||
// FIXME(#37712) could use ItemLikeVisitor if trait items were item-like
|
||||
tcx.map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
}
|
||||
|
||||
struct SymbolNamesTest<'a, 'tcx:'a> {
|
||||
@ -47,7 +47,7 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
|
||||
fn process_attrs(&mut self,
|
||||
node_id: ast::NodeId) {
|
||||
let tcx = self.scx.tcx();
|
||||
let def_id = tcx.map.local_def_id(node_id);
|
||||
let def_id = tcx.hir.local_def_id(node_id);
|
||||
for attr in tcx.get_attrs(def_id).iter() {
|
||||
if attr.check_name(SYMBOL_NAME) {
|
||||
// for now, can only use on monomorphic names
|
||||
|
@ -77,9 +77,9 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
|
||||
match *self {
|
||||
TransItem::Static(node_id) => {
|
||||
let def_id = ccx.tcx().map.local_def_id(node_id);
|
||||
let def_id = ccx.tcx().hir.local_def_id(node_id);
|
||||
let _task = ccx.tcx().dep_graph.in_task(DepNode::TransCrateItem(def_id)); // (*)
|
||||
let item = ccx.tcx().map.expect_item(node_id);
|
||||
let item = ccx.tcx().hir.expect_item(node_id);
|
||||
if let hir::ItemStatic(_, m, _) = item.node {
|
||||
match consts::trans_static(&ccx, m, item.id, &item.attrs) {
|
||||
Ok(_) => { /* Cool, everything's alright. */ },
|
||||
@ -145,12 +145,12 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
node_id: ast::NodeId,
|
||||
linkage: llvm::Linkage,
|
||||
symbol_name: &str) {
|
||||
let def_id = ccx.tcx().map.local_def_id(node_id);
|
||||
let def_id = ccx.tcx().hir.local_def_id(node_id);
|
||||
let ty = ccx.tcx().item_type(def_id);
|
||||
let llty = type_of::type_of(ccx, ty);
|
||||
|
||||
let g = declare::define_global(ccx, symbol_name, llty).unwrap_or_else(|| {
|
||||
ccx.sess().span_fatal(ccx.tcx().map.span(node_id),
|
||||
ccx.sess().span_fatal(ccx.tcx().hir.span(node_id),
|
||||
&format!("symbol `{}` is already defined", symbol_name))
|
||||
});
|
||||
|
||||
@ -222,7 +222,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
match *self {
|
||||
TransItem::Fn(instance) => instance.symbol_name(scx),
|
||||
TransItem::Static(node_id) => {
|
||||
let def_id = scx.tcx().map.local_def_id(node_id);
|
||||
let def_id = scx.tcx().hir.local_def_id(node_id);
|
||||
Instance::mono(scx, def_id).symbol_name(scx)
|
||||
}
|
||||
TransItem::DropGlue(dg) => {
|
||||
@ -274,7 +274,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
pub fn explicit_linkage(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<llvm::Linkage> {
|
||||
let def_id = match *self {
|
||||
TransItem::Fn(ref instance) => instance.def,
|
||||
TransItem::Static(node_id) => tcx.map.local_def_id(node_id),
|
||||
TransItem::Static(node_id) => tcx.hir.local_def_id(node_id),
|
||||
TransItem::DropGlue(..) => return None,
|
||||
};
|
||||
|
||||
@ -283,7 +283,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
if let Some(linkage) = base::llvm_linkage_by_name(&name.as_str()) {
|
||||
Some(linkage)
|
||||
} else {
|
||||
let span = tcx.map.span_if_local(def_id);
|
||||
let span = tcx.hir.span_if_local(def_id);
|
||||
if let Some(span) = span {
|
||||
tcx.sess.span_fatal(span, "invalid linkage specified")
|
||||
} else {
|
||||
@ -296,7 +296,7 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||
}
|
||||
|
||||
pub fn to_string(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String {
|
||||
let hir_map = &tcx.map;
|
||||
let hir_map = &tcx.hir;
|
||||
|
||||
return match *self {
|
||||
TransItem::DropGlue(dg) => {
|
||||
|
@ -186,7 +186,7 @@ pub fn ast_region_to_region<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
.get(&id)
|
||||
.cloned()
|
||||
.unwrap_or(ty::Issue32330::WontChange);
|
||||
ty::ReLateBound(debruijn, ty::BrNamed(tcx.map.local_def_id(id),
|
||||
ty::ReLateBound(debruijn, ty::BrNamed(tcx.hir.local_def_id(id),
|
||||
lifetime.name,
|
||||
issue_32330))
|
||||
}
|
||||
@ -208,7 +208,7 @@ pub fn ast_region_to_region<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
.unwrap_or(ty::Issue32330::WontChange);
|
||||
ty::ReFree(ty::FreeRegion {
|
||||
scope: scope.to_code_extent(&tcx.region_maps),
|
||||
bound_region: ty::BrNamed(tcx.map.local_def_id(id),
|
||||
bound_region: ty::BrNamed(tcx.hir.local_def_id(id),
|
||||
lifetime.name,
|
||||
issue_32330)
|
||||
})
|
||||
@ -245,8 +245,8 @@ fn report_elision_failure(
|
||||
} = info;
|
||||
|
||||
let help_name = if let Some(body) = parent {
|
||||
let arg = &tcx.map.body(body).arguments[index];
|
||||
format!("`{}`", tcx.map.node_to_pretty_string(arg.pat.id))
|
||||
let arg = &tcx.hir.body(body).arguments[index];
|
||||
format!("`{}`", tcx.hir.node_to_pretty_string(arg.pat.id))
|
||||
} else {
|
||||
format!("argument {}", index + 1)
|
||||
};
|
||||
@ -684,7 +684,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
}
|
||||
_ => {
|
||||
span_fatal!(self.tcx().sess, path.span, E0245, "`{}` is not a trait",
|
||||
self.tcx().map.node_to_pretty_string(trait_ref.ref_id));
|
||||
self.tcx().hir.node_to_pretty_string(trait_ref.ref_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| {
|
||||
item.kind == ty::AssociatedKind::Type && item.name == assoc_name
|
||||
})
|
||||
.and_then(|item| self.tcx().map.span_if_local(item.def_id));
|
||||
.and_then(|item| self.tcx().hir.span_if_local(item.def_id));
|
||||
|
||||
if let Some(span) = bound_span {
|
||||
err.span_label(span, &format!("ambiguous `{}` from `{}`",
|
||||
@ -1223,7 +1223,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
}
|
||||
}
|
||||
(&ty::TyParam(_), Def::SelfTy(Some(trait_did), None)) => {
|
||||
let trait_node_id = tcx.map.as_local_node_id(trait_did).unwrap();
|
||||
let trait_node_id = tcx.hir.as_local_node_id(trait_did).unwrap();
|
||||
match self.find_bound_for_assoc_item(trait_node_id,
|
||||
keywords::SelfType.name(),
|
||||
assoc_name,
|
||||
@ -1233,7 +1233,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
}
|
||||
}
|
||||
(&ty::TyParam(_), Def::TyParam(param_did)) => {
|
||||
let param_node_id = tcx.map.as_local_node_id(param_did).unwrap();
|
||||
let param_node_id = tcx.hir.as_local_node_id(param_did).unwrap();
|
||||
let param_name = tcx.type_parameter_def(param_node_id).name;
|
||||
match self.find_bound_for_assoc_item(param_node_id,
|
||||
param_name,
|
||||
@ -1379,7 +1379,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
assert_eq!(opt_self_ty, None);
|
||||
tcx.prohibit_type_params(&path.segments);
|
||||
|
||||
let node_id = tcx.map.as_local_node_id(did).unwrap();
|
||||
let node_id = tcx.hir.as_local_node_id(did).unwrap();
|
||||
let param = tcx.ty_param_defs.borrow().get(&node_id)
|
||||
.map(ty::ParamTy::for_def);
|
||||
if let Some(p) = param {
|
||||
@ -1544,10 +1544,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
use collect::{compute_bounds, SizedByDefault};
|
||||
|
||||
// Create the anonymized type.
|
||||
let def_id = tcx.map.local_def_id(ast_ty.id);
|
||||
let def_id = tcx.hir.local_def_id(ast_ty.id);
|
||||
if let Some(anon_scope) = rscope.anon_type_scope() {
|
||||
let substs = anon_scope.fresh_substs(self, ast_ty.span);
|
||||
let ty = tcx.mk_anon(tcx.map.local_def_id(ast_ty.id), substs);
|
||||
let ty = tcx.mk_anon(tcx.hir.local_def_id(ast_ty.id), substs);
|
||||
|
||||
// Collect the bounds, i.e. the `A+B+'c` in `impl A+B+'c`.
|
||||
let bounds = compute_bounds(self, ty, bounds,
|
||||
|
@ -139,7 +139,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
// if there are multiple arms, make sure they all agree on
|
||||
// what the type of the binding `x` ought to be
|
||||
let var_id = tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let var_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
if var_id != pat.id {
|
||||
let vt = self.local_ty(pat.span, var_id);
|
||||
self.demand_eqtype(pat.span, vt, typ);
|
||||
@ -561,7 +561,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
span_err!(tcx.sess, pat.span, E0533,
|
||||
"expected unit struct/variant or constant, found {} `{}`",
|
||||
def.kind_name(),
|
||||
hir::print::to_string(&tcx.map, |s| s.print_qpath(qpath, false)));
|
||||
hir::print::to_string(&tcx.hir, |s| s.print_qpath(qpath, false)));
|
||||
};
|
||||
|
||||
// Resolve the path and check the definition for errors.
|
||||
@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
let report_unexpected_def = |def: Def| {
|
||||
let msg = format!("expected tuple struct/variant, found {} `{}`",
|
||||
def.kind_name(),
|
||||
hir::print::to_string(&tcx.map, |s| s.print_qpath(qpath, false)));
|
||||
hir::print::to_string(&tcx.hir, |s| s.print_qpath(qpath, false)));
|
||||
struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg)
|
||||
.span_label(pat.span, &format!("not a tuple variant or struct")).emit();
|
||||
on_error();
|
||||
|
@ -194,7 +194,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
let (fn_sig, def_span) = match callee_ty.sty {
|
||||
ty::TyFnDef(def_id, .., &ty::BareFnTy {ref sig, ..}) => {
|
||||
(sig, self.tcx.map.span_if_local(def_id))
|
||||
(sig, self.tcx.hir.span_if_local(def_id))
|
||||
}
|
||||
ty::TyFnPtr(&ty::BareFnTy {ref sig, ..}) => (sig, None),
|
||||
ref t => {
|
||||
@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if let &ty::TyAdt(adt_def, ..) = t {
|
||||
if adt_def.is_enum() {
|
||||
if let hir::ExprCall(ref expr, _) = call_expr.node {
|
||||
unit_variant = Some(self.tcx.map.node_to_pretty_string(expr.id))
|
||||
unit_variant = Some(self.tcx.hir.node_to_pretty_string(expr.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,7 +225,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
Def::Err
|
||||
};
|
||||
if def != Def::Err {
|
||||
if let Some(span) = self.tcx.map.span_if_local(def.def_id()) {
|
||||
if let Some(span) = self.tcx.hir.span_if_local(def.def_id()) {
|
||||
err.span_note(span, "defined here");
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
Some(ty) => self.deduce_expectations_from_expected_type(ty),
|
||||
None => (None, None),
|
||||
};
|
||||
let body = self.tcx.map.body(body_id);
|
||||
let body = self.tcx.hir.body(body_id);
|
||||
self.check_closure(expr, expected_kind, decl, body, expected_sig)
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
opt_kind,
|
||||
expected_sig);
|
||||
|
||||
let expr_def_id = self.tcx.map.local_def_id(expr.id);
|
||||
let expr_def_id = self.tcx.hir.local_def_id(expr.id);
|
||||
let mut fn_ty = AstConv::ty_of_closure(self,
|
||||
hir::Unsafety::Normal,
|
||||
decl,
|
||||
|
@ -170,7 +170,7 @@ fn compare_predicate_entailment<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
// Create a parameter environment that represents the implementation's
|
||||
// method.
|
||||
let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_m_node_id);
|
||||
|
||||
// Create mapping from impl to skolemized.
|
||||
@ -437,8 +437,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
|
||||
trait_sig: ty::FnSig<'tcx>)
|
||||
-> (Span, Option<Span>) {
|
||||
let tcx = infcx.tcx;
|
||||
let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let (impl_m_output, impl_m_iter) = match tcx.map.expect_impl_item(impl_m_node_id).node {
|
||||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let (impl_m_output, impl_m_iter) = match tcx.hir.expect_impl_item(impl_m_node_id).node {
|
||||
ImplItemKind::Method(ref impl_m_sig, _) => {
|
||||
(&impl_m_sig.decl.output, impl_m_sig.decl.inputs.iter())
|
||||
}
|
||||
@ -447,8 +447,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
|
||||
|
||||
match *terr {
|
||||
TypeError::Mutability => {
|
||||
if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) {
|
||||
let trait_m_iter = match tcx.map.expect_trait_item(trait_m_node_id).node {
|
||||
if let Some(trait_m_node_id) = tcx.hir.as_local_node_id(trait_m.def_id) {
|
||||
let trait_m_iter = match tcx.hir.expect_trait_item(trait_m_node_id).node {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
trait_m_sig.decl.inputs.iter()
|
||||
}
|
||||
@ -466,15 +466,15 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
|
||||
}).map(|(ref impl_arg, ref trait_arg)| {
|
||||
(impl_arg.span, Some(trait_arg.span))
|
||||
})
|
||||
.unwrap_or_else(|| (cause.span, tcx.map.span_if_local(trait_m.def_id)))
|
||||
.unwrap_or_else(|| (cause.span, tcx.hir.span_if_local(trait_m.def_id)))
|
||||
} else {
|
||||
(cause.span, tcx.map.span_if_local(trait_m.def_id))
|
||||
(cause.span, tcx.hir.span_if_local(trait_m.def_id))
|
||||
}
|
||||
}
|
||||
TypeError::Sorts(ExpectedFound { .. }) => {
|
||||
if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) {
|
||||
if let Some(trait_m_node_id) = tcx.hir.as_local_node_id(trait_m.def_id) {
|
||||
let (trait_m_output, trait_m_iter) =
|
||||
match tcx.map.expect_trait_item(trait_m_node_id).node {
|
||||
match tcx.hir.expect_trait_item(trait_m_node_id).node {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
(&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter())
|
||||
}
|
||||
@ -499,14 +499,14 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
|
||||
.is_err() {
|
||||
(impl_m_output.span(), Some(trait_m_output.span()))
|
||||
} else {
|
||||
(cause.span, tcx.map.span_if_local(trait_m.def_id))
|
||||
(cause.span, tcx.hir.span_if_local(trait_m.def_id))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
(cause.span, tcx.map.span_if_local(trait_m.def_id))
|
||||
(cause.span, tcx.hir.span_if_local(trait_m.def_id))
|
||||
}
|
||||
}
|
||||
_ => (cause.span, tcx.map.span_if_local(trait_m.def_id)),
|
||||
_ => (cause.span, tcx.hir.span_if_local(trait_m.def_id)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ fn compare_self_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
trait_m.name,
|
||||
self_descr);
|
||||
err.span_label(impl_m_span, &format!("`{}` used in impl", self_descr));
|
||||
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
|
||||
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
|
||||
err.span_label(span, &format!("trait declared without `{}`", self_descr));
|
||||
}
|
||||
err.emit();
|
||||
@ -572,7 +572,7 @@ fn compare_self_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
self_descr);
|
||||
err.span_label(impl_m_span,
|
||||
&format!("expected `{}` in impl", self_descr));
|
||||
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
|
||||
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
|
||||
err.span_label(span, &format!("`{}` used in trait", self_descr));
|
||||
}
|
||||
err.emit();
|
||||
@ -595,8 +595,8 @@ fn compare_number_of_generics<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let num_impl_m_type_params = impl_m_generics.types.len();
|
||||
let num_trait_m_type_params = trait_m_generics.types.len();
|
||||
if num_impl_m_type_params != num_trait_m_type_params {
|
||||
let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let span = match tcx.map.expect_impl_item(impl_m_node_id).node {
|
||||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let span = match tcx.hir.expect_impl_item(impl_m_node_id).node {
|
||||
ImplItemKind::Method(ref impl_m_sig, _) => {
|
||||
if impl_m_sig.generics.is_parameterized() {
|
||||
impl_m_sig.generics.span
|
||||
@ -671,9 +671,9 @@ fn compare_number_of_method_arguments<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let trait_number_args = trait_m_fty.sig.inputs().skip_binder().len();
|
||||
let impl_number_args = impl_m_fty.sig.inputs().skip_binder().len();
|
||||
if trait_number_args != impl_number_args {
|
||||
let trait_m_node_id = tcx.map.as_local_node_id(trait_m.def_id);
|
||||
let trait_m_node_id = tcx.hir.as_local_node_id(trait_m.def_id);
|
||||
let trait_span = if let Some(trait_id) = trait_m_node_id {
|
||||
match tcx.map.expect_trait_item(trait_id).node {
|
||||
match tcx.hir.expect_trait_item(trait_id).node {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
if let Some(arg) = trait_m_sig.decl.inputs.get(if trait_number_args > 0 {
|
||||
trait_number_args - 1
|
||||
@ -690,8 +690,8 @@ fn compare_number_of_method_arguments<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
} else {
|
||||
trait_item_span
|
||||
};
|
||||
let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let impl_span = match tcx.map.expect_impl_item(impl_m_node_id).node {
|
||||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
|
||||
let impl_span = match tcx.hir.expect_impl_item(impl_m_node_id).node {
|
||||
ImplItemKind::Method(ref impl_m_sig, _) => {
|
||||
if let Some(arg) = impl_m_sig.decl.inputs.get(if impl_number_args > 0 {
|
||||
impl_number_args - 1
|
||||
@ -759,7 +759,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
// Create a parameter environment that represents the implementation's
|
||||
// method.
|
||||
let impl_c_node_id = tcx.map.as_local_node_id(impl_c.def_id).unwrap();
|
||||
let impl_c_node_id = tcx.hir.as_local_node_id(impl_c.def_id).unwrap();
|
||||
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_c_node_id);
|
||||
|
||||
// Create mapping from impl to skolemized.
|
||||
@ -810,7 +810,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
trait_ty);
|
||||
|
||||
// Locate the Span containing just the type of the offending impl
|
||||
match tcx.map.expect_impl_item(impl_c_node_id).node {
|
||||
match tcx.hir.expect_impl_item(impl_c_node_id).node {
|
||||
ImplItemKind::Const(ref ty, _) => cause.span = ty.span,
|
||||
_ => bug!("{:?} is not a impl const", impl_c),
|
||||
}
|
||||
@ -823,8 +823,8 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
trait_c.name);
|
||||
|
||||
// Add a label to the Span containing just the type of the item
|
||||
let trait_c_node_id = tcx.map.as_local_node_id(trait_c.def_id).unwrap();
|
||||
let trait_c_span = match tcx.map.expect_trait_item(trait_c_node_id).node {
|
||||
let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id).unwrap();
|
||||
let trait_c_span = match tcx.hir.expect_trait_item(trait_c_node_id).node {
|
||||
TraitItemKind::Const(ref ty, _) => ty.span,
|
||||
_ => bug!("{:?} is not a trait const", trait_c),
|
||||
};
|
||||
|
@ -75,8 +75,8 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
|
||||
-> Result<(), ()>
|
||||
{
|
||||
let tcx = ccx.tcx;
|
||||
let drop_impl_node_id = tcx.map.as_local_node_id(drop_impl_did).unwrap();
|
||||
let self_type_node_id = tcx.map.as_local_node_id(self_type_did).unwrap();
|
||||
let drop_impl_node_id = tcx.hir.as_local_node_id(drop_impl_did).unwrap();
|
||||
let self_type_node_id = tcx.hir.as_local_node_id(self_type_did).unwrap();
|
||||
|
||||
// check that the impl type can be made to match the trait type.
|
||||
|
||||
@ -100,7 +100,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
|
||||
assert!(obligations.is_empty());
|
||||
}
|
||||
Err(_) => {
|
||||
let item_span = tcx.map.span(self_type_node_id);
|
||||
let item_span = tcx.hir.span(self_type_node_id);
|
||||
struct_span_err!(tcx.sess, drop_impl_span, E0366,
|
||||
"Implementations of Drop cannot be specialized")
|
||||
.span_note(item_span,
|
||||
@ -171,7 +171,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>(
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
|
||||
let self_type_node_id = tcx.map.as_local_node_id(self_type_did).unwrap();
|
||||
let self_type_node_id = tcx.hir.as_local_node_id(self_type_did).unwrap();
|
||||
|
||||
let drop_impl_span = tcx.def_span(drop_impl_did);
|
||||
|
||||
@ -203,7 +203,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>(
|
||||
// repeated `contains` calls.
|
||||
|
||||
if !assumptions_in_impl_context.contains(&predicate) {
|
||||
let item_span = tcx.map.span(self_type_node_id);
|
||||
let item_span = tcx.hir.span(self_type_node_id);
|
||||
struct_span_err!(tcx.sess, drop_impl_span, E0367,
|
||||
"The requirement `{}` is added only by the Drop impl.", predicate)
|
||||
.span_note(item_span,
|
||||
|
@ -34,7 +34,7 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
inputs: Vec<Ty<'tcx>>,
|
||||
output: Ty<'tcx>) {
|
||||
let tcx = ccx.tcx;
|
||||
let def_id = tcx.map.local_def_id(it.id);
|
||||
let def_id = tcx.hir.local_def_id(it.id);
|
||||
|
||||
let substs = Substs::for_item(tcx, def_id,
|
||||
|_, _| tcx.mk_region(ty::ReErased),
|
||||
@ -324,7 +324,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
|
||||
};
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
let def_id = tcx.map.local_def_id(it.id);
|
||||
let def_id = tcx.hir.local_def_id(it.id);
|
||||
let i_n_tps = tcx.item_generics(def_id).types.len();
|
||||
let name = it.name.as_str();
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user