HirIdification: miscellaneous bits

This commit is contained in:
ljedrz 2019-06-24 10:17:04 +02:00
parent d82a12f64f
commit 87438a163e
2 changed files with 5 additions and 7 deletions

View File

@ -110,7 +110,7 @@ use std::{fmt, u32};
use std::io::prelude::*;
use std::io;
use std::rc::Rc;
use syntax::ast::{self, NodeId};
use syntax::ast;
use syntax::ptr::P;
use syntax::symbol::{kw, sym};
use syntax_pos::Span;
@ -1327,12 +1327,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
fn access_var(&mut self, hir_id: HirId, nid: NodeId, succ: LiveNode, acc: u32, span: Span)
fn access_var(&mut self, hir_id: HirId, var_hid: HirId, succ: LiveNode, acc: u32, span: Span)
-> LiveNode {
let ln = self.live_node(hir_id, span);
if acc != 0 {
self.init_from_succ(ln, succ);
let var_hid = self.ir.tcx.hir().node_to_hir_id(nid);
let var = self.variable(var_hid, span);
self.acc(ln, var, acc);
}
@ -1345,8 +1344,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
Res::Local(hid) => {
let upvars = self.ir.tcx.upvars(self.ir.body_owner);
if !upvars.map_or(false, |upvars| upvars.contains_key(&hid)) {
let nid = self.ir.tcx.hir().hir_to_node_id(hid);
self.access_var(hir_id, nid, succ, acc, path.span)
self.access_var(hir_id, hid, succ, acc, path.span)
} else {
succ
}

View File

@ -1,6 +1,6 @@
use std::mem;
use smallvec::SmallVec;
use syntax::ast::CRATE_NODE_ID;
use rustc::hir::CRATE_HIR_ID;
use crate::ty::context::TyCtxt;
use crate::ty::{DefId, DefIdTree};
@ -33,7 +33,7 @@ impl<'tcx> DefIdForest {
/// crate.
#[inline]
pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest {
let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID);
let crate_id = tcx.hir().local_def_id_from_hir_id(CRATE_HIR_ID);
DefIdForest::from_id(crate_id)
}