cleanup: don't use node_to_hir_id where unneeded

This commit is contained in:
ljedrz 2019-02-03 08:51:50 +01:00
parent ec7ecb3076
commit 28fec683f5
7 changed files with 10 additions and 17 deletions

View File

@ -99,7 +99,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
let hir_id = self.tcx.hir().node_to_hir_id(stmt.id);
let exit = match stmt.node {
hir::StmtKind::Local(ref local) => {
let init_exit = self.opt_expr(&local.init, pred);
@ -113,7 +112,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.expr(&expr, pred)
}
};
self.add_ast_node(hir_id.local_id, &[exit])
self.add_ast_node(stmt.hir_id.local_id, &[exit])
}
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {

View File

@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
hir::TyKind::Rptr(ref lifetime, _) => {
// the lifetime of the TyRptr
let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
let hir_id = lifetime.hir_id;
match (self.tcx.named_region(hir_id), self.bound_region) {
// Find the index of the anonymous region that was part of the
// error. We will then search the function parameters for a bound
@ -221,8 +221,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
}
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
match (self.tcx.named_region(hir_id), self.bound_region) {
match (self.tcx.named_region(lifetime.hir_id), self.bound_region) {
// the lifetime of the TyPath!
(Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
if debruijn_index == self.current_index && anon_index == br_index {

View File

@ -840,7 +840,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &
}
fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
let stmt_id = visitor.tcx.hir().node_to_hir_id(stmt.id).local_id;
let stmt_id = stmt.hir_id.local_id;
debug!("resolve_stmt(stmt.id={:?})", stmt_id);
// Every statement will clean up the temporaries created during

View File

@ -46,7 +46,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
-> Vec<StmtRef<'tcx>> {
let mut result = vec![];
for (index, stmt) in stmts.iter().enumerate() {
let hir_id = cx.tcx.hir().node_to_hir_id(stmt.id);
let hir_id = stmt.hir_id;
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
let stmt_span = StatementSpan(cx.tcx.hir().span(stmt.id));
match stmt.node {

View File

@ -114,8 +114,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
tcx.hir().name(tcx.hir().as_local_node_id(def_id).unwrap()).as_interned_str()
};
let hir_id = tcx.hir().node_to_hir_id(lifetime.id);
let r = match tcx.named_region(hir_id) {
let r = match tcx.named_region(lifetime.hir_id) {
Some(rl::Region::Static) => {
tcx.types.re_static
}
@ -1145,8 +1144,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
self.ast_region_to_region(lifetime, None)
} else {
self.compute_object_lifetime_bound(span, existential_predicates).unwrap_or_else(|| {
let hir_id = tcx.hir().node_to_hir_id(lifetime.id);
if tcx.named_region(hir_id).is_some() {
if tcx.named_region(lifetime.hir_id).is_some() {
self.ast_region_to_region(lifetime, None)
} else {
self.re_infer(span, None).unwrap_or_else(|| {

View File

@ -814,8 +814,7 @@ fn has_late_bound_regions<'a, 'tcx>(
return;
}
let hir_id = self.tcx.hir().node_to_hir_id(lt.id);
match self.tcx.named_region(hir_id) {
match self.tcx.named_region(lt.hir_id) {
Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {}
Some(rl::Region::LateBound(debruijn, _, _))
| Some(rl::Region::LateBoundAnon(debruijn, _)) if debruijn < self.outer_index => {}
@ -841,8 +840,7 @@ fn has_late_bound_regions<'a, 'tcx>(
};
for param in &generics.params {
if let GenericParamKind::Lifetime { .. } = param.kind {
let hir_id = tcx.hir().node_to_hir_id(param.id);
if tcx.is_late_bound(hir_id) {
if tcx.is_late_bound(param.hir_id) {
return Some(param.span);
}
}

View File

@ -1210,8 +1210,7 @@ impl Lifetime {
impl Clean<Lifetime> for hir::Lifetime {
fn clean(&self, cx: &DocContext) -> Lifetime {
if self.id != ast::DUMMY_NODE_ID {
let hir_id = cx.tcx.hir().node_to_hir_id(self.id);
let def = cx.tcx.named_region(hir_id);
let def = cx.tcx.named_region(self.hir_id);
match def {
Some(rl::Region::EarlyBound(_, node_id, _)) |
Some(rl::Region::LateBound(_, node_id, _)) |