From 701e900f46a7535b77d7bd42607963b95da229f7 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sat, 2 Jun 2018 00:23:35 -0700 Subject: [PATCH] in which some `node_to_hir_id` calls become `hir_id` field accesses For #50928. --- .../error_reporting/nice_region_error/find_anon_type.rs | 6 ++---- src/librustc/middle/region.rs | 2 +- src/librustc_typeck/astconv.rs | 6 ++---- src/librustc_typeck/collect.rs | 9 +++------ src/librustdoc/clean/mod.rs | 3 +-- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index b148a7401f8ba..e06ebfad22112 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -124,8 +124,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { hir::TyRptr(ref lifetime, _) => { // the lifetime of the TyRptr - 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) { // Find the index of the anonymous region that was part of the // error. We will then search the function parameters for a bound // region at the right depth with the same index @@ -231,8 +230,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 { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index c7249c0aa20c8..4b79df3c3ae2b 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -909,7 +909,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.node.id()).local_id; + let stmt_id = stmt.node.hir_id().local_id; debug!("resolve_stmt(stmt.id={:?})", stmt_id); // Every statement will clean up the temporaries created during diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 762dc5d26f5a4..ea4f0e364a4c1 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -109,8 +109,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> 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 } @@ -738,8 +737,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> 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(|| { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ffe269c039b70..576cb882905f5 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -722,8 +722,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) { if self.has_late_bound_regions.is_some() { 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, _)) @@ -750,8 +749,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, for param in &generics.params { match param.kind { GenericParamKind::Lifetime { .. } => { - 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); } } @@ -1303,8 +1301,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>( { generics.params.iter().filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => { - let hir_id = tcx.hir.node_to_hir_id(param.id); - !tcx.is_late_bound(hir_id) + !tcx.is_late_bound(param.hir_id) } _ => false, }) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 65babbffffef1..05ef67ca38e2e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1651,8 +1651,7 @@ impl Lifetime { impl Clean 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, _)) |