Skip to content

Commit f5bba2c

Browse files
committed
HirIdification: change some NodeId to HirId calls
1 parent 36fffa8 commit f5bba2c

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

src/librustc_borrowck/borrowck/gather_loans/move_error.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
8888
}
8989
}
9090
if let NoteClosureEnv(upvar_id) = error.move_from.note {
91-
let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
92-
err.span_label(bccx.tcx.hir().span(var_node_id),
91+
err.span_label(bccx.tcx.hir().span_by_hir_id(upvar_id.var_path.hir_id),
9392
"captured outer variable");
9493
}
9594
err.emit();

src/librustc_borrowck/borrowck/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -703,20 +703,20 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
703703

704704
// Get type of value and span where it was previously
705705
// moved.
706-
let node_id = self.tcx.hir().hir_to_node_id(hir::HirId {
706+
let hir_id = hir::HirId {
707707
owner: self.body.value.hir_id.owner,
708708
local_id: the_move.id
709-
});
709+
};
710710
let (move_span, move_note) = match the_move.kind {
711711
move_data::Declared => {
712712
unreachable!();
713713
}
714714

715715
move_data::MoveExpr |
716-
move_data::MovePat => (self.tcx.hir().span(node_id), ""),
716+
move_data::MovePat => (self.tcx.hir().span_by_hir_id(hir_id), ""),
717717

718718
move_data::Captured =>
719-
(match self.tcx.hir().expect_expr(node_id).node {
719+
(match self.tcx.hir().expect_expr_by_hir_id(hir_id).node {
720720
hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span,
721721
ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
722722
the_move.id, r),
@@ -828,8 +828,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
828828
MutabilityViolation => {
829829
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
830830
if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
831-
let node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
832-
let sp = self.tcx.hir().span(node_id);
831+
let hir_id = upvar_id.var_path.hir_id;
832+
let sp = self.tcx.hir().span_by_hir_id(hir_id);
833833
let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
834834
environment for modifications";
835835
match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
@@ -1120,8 +1120,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
11201120
} else {
11211121
"consider changing this closure to take self by mutable reference"
11221122
};
1123-
let node_id = self.tcx.hir().local_def_id_to_node_id(id);
1124-
let help_span = self.tcx.hir().span(node_id);
1123+
let hir_id = self.tcx.hir().local_def_id_to_hir_id(id);
1124+
let help_span = self.tcx.hir().span_by_hir_id(hir_id);
11251125
self.cannot_act_on_capture_in_sharable_fn(span,
11261126
prefix,
11271127
(help_span, help_msg),
@@ -1362,9 +1362,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
13621362
_ => bug!()
13631363
};
13641364
if *kind == ty::ClosureKind::Fn {
1365-
let closure_node_id =
1366-
self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id);
1367-
db.span_help(self.tcx.hir().span(closure_node_id),
1365+
let closure_hir_id =
1366+
self.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id);
1367+
db.span_help(self.tcx.hir().span_by_hir_id(closure_hir_id),
13681368
"consider changing this closure to take \
13691369
self by mutable reference");
13701370
}
@@ -1397,8 +1397,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
13971397
loan_path: &LoanPath<'tcx>,
13981398
out: &mut String) {
13991399
match loan_path.kind {
1400-
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id}, closure_expr_id: _ }) => {
1401-
out.push_str(&self.tcx.hir().name(self.tcx.hir().hir_to_node_id(id)).as_str());
1400+
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
1401+
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
14021402
}
14031403
LpVar(id) => {
14041404
out.push_str(&self.tcx.hir().name(id).as_str());

src/librustc_privacy/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
454454
if let Some([module, segment]) = segments.rchunks_exact(2).next() {
455455
if let Some(item) = module.def
456456
.and_then(|def| def.mod_def_id())
457-
.and_then(|def_id| self.tcx.hir().as_local_node_id(def_id))
458-
.map(|module_node_id| self.tcx.hir().expect_item(module_node_id))
457+
.and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
458+
.map(|module_hir_id| self.tcx.hir().expect_item_by_hir_id(module_hir_id))
459459
{
460460
if let hir::ItemKind::Mod(m) = &item.node {
461461
for item_id in m.item_ids.as_ref() {

src/librustdoc/clean/inline.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
296296
}
297297
}
298298

299-
let for_ = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
300-
match tcx.hir().expect_item(nodeid).node {
299+
let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
300+
match tcx.hir().expect_item_by_hir_id(hir_id).node {
301301
hir::ItemKind::Impl(.., ref t, _) => {
302302
t.clean(cx)
303303
}
@@ -318,8 +318,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
318318
}
319319

320320
let predicates = tcx.predicates_of(did);
321-
let (trait_items, generics) = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
322-
match tcx.hir().expect_item(nodeid).node {
321+
let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
322+
match tcx.hir().expect_item_by_hir_id(hir_id).node {
323323
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
324324
(
325325
item_ids.iter()

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2562,9 +2562,9 @@ impl Clean<Type> for hir::Ty {
25622562
let mut alias = None;
25632563
if let Def::TyAlias(def_id) = path.def {
25642564
// Substitute private type aliases
2565-
if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
2565+
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
25662566
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
2567-
alias = Some(&cx.tcx.hir().expect_item(node_id).node);
2567+
alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
25682568
}
25692569
}
25702570
};

0 commit comments

Comments
 (0)