rustc: rename TyCtxt's map
field to hir
.
This commit is contained in:
parent
2f0463a4a4
commit
45c8c5678a
111 changed files with 761 additions and 761 deletions
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -144,14 +144,14 @@ 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)) {
|
||||
let tag = match self.hir.find(scope.node_id(&self.region_maps)) {
|
||||
Some(ast_map::NodeBlock(_)) => "block",
|
||||
Some(ast_map::NodeExpr(expr)) => match expr.node {
|
||||
hir::ExprCall(..) => "call",
|
||||
|
@ -206,7 +206,7 @@ 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) {
|
||||
let tag = match self.hir.find(node) {
|
||||
Some(ast_map::NodeBlock(_)) |
|
||||
Some(ast_map::NodeExpr(_)) => "body",
|
||||
Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
|
||||
|
@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
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,8 +467,8 @@ 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 {
|
||||
|
@ -1068,8 +1068,8 @@ 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 {
|
||||
|
@ -1083,8 +1083,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
let id = self.tcx.hir.get_parent(item.id);
|
||||
if let Some(ast_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)
|
||||
|
@ -1654,7 +1654,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;
|
||||
|
||||
|
@ -1891,8 +1891,8 @@ 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::ItemFn(.., ref gen, _) => {
|
||||
|
@ -1915,8 +1915,8 @@ 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::ItemImpl(_, _, ref gen, ..) => {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -35,7 +35,7 @@ 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) {
|
||||
match tcx.hir.find(node_id) {
|
||||
Some(ast_map::NodeItem(..)) |
|
||||
Some(ast_map::NodeImplItem(..)) |
|
||||
Some(ast_map::NodeForeignItem(..)) |
|
||||
|
@ -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,7 +143,7 @@ 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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -268,7 +268,7 @@ impl MutabilityCategory {
|
|||
}
|
||||
|
||||
fn from_local(tcx: TyCtxt, id: ast::NodeId) -> MutabilityCategory {
|
||||
let ret = match tcx.map.get(id) {
|
||||
let ret = match tcx.hir.get(id) {
|
||||
ast_map::NodeLocal(p) => match p.node {
|
||||
PatKind::Binding(bind_mode, ..) => {
|
||||
if bind_mode == hir::BindByValue(hir::MutMutable) {
|
||||
|
@ -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,7 +698,7 @@ 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) {
|
||||
let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) {
|
||||
Some(ast_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()
|
||||
|
|
|
@ -63,8 +63,8 @@ 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) {
|
||||
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
|
||||
match tcx.hir.find(impl_node_id) {
|
||||
Some(ast_map::NodeItem(item)) =>
|
||||
item_might_be_inlined(&item),
|
||||
Some(..) | None =>
|
||||
|
@ -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,12 +147,12 @@ 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) {
|
||||
match self.tcx.hir.find(node_id) {
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
match item.node {
|
||||
hir::ItemFn(..) => item_might_be_inlined(&item),
|
||||
|
@ -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,7 +210,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
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)
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
ast_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.
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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: ast_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: ast_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));
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
match tcx.hir.find(id) {
|
||||
Some(ast_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,7 +1213,7 @@ 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))
|
||||
}
|
||||
}
|
||||
|
@ -1223,8 +1223,8 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
|||
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,7 +1242,7 @@ 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)
|
||||
}
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
|||
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))
|
||||
|
@ -1287,7 +1287,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
|||
Some(ast_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,
|
||||
|
@ -1298,7 +1298,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
|
|||
}
|
||||
}
|
||||
Some(ast_map::NodeForeignItem(item)) => {
|
||||
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,
|
||||
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,7 +1944,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn expr_span(self, id: NodeId) -> Span {
|
||||
match self.map.find(id) {
|
||||
match self.hir.find(id) {
|
||||
Some(ast_map::NodeExpr(e)) => {
|
||||
e.span
|
||||
}
|
||||
|
@ -1958,7 +1958,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn local_var_name_str(self, id: NodeId) -> InternedString {
|
||||
match self.map.find(id) {
|
||||
match self.hir.find(id) {
|
||||
Some(ast_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")
|
||||
|
@ -2227,7 +2227,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn def_key(self, id: DefId) -> ast_map::DefKey {
|
||||
if id.is_local() {
|
||||
self.map.def_key(id)
|
||||
self.hir.def_key(id)
|
||||
} else {
|
||||
self.sess.cstore.def_key(id)
|
||||
}
|
||||
|
@ -2240,27 +2240,27 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// be a non-local `DefPath`.
|
||||
pub fn def_path(self, id: DefId) -> ast_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 {
|
||||
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(ast_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,8 +83,8 @@ 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 {
|
||||
node: hir::ItemConst(ref ty, body), ..
|
||||
|
@ -92,7 +92,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
Some(ast_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)))
|
||||
}
|
||||
|
@ -102,10 +102,10 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// 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);
|
||||
|
|
|
@ -502,7 +502,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
Some(&self.tcx.hir)
|
||||
}
|
||||
|
||||
fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn {
|
||||
|
@ -521,7 +521,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(())
|
||||
}
|
||||
|
@ -739,13 +739,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,
|
||||
ast_map: &tcx.hir,
|
||||
cfg: &cfg,
|
||||
name: format!("node_{}", code.id()),
|
||||
labelled_edges: labelled_edges,
|
||||
|
@ -1005,7 +1005,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 +1030,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 +1047,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -803,7 +803,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
|||
for step in steps.iter() {
|
||||
let closure_id = match step.self_ty.sty {
|
||||
ty::TyClosure(def_id, _) => {
|
||||
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) {
|
||||
id
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
@ -99,8 +99,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
item_name
|
||||
)
|
||||
}).unwrap();
|
||||
let note_span = self.tcx.map.span_if_local(item.def_id).or_else(|| {
|
||||
self.tcx.map.span_if_local(impl_did)
|
||||
let note_span = self.tcx.hir.span_if_local(item.def_id).or_else(|| {
|
||||
self.tcx.hir.span_if_local(impl_did)
|
||||
});
|
||||
|
||||
let impl_ty = self.impl_self_ty(span, impl_did).ty;
|
||||
|
@ -285,7 +285,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let msg = if let Some(callee) = rcvr_expr {
|
||||
format!("{}; use overloaded call notation instead (e.g., `{}()`)",
|
||||
msg,
|
||||
self.tcx.map.node_to_pretty_string(callee.id))
|
||||
self.tcx.hir.node_to_pretty_string(callee.id))
|
||||
} else {
|
||||
msg
|
||||
};
|
||||
|
@ -488,8 +488,8 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
|
|||
fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {
|
||||
}
|
||||
}
|
||||
ccx.tcx.map.krate().visit_all_item_likes(&mut Visitor {
|
||||
map: &ccx.tcx.map,
|
||||
ccx.tcx.hir.krate().visit_all_item_likes(&mut Visitor {
|
||||
map: &ccx.tcx.hir,
|
||||
traits: &mut traits,
|
||||
});
|
||||
|
||||
|
|
|
@ -538,7 +538,7 @@ struct CheckItemBodiesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
|||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ccx.tcx.map)
|
||||
NestedVisitorMap::OnlyBodies(&self.ccx.tcx.hir)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
|
@ -634,7 +634,7 @@ pub fn check_item_bodies(ccx: &CrateCtxt) -> CompileResult {
|
|||
// bodies have been fully inferred.
|
||||
for (&item_id, obligations) in ccx.deferred_obligations.borrow().iter() {
|
||||
// Use the same DepNode as for the body of the original function/item.
|
||||
let def_id = ccx.tcx.map.local_def_id(item_id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(item_id);
|
||||
let _task = ccx.tcx.dep_graph.in_task(DepNode::TypeckTables(def_id));
|
||||
|
||||
let param_env = ParameterEnvironment::for_item(ccx.tcx, item_id);
|
||||
|
@ -677,9 +677,9 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
body_id: hir::BodyId,
|
||||
fn_id: ast::NodeId,
|
||||
span: Span) {
|
||||
let body = ccx.tcx.map.body(body_id);
|
||||
let body = ccx.tcx.hir.body(body_id);
|
||||
|
||||
let raw_fty = ccx.tcx.item_type(ccx.tcx.map.local_def_id(fn_id));
|
||||
let raw_fty = ccx.tcx.item_type(ccx.tcx.hir.local_def_id(fn_id));
|
||||
let fn_ty = match raw_fty.sty {
|
||||
ty::TyFnDef(.., f) => f,
|
||||
_ => span_bug!(body.value.span, "check_bare_fn: function type expected")
|
||||
|
@ -835,7 +835,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
|||
}
|
||||
|
||||
fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
|
||||
let def_id = ccx.tcx.map.local_def_id(id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(id);
|
||||
check_representable(ccx.tcx, span, def_id);
|
||||
|
||||
if ccx.tcx.lookup_simd(def_id) {
|
||||
|
@ -844,13 +844,13 @@ fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
|
|||
}
|
||||
|
||||
fn check_union(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
|
||||
check_representable(ccx.tcx, span, ccx.tcx.map.local_def_id(id));
|
||||
check_representable(ccx.tcx, span, ccx.tcx.hir.local_def_id(id));
|
||||
}
|
||||
|
||||
pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
||||
debug!("check_item_type(it.id={}, it.name={})",
|
||||
it.id,
|
||||
ccx.tcx.item_path_str(ccx.tcx.map.local_def_id(it.id)));
|
||||
ccx.tcx.item_path_str(ccx.tcx.hir.local_def_id(it.id)));
|
||||
let _indenter = indenter();
|
||||
match it.node {
|
||||
// Consts can play a role in type-checking, so they are included here.
|
||||
|
@ -865,7 +865,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
|||
hir::ItemFn(..) => {} // entirely within check_item_body
|
||||
hir::ItemImpl(.., ref impl_item_refs) => {
|
||||
debug!("ItemImpl {} with id {}", it.name, it.id);
|
||||
let impl_def_id = ccx.tcx.map.local_def_id(it.id);
|
||||
let impl_def_id = ccx.tcx.hir.local_def_id(it.id);
|
||||
if let Some(impl_trait_ref) = ccx.tcx.impl_trait_ref(impl_def_id) {
|
||||
check_impl_items_against_trait(ccx,
|
||||
it.span,
|
||||
|
@ -877,7 +877,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
|||
}
|
||||
}
|
||||
hir::ItemTrait(..) => {
|
||||
let def_id = ccx.tcx.map.local_def_id(it.id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(it.id);
|
||||
check_on_unimplemented(ccx, def_id, it);
|
||||
}
|
||||
hir::ItemStruct(..) => {
|
||||
|
@ -887,7 +887,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
|||
check_union(ccx, it.id, it.span);
|
||||
}
|
||||
hir::ItemTy(_, ref generics) => {
|
||||
let def_id = ccx.tcx.map.local_def_id(it.id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(it.id);
|
||||
let pty_ty = ccx.tcx.item_type(def_id);
|
||||
check_bounds_are_used(ccx, generics, pty_ty);
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
|||
}
|
||||
} else {
|
||||
for item in &m.items {
|
||||
let generics = ccx.tcx.item_generics(ccx.tcx.map.local_def_id(item.id));
|
||||
let generics = ccx.tcx.item_generics(ccx.tcx.hir.local_def_id(item.id));
|
||||
if !generics.types.is_empty() {
|
||||
let mut err = struct_span_err!(ccx.tcx.sess, item.span, E0044,
|
||||
"foreign items may not have type parameters");
|
||||
|
@ -1038,12 +1038,12 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
let trait_def = tcx.lookup_trait_def(impl_trait_ref.def_id);
|
||||
let mut overridden_associated_type = None;
|
||||
|
||||
let impl_items = || impl_item_refs.iter().map(|iiref| ccx.tcx.map.impl_item(iiref.id));
|
||||
let impl_items = || impl_item_refs.iter().map(|iiref| ccx.tcx.hir.impl_item(iiref.id));
|
||||
|
||||
// Check existing impl methods to see if they are both present in trait
|
||||
// and compatible with trait signature
|
||||
for impl_item in impl_items() {
|
||||
let ty_impl_item = tcx.associated_item(tcx.map.local_def_id(impl_item.id));
|
||||
let ty_impl_item = tcx.associated_item(tcx.hir.local_def_id(impl_item.id));
|
||||
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
|
||||
.find(|ac| ac.name == ty_impl_item.name);
|
||||
|
||||
|
@ -1067,14 +1067,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
err.span_label(impl_item.span, &format!("does not match trait"));
|
||||
// We can only get the spans from local trait definition
|
||||
// Same for E0324 and E0325
|
||||
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) {
|
||||
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
|
||||
err.span_label(trait_span, &format!("item in trait"));
|
||||
}
|
||||
err.emit()
|
||||
}
|
||||
}
|
||||
hir::ImplItemKind::Method(_, body_id) => {
|
||||
let trait_span = tcx.map.span_if_local(ty_trait_item.def_id);
|
||||
let trait_span = tcx.hir.span_if_local(ty_trait_item.def_id);
|
||||
if ty_trait_item.kind == ty::AssociatedKind::Method {
|
||||
let err_count = tcx.sess.err_count();
|
||||
compare_impl_method(ccx,
|
||||
|
@ -1103,7 +1103,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
ty_impl_item.name,
|
||||
impl_trait_ref);
|
||||
err.span_label(impl_item.span, &format!("does not match trait"));
|
||||
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) {
|
||||
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
|
||||
err.span_label(trait_span, &format!("item in trait"));
|
||||
}
|
||||
err.emit()
|
||||
|
@ -1121,7 +1121,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
ty_impl_item.name,
|
||||
impl_trait_ref);
|
||||
err.span_label(impl_item.span, &format!("does not match trait"));
|
||||
if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) {
|
||||
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
|
||||
err.span_label(trait_span, &format!("item in trait"));
|
||||
}
|
||||
err.emit()
|
||||
|
@ -1176,7 +1176,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
.map(|trait_item| trait_item.name.to_string())
|
||||
.collect::<Vec<_>>().join("`, `")));
|
||||
for trait_item in missing_items {
|
||||
if let Some(span) = tcx.map.span_if_local(trait_item.def_id) {
|
||||
if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) {
|
||||
err.span_label(span, &format!("`{}` from trait", trait_item.name));
|
||||
} else {
|
||||
err.note(&format!("`{}` from trait: `{}`",
|
||||
|
@ -1204,7 +1204,7 @@ fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
|
|||
body: hir::BodyId,
|
||||
expected_type: Ty<'tcx>,
|
||||
id: ast::NodeId) {
|
||||
let body = ccx.tcx.map.body(body);
|
||||
let body = ccx.tcx.hir.body(body);
|
||||
ccx.inherited(id).enter(|inh| {
|
||||
let fcx = FnCtxt::new(&inh, None, body.value.id);
|
||||
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
|
||||
|
@ -1231,7 +1231,7 @@ fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
|
|||
fn check_const<'a, 'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
||||
body: hir::BodyId,
|
||||
id: ast::NodeId) {
|
||||
let decl_ty = ccx.tcx.item_type(ccx.tcx.map.local_def_id(id));
|
||||
let decl_ty = ccx.tcx.item_type(ccx.tcx.hir.local_def_id(id));
|
||||
check_const_with_type(ccx, body, decl_ty, id);
|
||||
}
|
||||
|
||||
|
@ -1294,7 +1294,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
sp: Span,
|
||||
vs: &'tcx [hir::Variant],
|
||||
id: ast::NodeId) {
|
||||
let def_id = ccx.tcx.map.local_def_id(id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(id);
|
||||
let hint = *ccx.tcx.lookup_repr_hints(def_id).get(0).unwrap_or(&attr::ReprAny);
|
||||
|
||||
if hint != attr::ReprAny && vs.is_empty() {
|
||||
|
@ -1319,7 +1319,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
let def_id = ccx.tcx.map.local_def_id(id);
|
||||
let def_id = ccx.tcx.hir.local_def_id(id);
|
||||
|
||||
let variants = &ccx.tcx.lookup_adt_def(def_id).variants;
|
||||
let mut disr_vals: Vec<ty::Disr> = Vec::new();
|
||||
|
@ -1328,14 +1328,14 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
|||
|
||||
// Check for duplicate discriminant values
|
||||
if let Some(i) = disr_vals.iter().position(|&x| x == current_disr_val) {
|
||||
let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap();
|
||||
let variant_i = ccx.tcx.map.expect_variant(variant_i_node_id);
|
||||
let variant_i_node_id = ccx.tcx.hir.as_local_node_id(variants[i].did).unwrap();
|
||||
let variant_i = ccx.tcx.hir.expect_variant(variant_i_node_id);
|
||||
let i_span = match variant_i.node.disr_expr {
|
||||
Some(expr) => ccx.tcx.map.span(expr.node_id),
|
||||
None => ccx.tcx.map.span(variant_i_node_id)
|
||||
Some(expr) => ccx.tcx.hir.span(expr.node_id),
|
||||
None => ccx.tcx.hir.span(variant_i_node_id)
|
||||
};
|
||||
let span = match v.node.disr_expr {
|
||||
Some(expr) => ccx.tcx.map.span(expr.node_id),
|
||||
Some(expr) => ccx.tcx.hir.span(expr.node_id),
|
||||
None => v.span
|
||||
};
|
||||
struct_span_err!(ccx.tcx.sess, span, E0081,
|
||||
|
@ -1610,7 +1610,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
Some(&t) => t,
|
||||
None => {
|
||||
span_bug!(span, "no type for local variable {}",
|
||||
self.tcx.map.node_to_string(nid));
|
||||
self.tcx.hir.node_to_string(nid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1841,7 +1841,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
None if self.err_count_since_creation() != 0 => 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),
|
||||
self.tag());
|
||||
}
|
||||
}
|
||||
|
@ -2159,7 +2159,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
TypeVariableOrigin::MiscVariable(syntax_pos::DUMMY_SP)),
|
||||
origin_span: syntax_pos::DUMMY_SP,
|
||||
// what do I put here?
|
||||
def_id: self.tcx.map.local_def_id(ast::CRATE_NODE_ID)
|
||||
def_id: self.tcx.hir.local_def_id(ast::CRATE_NODE_ID)
|
||||
});
|
||||
|
||||
// This is to ensure that we elimnate any non-determinism from the error
|
||||
|
@ -2435,7 +2435,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
);
|
||||
self.check_argument_types(sp, &fty.sig.0.inputs()[1..], &expected_arg_tys[..],
|
||||
args_no_rcvr, fty.sig.0.variadic, tuple_arguments,
|
||||
self.tcx.map.span_if_local(def_id));
|
||||
self.tcx.hir.span_if_local(def_id));
|
||||
fty.sig.0.output()
|
||||
}
|
||||
_ => {
|
||||
|
@ -3021,7 +3021,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::TyRawPtr(..) => {
|
||||
err.note(&format!("`{0}` is a native pointer; perhaps you need to deref with \
|
||||
`(*{0}).{1}`",
|
||||
self.tcx.map.node_to_pretty_string(base.id),
|
||||
self.tcx.hir.node_to_pretty_string(base.id),
|
||||
field.node));
|
||||
}
|
||||
_ => {}
|
||||
|
@ -3436,12 +3436,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
self.diverges.set(self.diverges.get() | old_diverges);
|
||||
self.has_errors.set(self.has_errors.get() | old_has_errors);
|
||||
|
||||
debug!("type of {} is...", self.tcx.map.node_to_string(expr.id));
|
||||
debug!("type of {} is...", self.tcx.hir.node_to_string(expr.id));
|
||||
debug!("... {:?}, expected is {:?}", ty, expected);
|
||||
|
||||
// Add adjustments to !-expressions
|
||||
if ty.is_never() {
|
||||
if let Some(hir::map::NodeExpr(node_expr)) = self.tcx.map.find(expr.id) {
|
||||
if let Some(hir::map::NodeExpr(node_expr)) = self.tcx.hir.find(expr.id) {
|
||||
let adj_ty = self.next_diverging_ty_var(
|
||||
TypeVariableOrigin::AdjustmentType(node_expr.span));
|
||||
self.write_adjustment(expr.id, adjustment::Adjustment {
|
||||
|
@ -4370,7 +4370,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
match def {
|
||||
Def::Local(def_id) | Def::Upvar(def_id, ..) => {
|
||||
let nid = self.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let nid = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let ty = self.local_ty(span, nid);
|
||||
let ty = self.normalize_associated_types_in(span, &ty);
|
||||
self.write_ty(node_id, ty);
|
||||
|
|
|
@ -148,7 +148,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
if self.err_count_since_creation() == 0 {
|
||||
// regionck assumes typeck succeeded
|
||||
rcx.visit_fn_body(fn_id, body, self.tcx.map.span(fn_id));
|
||||
rcx.visit_fn_body(fn_id, body, self.tcx.hir.span(fn_id));
|
||||
}
|
||||
|
||||
rcx.free_region_map.relate_free_regions_from_predicates(
|
||||
|
@ -482,7 +482,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn visit_fn(&mut self, _fk: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl,
|
||||
b: hir::BodyId, span: Span, id: ast::NodeId) {
|
||||
let body = self.tcx.map.body(b);
|
||||
let body = self.tcx.hir.body(b);
|
||||
self.visit_fn_body(id, body, span)
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for SeedBorrowKind<'a, 'gcx, 'tcx> {
|
|||
fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprClosure(cc, _, body_id, _) => {
|
||||
let body = self.fcx.tcx.map.body(body_id);
|
||||
let body = self.fcx.tcx.hir.body(body_id);
|
||||
self.visit_body(body);
|
||||
self.check_closure(expr, cc);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> SeedBorrowKind<'a, 'gcx, 'tcx> {
|
|||
self.fcx.tcx.with_freevars(expr.id, |freevars| {
|
||||
for freevar in freevars {
|
||||
let def_id = freevar.def.def_id();
|
||||
let var_node_id = self.fcx.tcx.map.as_local_node_id(def_id).unwrap();
|
||||
let var_node_id = self.fcx.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let upvar_id = ty::UpvarId { var_id: var_node_id,
|
||||
closure_expr_id: expr.id };
|
||||
debug!("seed upvar_id {:?}", upvar_id);
|
||||
|
@ -208,7 +208,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
|
|||
|
||||
// If we are also inferred the closure kind here, update the
|
||||
// main table and process any deferred resolutions.
|
||||
let closure_def_id = self.fcx.tcx.map.local_def_id(id);
|
||||
let closure_def_id = self.fcx.tcx.hir.local_def_id(id);
|
||||
if let Some(&kind) = self.temp_closure_kinds.get(&id) {
|
||||
self.fcx.tables.borrow_mut().closure_kinds.insert(id, kind);
|
||||
debug!("closure_kind({:?}) = {:?}", closure_def_id, kind);
|
||||
|
@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
|
|||
tcx.with_freevars(closure_id, |freevars| {
|
||||
freevars.iter().map(|freevar| {
|
||||
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 freevar_ty = self.fcx.node_ty(var_id);
|
||||
let upvar_id = ty::UpvarId {
|
||||
var_id: var_id,
|
||||
|
@ -500,7 +500,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> {
|
|||
{
|
||||
intravisit::walk_fn(self, fn_kind, decl, body, span, id);
|
||||
|
||||
let body = self.fcx.tcx.map.body(body);
|
||||
let body = self.fcx.tcx.hir.body(body);
|
||||
self.visit_body(body);
|
||||
self.analyze_closure(id, span, body);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
let ccx = self.ccx;
|
||||
debug!("check_item_well_formed(it.id={}, it.name={})",
|
||||
item.id,
|
||||
ccx.tcx.item_path_str(ccx.tcx.map.local_def_id(item.id)));
|
||||
ccx.tcx.item_path_str(ccx.tcx.hir.local_def_id(item.id)));
|
||||
|
||||
match item.node {
|
||||
/// Right now we check that every default trait implementation
|
||||
|
@ -117,7 +117,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
hir::ItemImpl(_, hir::ImplPolarity::Negative, _, Some(_), ..) => {
|
||||
// FIXME(#27579) what amount of WF checking do we need for neg impls?
|
||||
|
||||
let trait_ref = ccx.tcx.impl_trait_ref(ccx.tcx.map.local_def_id(item.id)).unwrap();
|
||||
let trait_ref = ccx.tcx.impl_trait_ref(ccx.tcx.hir.local_def_id(item.id)).unwrap();
|
||||
if !ccx.tcx.trait_has_default_impl(trait_ref.def_id) {
|
||||
error_192(ccx, item.span);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
let free_substs = &fcx.parameter_environment.free_substs;
|
||||
let free_id_outlive = fcx.parameter_environment.free_id_outlive;
|
||||
|
||||
let item = fcx.tcx.associated_item(fcx.tcx.map.local_def_id(item_id));
|
||||
let item = fcx.tcx.associated_item(fcx.tcx.hir.local_def_id(item_id));
|
||||
|
||||
let (mut implied_bounds, self_ty) = match item.container {
|
||||
ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()),
|
||||
|
@ -251,7 +251,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
}
|
||||
|
||||
let free_substs = &fcx.parameter_environment.free_substs;
|
||||
let def_id = fcx.tcx.map.local_def_id(item.id);
|
||||
let def_id = fcx.tcx.hir.local_def_id(item.id);
|
||||
let predicates = fcx.instantiate_bounds(item.span, def_id, free_substs);
|
||||
this.check_where_clauses(fcx, item.span, &predicates);
|
||||
|
||||
|
@ -321,7 +321,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
}
|
||||
|
||||
fn check_trait(&mut self, item: &hir::Item) {
|
||||
let trait_def_id = self.tcx().map.local_def_id(item.id);
|
||||
let trait_def_id = self.tcx().hir.local_def_id(item.id);
|
||||
|
||||
if self.tcx().trait_has_default_impl(trait_def_id) {
|
||||
self.check_auto_trait(trait_def_id, item.span);
|
||||
|
@ -341,7 +341,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
{
|
||||
self.for_item(item).with_fcx(|fcx, this| {
|
||||
let free_substs = &fcx.parameter_environment.free_substs;
|
||||
let def_id = fcx.tcx.map.local_def_id(item.id);
|
||||
let def_id = fcx.tcx.hir.local_def_id(item.id);
|
||||
let ty = fcx.tcx.item_type(def_id);
|
||||
let item_ty = fcx.instantiate_type_scheme(item.span, free_substs, &ty);
|
||||
let bare_fn_ty = match item_ty.sty {
|
||||
|
@ -367,7 +367,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
debug!("check_item_type: {:?}", item);
|
||||
|
||||
self.for_item(item).with_fcx(|fcx, this| {
|
||||
let ty = fcx.tcx.item_type(fcx.tcx.map.local_def_id(item.id));
|
||||
let ty = fcx.tcx.item_type(fcx.tcx.hir.local_def_id(item.id));
|
||||
let item_ty = fcx.instantiate_type_scheme(item.span,
|
||||
&fcx.parameter_environment
|
||||
.free_substs,
|
||||
|
@ -388,7 +388,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
|
||||
self.for_item(item).with_fcx(|fcx, this| {
|
||||
let free_substs = &fcx.parameter_environment.free_substs;
|
||||
let item_def_id = fcx.tcx.map.local_def_id(item.id);
|
||||
let item_def_id = fcx.tcx.hir.local_def_id(item.id);
|
||||
|
||||
match *ast_trait_ref {
|
||||
Some(ref ast_trait_ref) => {
|
||||
|
@ -514,7 +514,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
|
|||
item: &hir::Item,
|
||||
ast_generics: &hir::Generics)
|
||||
{
|
||||
let item_def_id = self.tcx().map.local_def_id(item.id);
|
||||
let item_def_id = self.tcx().hir.local_def_id(item.id);
|
||||
let ty = self.tcx().item_type(item_def_id);
|
||||
if self.tcx().has_error_field(ty) {
|
||||
return;
|
||||
|
@ -644,7 +644,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let fields =
|
||||
struct_def.fields().iter()
|
||||
.map(|field| {
|
||||
let field_ty = self.tcx.item_type(self.tcx.map.local_def_id(field.id));
|
||||
let field_ty = self.tcx.item_type(self.tcx.hir.local_def_id(field.id));
|
||||
let field_ty = self.instantiate_type_scheme(field.span,
|
||||
&self.parameter_environment
|
||||
.free_substs,
|
||||
|
|
|
@ -36,8 +36,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) {
|
||||
assert_eq!(self.writeback_errors.get(), false);
|
||||
|
||||
let item_id = self.tcx.map.body_owner(body.id());
|
||||
let item_def_id = self.tcx.map.local_def_id(item_id);
|
||||
let item_id = self.tcx.hir.body_owner(body.id());
|
||||
let item_def_id = self.tcx.hir.local_def_id(item_id);
|
||||
|
||||
let mut wbcx = WritebackCx::new(self);
|
||||
for arg in &body.arguments {
|
||||
|
@ -209,7 +209,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
|||
MethodCall::expr(e.id));
|
||||
|
||||
if let hir::ExprClosure(_, _, body, _) = e.node {
|
||||
let body = self.fcx.tcx.map.body(body);
|
||||
let body = self.fcx.tcx.hir.body(body);
|
||||
for arg in &body.arguments {
|
||||
self.visit_node_id(ResolvingExpr(e.span), arg.id);
|
||||
}
|
||||
|
@ -281,12 +281,12 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
|||
|
||||
for (&id, closure_ty) in self.fcx.tables.borrow().closure_tys.iter() {
|
||||
let closure_ty = self.resolve(closure_ty, ResolvingClosure(id));
|
||||
let def_id = self.tcx().map.local_def_id(id);
|
||||
let def_id = self.tcx().hir.local_def_id(id);
|
||||
self.tcx().closure_tys.borrow_mut().insert(def_id, closure_ty);
|
||||
}
|
||||
|
||||
for (&id, &closure_kind) in self.fcx.tables.borrow().closure_kinds.iter() {
|
||||
let def_id = self.tcx().map.local_def_id(id);
|
||||
let def_id = self.tcx().hir.local_def_id(id);
|
||||
self.tcx().closure_kinds.borrow_mut().insert(def_id, closure_kind);
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ impl<'a, 'gcx, 'tcx> ResolveReason {
|
|||
ResolvingFnSig(id) |
|
||||
ResolvingFieldTypes(id) |
|
||||
ResolvingTyNode(id) => {
|
||||
tcx.map.span(id)
|
||||
tcx.hir.span(id)
|
||||
}
|
||||
ResolvingAnonTy(did) => {
|
||||
tcx.def_span(did)
|
||||
|
|
|
@ -60,5 +60,5 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for UnusedTraitImportVisitor<'a, 'tcx> {
|
|||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let _task = tcx.dep_graph.in_task(DepNode::UnusedTraitCheck);
|
||||
let mut visitor = UnusedTraitImportVisitor { tcx: tcx };
|
||||
tcx.map.krate().visit_all_item_likes(&mut visitor);
|
||||
tcx.hir.krate().visit_all_item_likes(&mut visitor);
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
_ => {
|
||||
// Destructors only work on nominal types.
|
||||
if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_did) {
|
||||
match tcx.map.find(impl_node_id) {
|
||||
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) {
|
||||
match tcx.hir.find(impl_node_id) {
|
||||
Some(hir_map::NodeItem(item)) => {
|
||||
let span = match item.node {
|
||||
ItemImpl(.., ref ty, _) => ty.span,
|
||||
|
@ -101,7 +101,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
impl_did: DefId) {
|
||||
debug!("visit_implementation_of_copy: impl_did={:?}", impl_did);
|
||||
|
||||
let impl_node_id = if let Some(n) = tcx.map.as_local_node_id(impl_did) {
|
||||
let impl_node_id = if let Some(n) = tcx.hir.as_local_node_id(impl_did) {
|
||||
n
|
||||
} else {
|
||||
debug!("visit_implementation_of_copy(): impl not in this \
|
||||
|
@ -113,7 +113,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
debug!("visit_implementation_of_copy: self_type={:?} (bound)",
|
||||
self_type);
|
||||
|
||||
let span = tcx.map.span(impl_node_id);
|
||||
let span = tcx.hir.span(impl_node_id);
|
||||
let param_env = ParameterEnvironment::for_item(tcx, impl_node_id);
|
||||
let self_type = self_type.subst(tcx, ¶m_env.free_substs);
|
||||
assert!(!self_type.has_escaping_regions());
|
||||
|
@ -124,7 +124,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
match param_env.can_type_implement_copy(tcx, self_type, span) {
|
||||
Ok(()) => {}
|
||||
Err(CopyImplementationError::InfrigingField(field)) => {
|
||||
let item = tcx.map.expect_item(impl_node_id);
|
||||
let item = tcx.hir.expect_item(impl_node_id);
|
||||
let span = if let ItemImpl(.., Some(ref tr), _, _) = item.node {
|
||||
tr.path.span
|
||||
} else {
|
||||
|
@ -141,7 +141,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
.emit()
|
||||
}
|
||||
Err(CopyImplementationError::NotAnAdt) => {
|
||||
let item = tcx.map.expect_item(impl_node_id);
|
||||
let item = tcx.hir.expect_item(impl_node_id);
|
||||
let span = if let ItemImpl(.., ref ty, _) = item.node {
|
||||
ty.span
|
||||
} else {
|
||||
|
@ -180,7 +180,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
};
|
||||
|
||||
let impl_node_id = if let Some(n) = tcx.map.as_local_node_id(impl_did) {
|
||||
let impl_node_id = if let Some(n) = tcx.hir.as_local_node_id(impl_did) {
|
||||
n
|
||||
} else {
|
||||
debug!("visit_implementation_of_coerce_unsized(): impl not \
|
||||
|
@ -195,7 +195,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
source,
|
||||
target);
|
||||
|
||||
let span = tcx.map.span(impl_node_id);
|
||||
let span = tcx.hir.span(impl_node_id);
|
||||
let param_env = ParameterEnvironment::for_item(tcx, impl_node_id);
|
||||
let source = source.subst(tcx, ¶m_env.free_substs);
|
||||
let target = target.subst(tcx, ¶m_env.free_substs);
|
||||
|
@ -281,11 +281,11 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
being coerced, none found");
|
||||
return;
|
||||
} else if diff_fields.len() > 1 {
|
||||
let item = tcx.map.expect_item(impl_node_id);
|
||||
let item = tcx.hir.expect_item(impl_node_id);
|
||||
let span = if let ItemImpl(.., Some(ref t), _, _) = item.node {
|
||||
t.path.span
|
||||
} else {
|
||||
tcx.map.span(impl_node_id)
|
||||
tcx.hir.span(impl_node_id)
|
||||
};
|
||||
|
||||
let mut err = struct_span_err!(tcx.sess,
|
||||
|
|
|
@ -86,7 +86,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
|
||||
fn check_implementation(&self, item: &Item) {
|
||||
let tcx = self.tcx;
|
||||
let impl_did = tcx.map.local_def_id(item.id);
|
||||
let impl_did = tcx.hir.local_def_id(item.id);
|
||||
let self_type = tcx.item_type(impl_did);
|
||||
|
||||
// If there are no traits, then this implementation must have a
|
||||
|
|
|
@ -76,13 +76,13 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
|||
/// to prevent inundating the user with a bunch of similar error
|
||||
/// reports.
|
||||
fn visit_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::ItemImpl(.., None, ref ty, _) => {
|
||||
// For inherent impls, self type must be a nominal type
|
||||
// defined in this crate.
|
||||
debug!("coherence2::orphan check: inherent impl {}",
|
||||
self.tcx.map.node_to_string(item.id));
|
||||
self.tcx.hir.node_to_string(item.id));
|
||||
let self_ty = self.tcx.item_type(def_id);
|
||||
match self_ty.sty {
|
||||
ty::TyAdt(def, _) => {
|
||||
|
@ -249,7 +249,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
|||
hir::ItemImpl(.., Some(_), _, _) => {
|
||||
// "Trait" impl
|
||||
debug!("coherence2::orphan check: trait impl {}",
|
||||
self.tcx.map.node_to_string(item.id));
|
||||
self.tcx.hir.node_to_string(item.id));
|
||||
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
match traits::orphan_check(self.tcx, def_id) {
|
||||
|
@ -374,7 +374,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
|||
hir::ItemDefaultImpl(_, ref item_trait_ref) => {
|
||||
// "Trait" impl
|
||||
debug!("coherence2::orphan check: default trait impl {}",
|
||||
self.tcx.map.node_to_string(item.id));
|
||||
self.tcx.hir.node_to_string(item.id));
|
||||
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
|
||||
if trait_ref.def_id.krate != LOCAL_CRATE {
|
||||
struct_span_err!(self.tcx.sess,
|
||||
|
@ -384,7 +384,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
|||
the crate they're defined in; define a new trait instead")
|
||||
.span_label(item_trait_ref.path.span,
|
||||
&format!("`{}` trait not defined in this crate",
|
||||
self.tcx.map.node_to_pretty_string(item_trait_ref.ref_id)))
|
||||
self.tcx.hir.node_to_pretty_string(item_trait_ref.ref_id)))
|
||||
.emit();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
|||
for &item2 in &impl_items2[..] {
|
||||
if (name, namespace) == name_and_namespace(item2) {
|
||||
let msg = format!("duplicate definitions with name `{}`", name);
|
||||
let node_id = self.tcx.map.as_local_node_id(item1).unwrap();
|
||||
let node_id = self.tcx.hir.as_local_node_id(item1).unwrap();
|
||||
self.tcx.sess.add_lint(lint::builtin::OVERLAPPING_INHERENT_IMPLS,
|
||||
node_id,
|
||||
self.tcx.span_of_impl(item1).unwrap(),
|
||||
|
@ -104,7 +104,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
|
|||
hir::ItemStruct(..) |
|
||||
hir::ItemTrait(..) |
|
||||
hir::ItemUnion(..) => {
|
||||
let type_def_id = self.tcx.map.local_def_id(item.id);
|
||||
let type_def_id = self.tcx.hir.local_def_id(item.id);
|
||||
self.check_for_overlapping_inherent_impls(type_def_id);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
|
|||
// look for another default impl; note that due to the
|
||||
// general orphan/coherence rules, it must always be
|
||||
// in this crate.
|
||||
let impl_def_id = self.tcx.map.local_def_id(item.id);
|
||||
let impl_def_id = self.tcx.hir.local_def_id(item.id);
|
||||
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
|
||||
let prev_default_impl = self.default_impls.insert(trait_ref.def_id, item.id);
|
||||
|
@ -124,14 +124,14 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
|
|||
`{}`:",
|
||||
trait_ref);
|
||||
err.span_note(self.tcx
|
||||
.span_of_impl(self.tcx.map.local_def_id(prev_id))
|
||||
.span_of_impl(self.tcx.hir.local_def_id(prev_id))
|
||||
.unwrap(),
|
||||
"redundant implementation is here:");
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
hir::ItemImpl(.., Some(_), _, _) => {
|
||||
let impl_def_id = self.tcx.map.local_def_id(item.id);
|
||||
let impl_def_id = self.tcx.hir.local_def_id(item.id);
|
||||
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue