Skip to content

Commit

Permalink
cleanup: don't use node_to_hir_id where unneeded
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Feb 3, 2019
1 parent ec7ecb3 commit 28fec68
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/librustc/cfg/construct.rs
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/region.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/block.rs
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -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
}
Expand Down Expand Up @@ -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(|| {
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/collect.rs
Expand Up @@ -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 => {}
Expand All @@ -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);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -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, _)) |
Expand Down

0 comments on commit 28fec68

Please sign in to comment.