Skip to content

Commit d08bd72

Browse files
committed
HIR: rename get_parent_node_by_hir_id to get_parent_node
1 parent c7e1f4d commit d08bd72

File tree

21 files changed

+47
-47
lines changed

21 files changed

+47
-47
lines changed

src/librustc/hir/map/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> Code<'a> {
8787
match map.get(id) {
8888
map::Node::Block(_) => {
8989
// Use the parent, hopefully an expression node.
90-
Code::from_node(map, map.get_parent_node_by_hir_id(id))
90+
Code::from_node(map, map.get_parent_node(id))
9191
}
9292
map::Node::Expr(expr) => Some(Code::Expr(expr)),
9393
node => FnLikeNode::from_node(node).map(Code::FnLike)

src/librustc/hir/map/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
347347
if variant_data.ctor_hir_id().is_none() {
348348
return None;
349349
}
350-
let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(hir_id)) {
350+
let ctor_of = match self.find_by_hir_id(self.get_parent_node(hir_id)) {
351351
Some(Node::Item(..)) => def::CtorOf::Struct,
352352
Some(Node::Variant(..)) => def::CtorOf::Variant,
353353
_ => unreachable!(),
@@ -424,7 +424,7 @@ impl<'hir> Map<'hir> {
424424
/// which this is the body of, i.e., a `fn`, `const` or `static`
425425
/// item (possibly associated), a closure, or a `hir::AnonConst`.
426426
pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> HirId {
427-
let parent = self.get_parent_node_by_hir_id(hir_id);
427+
let parent = self.get_parent_node(hir_id);
428428
assert!(self.lookup(parent).map_or(false, |e| e.is_body_owner(hir_id)));
429429
parent
430430
}
@@ -485,7 +485,7 @@ impl<'hir> Map<'hir> {
485485
match self.get(id) {
486486
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
487487
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
488-
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
488+
Node::GenericParam(_) => self.get_parent_node(id),
489489
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
490490
}
491491
}
@@ -625,7 +625,7 @@ impl<'hir> Map<'hir> {
625625
/// never appear as the parent node. Thus, you can always walk the parent nodes
626626
/// from a node to the root of the HIR (unless you get back the same ID here,
627627
/// which can happen if the ID is not in the map itself or is just weird).
628-
pub fn get_parent_node_by_hir_id(&self, hir_id: HirId) -> HirId {
628+
pub fn get_parent_node(&self, hir_id: HirId) -> HirId {
629629
if self.dep_graph.is_fully_enabled() {
630630
let hir_id_owner = hir_id.owner;
631631
let def_path_hash = self.definitions.def_path_hash(hir_id_owner);
@@ -644,7 +644,7 @@ impl<'hir> Map<'hir> {
644644
Some(Node::Binding(_)) => (),
645645
_ => return false,
646646
}
647-
match self.find_by_hir_id(self.get_parent_node_by_hir_id(id)) {
647+
match self.find_by_hir_id(self.get_parent_node(id)) {
648648
Some(Node::Item(_)) |
649649
Some(Node::TraitItem(_)) |
650650
Some(Node::ImplItem(_)) => true,
@@ -680,7 +680,7 @@ impl<'hir> Map<'hir> {
680680
{
681681
let mut id = start_id;
682682
loop {
683-
let parent_id = self.get_parent_node_by_hir_id(id);
683+
let parent_id = self.get_parent_node(id);
684684
if parent_id == CRATE_HIR_ID {
685685
return Ok(CRATE_HIR_ID);
686686
}
@@ -1022,7 +1022,7 @@ impl<'hir> Map<'hir> {
10221022
Some(Node::Arm(arm)) => arm.span,
10231023
Some(Node::Block(block)) => block.span,
10241024
Some(Node::Ctor(..)) => match self.find_by_hir_id(
1025-
self.get_parent_node_by_hir_id(hir_id))
1025+
self.get_parent_node(hir_id))
10261026
{
10271027
Some(Node::Item(item)) => item.span,
10281028
Some(Node::Variant(variant)) => variant.span,

src/librustc/middle/resolve_lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
662662
if let Some(Region::LateBound(_, def_id, _)) = def {
663663
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
664664
// Ensure that the parent of the def is an item, not HRTB
665-
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
665+
let parent_id = self.tcx.hir().get_parent_node(hir_id);
666666
let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
667667
let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
668668
let krate = self.tcx.hir().forest.krate();
@@ -2051,7 +2051,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20512051
// and whether there's a `self` argument (treated specially).
20522052
let mut assoc_item_kind = None;
20532053
let mut impl_self = None;
2054-
let parent = self.tcx.hir().get_parent_node_by_hir_id(output.hir_id);
2054+
let parent = self.tcx.hir().get_parent_node(output.hir_id);
20552055
let body = match self.tcx.hir().get(parent) {
20562056
// `fn` definitions and methods.
20572057
Node::Item(&hir::Item {

src/librustc/traits/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
938938
err: &mut DiagnosticBuilder<'tcx>,
939939
) {
940940
if let &ObligationCauseCode::VariableType(hir_id) = code {
941-
let parent_node = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
941+
let parent_node = self.tcx.hir().get_parent_node(hir_id);
942942
if let Some(Node::Local(ref local)) = self.tcx.hir().find_by_hir_id(parent_node) {
943943
if let Some(ref expr) = local.init {
944944
if let hir::ExprKind::Index(_, _) = expr.node {
@@ -1013,7 +1013,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10131013
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
10141014
) {
10151015
let hir = self.tcx.hir();
1016-
let parent_node = hir.get_parent_node_by_hir_id(obligation.cause.body_id);
1016+
let parent_node = hir.get_parent_node(obligation.cause.body_id);
10171017
let node = hir.find_by_hir_id(parent_node);
10181018
if let Some(hir::Node::Item(hir::Item {
10191019
node: hir::ItemKind::Fn(decl, _, _, body_id),

src/librustc/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,7 @@ impl<'tcx> TyCtxt<'tcx> {
28802880
if lint::maybe_lint_level_root(self, id) {
28812881
return id;
28822882
}
2883-
let next = self.hir().get_parent_node_by_hir_id(id);
2883+
let next = self.hir().get_parent_node(id);
28842884
if next == id {
28852885
bug!("lint traversal reached the root of the crate");
28862886
}
@@ -2898,7 +2898,7 @@ impl<'tcx> TyCtxt<'tcx> {
28982898
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
28992899
return pair
29002900
}
2901-
let next = self.hir().get_parent_node_by_hir_id(id);
2901+
let next = self.hir().get_parent_node(id);
29022902
if next == id {
29032903
bug!("lint traversal reached the root of the crate");
29042904
}

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub enum PatternSource<'tcx> {
4747
/// with a reference to the let
4848
fn get_pattern_source<'tcx>(tcx: TyCtxt<'tcx>, pat: &Pat) -> PatternSource<'tcx> {
4949

50-
let parent = tcx.hir().get_parent_node_by_hir_id(pat.hir_id);
50+
let parent = tcx.hir().get_parent_node(pat.hir_id);
5151

5252
match tcx.hir().get(parent) {
5353
Node::Expr(ref e) => {

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ impl BorrowckCtxt<'_, 'tcx> {
11891189
}
11901190

11911191
fn local_ty(&self, hir_id: hir::HirId) -> (Option<&hir::Ty>, bool) {
1192-
let parent = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
1192+
let parent = self.tcx.hir().get_parent_node(hir_id);
11931193
let parent_node = self.tcx.hir().get(parent);
11941194

11951195
// The parent node is like a fn
@@ -1287,7 +1287,7 @@ impl BorrowckCtxt<'_, 'tcx> {
12871287
},
12881288
)) = ty.map(|t| &t.node)
12891289
{
1290-
let borrow_expr_id = self.tcx.hir().get_parent_node_by_hir_id(borrowed_hir_id);
1290+
let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_hir_id);
12911291
db.span_suggestion(
12921292
self.tcx.hir().span(borrow_expr_id),
12931293
"consider removing the `&mut`, as it is an \

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ fn print_flowgraph<'tcx, W: Write>(
631631
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
632632
break n.body();
633633
}
634-
let parent = tcx.hir().get_parent_node_by_hir_id(hir_id);
634+
let parent = tcx.hir().get_parent_node(hir_id);
635635
assert_ne!(hir_id, parent);
636636
hir_id = parent;
637637
}

src/librustc_lint/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn lint_int_literal<'a, 'tcx>(
275275
return;
276276
}
277277

278-
let par_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
278+
let par_id = cx.tcx.hir().get_parent_node(e.hir_id);
279279
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
280280
if let hir::ExprKind::Struct(..) = par_e.node {
281281
if is_range_literal(cx.sess(), par_e)
@@ -314,7 +314,7 @@ fn lint_uint_literal<'a, 'tcx>(
314314
_ => bug!(),
315315
};
316316
if lit_val < min || lit_val > max {
317-
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
317+
let parent_id = cx.tcx.hir().get_parent_node(e.hir_id);
318318
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
319319
match par_e.node {
320320
hir::ExprKind::Cast(..) => {

src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ fn convert_path_expr<'a, 'tcx>(
909909

910910
Res::Def(DefKind::ConstParam, def_id) => {
911911
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
912-
let item_id = cx.tcx.hir().get_parent_node_by_hir_id(hir_id);
912+
let item_id = cx.tcx.hir().get_parent_node(hir_id);
913913
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(item_id);
914914
let generics = cx.tcx.generics_of(item_def_id);
915915
let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);

0 commit comments

Comments
 (0)