Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6af339d

Browse files
committedJan 4, 2023
rename find_parent_node to opt_parent_id
1 parent a313ef0 commit 6af339d

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed
 

‎compiler/rustc_const_eval/src/transform/check_consts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn is_parent_const_stable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
115115
let local_def_id = def_id.expect_local();
116116
let hir_id = tcx.local_def_id_to_hir_id(local_def_id);
117117

118-
let Some(parent) = tcx.hir().find_parent_node(hir_id) else { return false };
118+
let Some(parent) = tcx.hir().opt_parent_id(hir_id) else { return false };
119119
let parent_def = tcx.hir().get(parent);
120120

121121
if !matches!(

‎compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
716716
num = num_trait_generics_except_self,
717717
);
718718

719-
if let Some(parent_node) = self.tcx.hir().find_parent_node(self.path_segment.hir_id)
719+
if let Some(parent_node) = self.tcx.hir().opt_parent_id(self.path_segment.hir_id)
720720
&& let Some(parent_node) = self.tcx.hir().find(parent_node)
721721
&& let hir::Node::Expr(expr) = parent_node {
722722
match expr.kind {

‎compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
943943
}) => {
944944
// Check if our original expression is a child of the condition of a while loop
945945
let expr_is_ancestor = std::iter::successors(Some(original_expr_id), |id| {
946-
self.tcx.hir().find_parent_node(*id)
946+
self.tcx.hir().opt_parent_id(*id)
947947
})
948948
.take_while(|id| *id != parent)
949949
.any(|id| id == expr.hir_id);

‎compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
140140
diag_expr_id: HirId,
141141
) {
142142
let hir = self.tcx.hir();
143-
let parent = match hir.find_parent_node(place_with_id.hir_id) {
143+
let parent = match hir.opt_parent_id(place_with_id.hir_id) {
144144
Some(parent) => parent,
145145
None => place_with_id.hir_id,
146146
};

‎compiler/rustc_middle/src/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
298298
/// Finds the id of the parent node to this one.
299299
///
300300
/// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
301-
pub fn find_parent_node(self, id: HirId) -> Option<HirId> {
301+
pub fn opt_parent_id(self, id: HirId) -> Option<HirId> {
302302
if id.local_id == ItemLocalId::from_u32(0) {
303303
Some(self.tcx.hir_owner_parent(id.owner))
304304
} else {
@@ -313,7 +313,7 @@ impl<'hir> Map<'hir> {
313313

314314
#[track_caller]
315315
pub fn parent_id(self, hir_id: HirId) -> HirId {
316-
self.find_parent_node(hir_id)
316+
self.opt_parent_id(hir_id)
317317
.unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id)))
318318
}
319319

‎compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ impl<'tcx> ConstantKind<'tcx> {
25062506
}
25072507

25082508
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
2509-
let parent_substs = if let Some(parent_hir_id) = tcx.hir().find_parent_node(hir_id) {
2509+
let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id) {
25102510
if let Some(parent_did) = tcx.hir().opt_local_def_id(parent_hir_id) {
25112511
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
25122512
} else {

‎src/librustdoc/passes/check_doc_test_visibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
8282
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.item_id.expect_def_id().expect_local());
8383

8484
// check if parent is trait impl
85-
if let Some(parent_hir_id) = cx.tcx.hir().find_parent_node(hir_id) {
85+
if let Some(parent_hir_id) = cx.tcx.hir().opt_parent_id(hir_id) {
8686
if let Some(parent_node) = cx.tcx.hir().find(parent_hir_id) {
8787
if matches!(
8888
parent_node,

‎src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
6868
fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
6969
let map = cx.tcx.hir();
7070
if_chain! {
71-
if let Some(parent_id) = map.find_parent_node(expr.hir_id);
71+
if let Some(parent_id) = map.opt_parent_id(expr.hir_id);
7272
if let Some(parent) = map.find(parent_id);
7373
then {
7474
let expr = match parent {

0 commit comments

Comments
 (0)
Please sign in to comment.