Skip to content

Commit 401329e

Browse files
committed
HirIdification: remove all NodeIds from borrowck
1 parent 7e1914f commit 401329e

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

src/librustc_borrowck/borrowck/gather_loans/lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
//! does not exceed the lifetime of the value being borrowed.
33
44
use crate::borrowck::*;
5+
use rustc::hir::HirId;
56
use rustc::middle::expr_use_visitor as euv;
67
use rustc::middle::mem_categorization as mc;
78
use rustc::middle::mem_categorization::Categorization;
89
use rustc::middle::region;
910
use rustc::ty;
1011

11-
use syntax::ast;
1212
use syntax_pos::Span;
1313
use log::debug;
1414

@@ -51,7 +51,7 @@ struct GuaranteeLifetimeContext<'a, 'tcx: 'a> {
5151
}
5252

5353
impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
54-
fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option<ast::NodeId>) -> R {
54+
fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option<HirId>) -> R {
5555
//! Main routine. Walks down `cmt` until we find the
5656
//! "guarantor". Reports an error if `self.loan_region` is
5757
//! larger than scope of `cmt`.

src/librustc_borrowck/borrowck/gather_loans/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc::middle::mem_categorization::Categorization;
1414
use rustc::middle::region;
1515
use rustc::ty::{self, TyCtxt};
1616

17-
use syntax::ast;
1817
use syntax_pos::Span;
1918
use rustc::hir;
2019
use log::debug;
@@ -141,8 +140,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
141140
assignee_cmt: &mc::cmt_<'tcx>,
142141
_: euv::MutateMode)
143142
{
144-
let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id);
145-
self.guarantee_assignment_valid(node_id,
143+
self.guarantee_assignment_valid(assignment_id,
146144
assignment_span,
147145
assignee_cmt);
148146
}
@@ -238,7 +236,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
238236

239237
/// Guarantees that `cmt` is assignable, or reports an error.
240238
fn guarantee_assignment_valid(&mut self,
241-
assignment_id: ast::NodeId,
239+
assignment_id: hir::HirId,
242240
assignment_span: Span,
243241
cmt: &mc::cmt_<'tcx>) {
244242

@@ -272,8 +270,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
272270
self.mark_loan_path_as_mutated(&lp);
273271
}
274272
gather_moves::gather_assignment(self.bccx, &self.move_data,
275-
self.bccx.tcx.hir().node_to_hir_id(assignment_id)
276-
.local_id,
273+
assignment_id.local_id,
277274
assignment_span,
278275
lp);
279276
}

src/librustc_borrowck/borrowck/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use std::fmt;
3434
use std::rc::Rc;
3535
use rustc_data_structures::sync::Lrc;
3636
use std::hash::{Hash, Hasher};
37-
use syntax::ast;
3837
use syntax_pos::{MultiSpan, Span};
3938
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
4039
use log::debug;
@@ -399,12 +398,12 @@ pub enum LoanPathElem<'tcx> {
399398
}
400399

401400
fn closure_to_block(closure_id: LocalDefId,
402-
tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId {
401+
tcx: TyCtxt<'_, '_, '_>) -> HirId {
403402
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
404403
match tcx.hir().get(closure_id) {
405404
Node::Expr(expr) => match expr.node {
406405
hir::ExprKind::Closure(.., body_id, _, _) => {
407-
tcx.hir().hir_to_node_id(body_id.hir_id)
406+
body_id.hir_id
408407
}
409408
_ => {
410409
bug!("encountered non-closure id: {}", closure_id)
@@ -422,8 +421,7 @@ impl<'a, 'tcx> LoanPath<'tcx> {
422421
}
423422
LpUpvar(upvar_id) => {
424423
let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx);
425-
let hir_id = bccx.tcx.hir().node_to_hir_id(block_id);
426-
region::Scope { id: hir_id.local_id, data: region::ScopeData::Node }
424+
region::Scope { id: block_id.local_id, data: region::ScopeData::Node }
427425
}
428426
LpDowncast(ref base, _) |
429427
LpExtend(ref base, ..) => base.kill_scope(bccx),

0 commit comments

Comments
 (0)