Skip to content

Commit

Permalink
HirIdification: remove all NodeIds from borrowck
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Mar 10, 2019
1 parent 7e1914f commit 401329e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
Expand Up @@ -2,13 +2,13 @@
//! does not exceed the lifetime of the value being borrowed.

use crate::borrowck::*;
use rustc::hir::HirId;
use rustc::middle::expr_use_visitor as euv;
use rustc::middle::mem_categorization as mc;
use rustc::middle::mem_categorization::Categorization;
use rustc::middle::region;
use rustc::ty;

use syntax::ast;
use syntax_pos::Span;
use log::debug;

Expand Down Expand Up @@ -51,7 +51,7 @@ struct GuaranteeLifetimeContext<'a, 'tcx: 'a> {
}

impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option<ast::NodeId>) -> R {
fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option<HirId>) -> R {
//! Main routine. Walks down `cmt` until we find the
//! "guarantor". Reports an error if `self.loan_region` is
//! larger than scope of `cmt`.
Expand Down
9 changes: 3 additions & 6 deletions src/librustc_borrowck/borrowck/gather_loans/mod.rs
Expand Up @@ -14,7 +14,6 @@ use rustc::middle::mem_categorization::Categorization;
use rustc::middle::region;
use rustc::ty::{self, TyCtxt};

use syntax::ast;
use syntax_pos::Span;
use rustc::hir;
use log::debug;
Expand Down Expand Up @@ -141,8 +140,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
assignee_cmt: &mc::cmt_<'tcx>,
_: euv::MutateMode)
{
let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id);
self.guarantee_assignment_valid(node_id,
self.guarantee_assignment_valid(assignment_id,
assignment_span,
assignee_cmt);
}
Expand Down Expand Up @@ -238,7 +236,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {

/// Guarantees that `cmt` is assignable, or reports an error.
fn guarantee_assignment_valid(&mut self,
assignment_id: ast::NodeId,
assignment_id: hir::HirId,
assignment_span: Span,
cmt: &mc::cmt_<'tcx>) {

Expand Down Expand Up @@ -272,8 +270,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
self.mark_loan_path_as_mutated(&lp);
}
gather_moves::gather_assignment(self.bccx, &self.move_data,
self.bccx.tcx.hir().node_to_hir_id(assignment_id)
.local_id,
assignment_id.local_id,
assignment_span,
lp);
}
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_borrowck/borrowck/mod.rs
Expand Up @@ -34,7 +34,6 @@ use std::fmt;
use std::rc::Rc;
use rustc_data_structures::sync::Lrc;
use std::hash::{Hash, Hasher};
use syntax::ast;
use syntax_pos::{MultiSpan, Span};
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use log::debug;
Expand Down Expand Up @@ -399,12 +398,12 @@ pub enum LoanPathElem<'tcx> {
}

fn closure_to_block(closure_id: LocalDefId,
tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId {
tcx: TyCtxt<'_, '_, '_>) -> HirId {
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
match tcx.hir().get(closure_id) {
Node::Expr(expr) => match expr.node {
hir::ExprKind::Closure(.., body_id, _, _) => {
tcx.hir().hir_to_node_id(body_id.hir_id)
body_id.hir_id
}
_ => {
bug!("encountered non-closure id: {}", closure_id)
Expand All @@ -422,8 +421,7 @@ impl<'a, 'tcx> LoanPath<'tcx> {
}
LpUpvar(upvar_id) => {
let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx);
let hir_id = bccx.tcx.hir().node_to_hir_id(block_id);
region::Scope { id: hir_id.local_id, data: region::ScopeData::Node }
region::Scope { id: block_id.local_id, data: region::ScopeData::Node }
}
LpDowncast(ref base, _) |
LpExtend(ref base, ..) => base.kill_scope(bccx),
Expand Down

0 comments on commit 401329e

Please sign in to comment.