about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2019-02-15 12:16:36 +0100
committerljedrz <ljedrz@gmail.com>2019-02-20 11:00:43 +0100
commitf5bba2c6d7b7fe28a33d709e5f776fd70b6f4edc (patch)
treecb21985ae8486faed4268cb2aaec22e1c9fc3d5f
parent36fffa81969fbefa64974da838590e06dc0b3faa (diff)
downloadrust-f5bba2c6d7b7fe28a33d709e5f776fd70b6f4edc.tar.gz
rust-f5bba2c6d7b7fe28a33d709e5f776fd70b6f4edc.zip
HirIdification: change some NodeId to HirId calls
-rw-r--r--src/librustc_borrowck/borrowck/gather_loans/move_error.rs3
-rw-r--r--src/librustc_borrowck/borrowck/mod.rs26
-rw-r--r--src/librustc_privacy/lib.rs4
-rw-r--r--src/librustdoc/clean/inline.rs8
-rw-r--r--src/librustdoc/clean/mod.rs4
5 files changed, 22 insertions, 23 deletions
diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
index 622dd8e891a..9a00c43be3f 100644
--- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
+++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs
@@ -88,8 +88,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
             }
         }
         if let NoteClosureEnv(upvar_id) = error.move_from.note {
-            let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
-            err.span_label(bccx.tcx.hir().span(var_node_id),
+            err.span_label(bccx.tcx.hir().span_by_hir_id(upvar_id.var_path.hir_id),
                            "captured outer variable");
         }
         err.emit();
diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs
index 307df163866..31189a71bba 100644
--- a/src/librustc_borrowck/borrowck/mod.rs
+++ b/src/librustc_borrowck/borrowck/mod.rs
@@ -703,20 +703,20 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
 
         // Get type of value and span where it was previously
         // moved.
-        let node_id = self.tcx.hir().hir_to_node_id(hir::HirId {
+        let hir_id = hir::HirId {
             owner: self.body.value.hir_id.owner,
             local_id: the_move.id
-        });
+        };
         let (move_span, move_note) = match the_move.kind {
             move_data::Declared => {
                 unreachable!();
             }
 
             move_data::MoveExpr |
-            move_data::MovePat => (self.tcx.hir().span(node_id), ""),
+            move_data::MovePat => (self.tcx.hir().span_by_hir_id(hir_id), ""),
 
             move_data::Captured =>
-                (match self.tcx.hir().expect_expr(node_id).node {
+                (match self.tcx.hir().expect_expr_by_hir_id(hir_id).node {
                     hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span,
                     ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
                                   the_move.id, r),
@@ -828,8 +828,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                     MutabilityViolation => {
                         let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
                         if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
-                            let node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
-                            let sp = self.tcx.hir().span(node_id);
+                            let hir_id = upvar_id.var_path.hir_id;
+                            let sp = self.tcx.hir().span_by_hir_id(hir_id);
                             let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
                                                   environment for modifications";
                             match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
@@ -1120,8 +1120,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                 } else {
                     "consider changing this closure to take self by mutable reference"
                 };
-                let node_id = self.tcx.hir().local_def_id_to_node_id(id);
-                let help_span = self.tcx.hir().span(node_id);
+                let hir_id = self.tcx.hir().local_def_id_to_hir_id(id);
+                let help_span = self.tcx.hir().span_by_hir_id(hir_id);
                 self.cannot_act_on_capture_in_sharable_fn(span,
                                                           prefix,
                                                           (help_span, help_msg),
@@ -1362,9 +1362,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                     _ => bug!()
                 };
                 if *kind == ty::ClosureKind::Fn {
-                    let closure_node_id =
-                        self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id);
-                    db.span_help(self.tcx.hir().span(closure_node_id),
+                    let closure_hir_id =
+                        self.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id);
+                    db.span_help(self.tcx.hir().span_by_hir_id(closure_hir_id),
                                  "consider changing this closure to take \
                                   self by mutable reference");
                 }
@@ -1397,8 +1397,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
                                       loan_path: &LoanPath<'tcx>,
                                       out: &mut String) {
         match loan_path.kind {
-            LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id}, closure_expr_id: _ }) => {
-                out.push_str(&self.tcx.hir().name(self.tcx.hir().hir_to_node_id(id)).as_str());
+            LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
+                out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
             }
             LpVar(id) => {
                 out.push_str(&self.tcx.hir().name(id).as_str());
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index 41557035f2c..894cb4cf11b 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -454,8 +454,8 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
         if let Some([module, segment]) = segments.rchunks_exact(2).next() {
             if let Some(item) = module.def
                 .and_then(|def| def.mod_def_id())
-                .and_then(|def_id| self.tcx.hir().as_local_node_id(def_id))
-                .map(|module_node_id| self.tcx.hir().expect_item(module_node_id))
+                .and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
+                .map(|module_hir_id| self.tcx.hir().expect_item_by_hir_id(module_hir_id))
              {
                 if let hir::ItemKind::Mod(m) = &item.node {
                     for item_id in m.item_ids.as_ref() {
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 8c8151e1e95..18155169d9a 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -296,8 +296,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
         }
     }
 
-    let for_ = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
-        match tcx.hir().expect_item(nodeid).node {
+    let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
+        match tcx.hir().expect_item_by_hir_id(hir_id).node {
             hir::ItemKind::Impl(.., ref t, _) => {
                 t.clean(cx)
             }
@@ -318,8 +318,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
     }
 
     let predicates = tcx.predicates_of(did);
-    let (trait_items, generics) = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
-        match tcx.hir().expect_item(nodeid).node {
+    let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
+        match tcx.hir().expect_item_by_hir_id(hir_id).node {
             hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
                 (
                     item_ids.iter()
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index ea9034ae3a1..fa921535a70 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2562,9 +2562,9 @@ impl Clean<Type> for hir::Ty {
                 let mut alias = None;
                 if let Def::TyAlias(def_id) = path.def {
                     // Substitute private type aliases
-                    if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
+                    if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
                         if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
-                            alias = Some(&cx.tcx.hir().expect_item(node_id).node);
+                            alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
                         }
                     }
                 };