Skip to content

Commit

Permalink
in which some node_to_hir_id calls become hir_id field accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Jul 2, 2018
1 parent 2a8ad09 commit 701e900
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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(|| {
Expand Down
9 changes: 3 additions & 6 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _))
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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,
})
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,8 +1651,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 701e900

Please sign in to comment.