Skip to content

Commit 28fec68

Browse files
committed
cleanup: don't use node_to_hir_id where unneeded
1 parent ec7ecb3 commit 28fec68

File tree

7 files changed

+10
-17
lines changed

7 files changed

+10
-17
lines changed

src/librustc/cfg/construct.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
9999
}
100100

101101
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
102-
let hir_id = self.tcx.hir().node_to_hir_id(stmt.id);
103102
let exit = match stmt.node {
104103
hir::StmtKind::Local(ref local) => {
105104
let init_exit = self.opt_expr(&local.init, pred);
@@ -113,7 +112,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
113112
self.expr(&expr, pred)
114113
}
115114
};
116-
self.add_ast_node(hir_id.local_id, &[exit])
115+
self.add_ast_node(stmt.hir_id.local_id, &[exit])
117116
}
118117

119118
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {

src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
114114

115115
hir::TyKind::Rptr(ref lifetime, _) => {
116116
// the lifetime of the TyRptr
117-
let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
117+
let hir_id = lifetime.hir_id;
118118
match (self.tcx.named_region(hir_id), self.bound_region) {
119119
// Find the index of the anonymous region that was part of the
120120
// 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> {
221221
}
222222

223223
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
224-
let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
225-
match (self.tcx.named_region(hir_id), self.bound_region) {
224+
match (self.tcx.named_region(lifetime.hir_id), self.bound_region) {
226225
// the lifetime of the TyPath!
227226
(Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
228227
if debruijn_index == self.current_index && anon_index == br_index {

src/librustc/middle/region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &
840840
}
841841

842842
fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
843-
let stmt_id = visitor.tcx.hir().node_to_hir_id(stmt.id).local_id;
843+
let stmt_id = stmt.hir_id.local_id;
844844
debug!("resolve_stmt(stmt.id={:?})", stmt_id);
845845

846846
// Every statement will clean up the temporaries created during

src/librustc_mir/hair/cx/block.rs

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

src/librustc_typeck/astconv.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
114114
tcx.hir().name(tcx.hir().as_local_node_id(def_id).unwrap()).as_interned_str()
115115
};
116116

117-
let hir_id = tcx.hir().node_to_hir_id(lifetime.id);
118-
let r = match tcx.named_region(hir_id) {
117+
let r = match tcx.named_region(lifetime.hir_id) {
119118
Some(rl::Region::Static) => {
120119
tcx.types.re_static
121120
}
@@ -1145,8 +1144,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
11451144
self.ast_region_to_region(lifetime, None)
11461145
} else {
11471146
self.compute_object_lifetime_bound(span, existential_predicates).unwrap_or_else(|| {
1148-
let hir_id = tcx.hir().node_to_hir_id(lifetime.id);
1149-
if tcx.named_region(hir_id).is_some() {
1147+
if tcx.named_region(lifetime.hir_id).is_some() {
11501148
self.ast_region_to_region(lifetime, None)
11511149
} else {
11521150
self.re_infer(span, None).unwrap_or_else(|| {

src/librustc_typeck/collect.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,7 @@ fn has_late_bound_regions<'a, 'tcx>(
814814
return;
815815
}
816816

817-
let hir_id = self.tcx.hir().node_to_hir_id(lt.id);
818-
match self.tcx.named_region(hir_id) {
817+
match self.tcx.named_region(lt.hir_id) {
819818
Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {}
820819
Some(rl::Region::LateBound(debruijn, _, _))
821820
| Some(rl::Region::LateBoundAnon(debruijn, _)) if debruijn < self.outer_index => {}
@@ -841,8 +840,7 @@ fn has_late_bound_regions<'a, 'tcx>(
841840
};
842841
for param in &generics.params {
843842
if let GenericParamKind::Lifetime { .. } = param.kind {
844-
let hir_id = tcx.hir().node_to_hir_id(param.id);
845-
if tcx.is_late_bound(hir_id) {
843+
if tcx.is_late_bound(param.hir_id) {
846844
return Some(param.span);
847845
}
848846
}

src/librustdoc/clean/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,7 @@ impl Lifetime {
12101210
impl Clean<Lifetime> for hir::Lifetime {
12111211
fn clean(&self, cx: &DocContext) -> Lifetime {
12121212
if self.id != ast::DUMMY_NODE_ID {
1213-
let hir_id = cx.tcx.hir().node_to_hir_id(self.id);
1214-
let def = cx.tcx.named_region(hir_id);
1213+
let def = cx.tcx.named_region(self.hir_id);
12151214
match def {
12161215
Some(rl::Region::EarlyBound(_, node_id, _)) |
12171216
Some(rl::Region::LateBound(_, node_id, _)) |

0 commit comments

Comments
 (0)