Skip to content

Commit 73d293f

Browse files
rename get_parent_node to parent_id
1 parent cd579d6 commit 73d293f

14 files changed

+21
-21
lines changed

clippy_lints/src/escape.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
131131
_ => return false,
132132
}
133133

134-
matches!(map.find(map.get_parent_node(id)), Some(Node::Param(_)))
134+
matches!(map.find(map.parent_id(id)), Some(Node::Param(_)))
135135
}
136136

137137
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
@@ -156,8 +156,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
156156
let map = &self.cx.tcx.hir();
157157
if is_argument(*map, cmt.hir_id) {
158158
// Skip closure arguments
159-
let parent_id = map.get_parent_node(cmt.hir_id);
160-
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) {
159+
let parent_id = map.parent_id(cmt.hir_id);
160+
if let Some(Node::Expr(..)) = map.find(map.parent_id(parent_id)) {
161161
return;
162162
}
163163

clippy_lints/src/index_refutable_slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
251251
let map = cx.tcx.hir();
252252

253253
// Checking for slice indexing
254-
let parent_id = map.get_parent_node(expr.hir_id);
254+
let parent_id = map.parent_id(expr.hir_id);
255255
if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id);
256256
if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind;
257257
if let Some((Constant::Int(index_value), _)) = constant(cx, cx.typeck_results(), index_expr);
258258
if let Ok(index_value) = index_value.try_into();
259259
if index_value < max_suggested_slice;
260260

261261
// Make sure that this slice index is read only
262-
let maybe_addrof_id = map.get_parent_node(parent_id);
262+
let maybe_addrof_id = map.parent_id(parent_id);
263263
if let Some(hir::Node::Expr(maybe_addrof_expr)) = map.find(maybe_addrof_id);
264264
if let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind;
265265
then {

clippy_lints/src/loops/same_item_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(super) fn check<'tcx>(
6363
if let Node::Pat(pat) = node;
6464
if let PatKind::Binding(bind_ann, ..) = pat.kind;
6565
if !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut));
66-
let parent_node = cx.tcx.hir().get_parent_node(hir_id);
66+
let parent_node = cx.tcx.hir().parent_id(hir_id);
6767
if let Some(Node::Local(parent_let_expr)) = cx.tcx.hir().find(parent_node);
6868
if let Some(init) = parent_let_expr.init;
6969
then {

clippy_lints/src/manual_rem_euclid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
7474
&& let Some(hir_id) = path_to_local(expr3)
7575
&& let Some(Node::Pat(_)) = cx.tcx.hir().find(hir_id) {
7676
// Apply only to params or locals with annotated types
77-
match cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
77+
match cx.tcx.hir().find(cx.tcx.hir().parent_id(hir_id)) {
7878
Some(Node::Param(..)) => (),
7979
Some(Node::Local(local)) => {
8080
let Some(ty) = local.ty else { return };

clippy_lints/src/matches/match_single_binding.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
140140
fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> {
141141
let map = &cx.tcx.hir();
142142

143-
if let Some(Node::Expr(parent_arm_expr)) = map.find(map.get_parent_node(ex.hir_id)) {
144-
return match map.find(map.get_parent_node(parent_arm_expr.hir_id)) {
143+
if let Some(Node::Expr(parent_arm_expr)) = map.find(map.parent_id(ex.hir_id)) {
144+
return match map.find(map.parent_id(parent_arm_expr.hir_id)) {
145145
Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local {
146146
span: parent_let_expr.span,
147147
pat_span: parent_let_expr.pat.span(),
@@ -183,7 +183,7 @@ fn sugg_with_curlies<'a>(
183183

184184
// If the parent is already an arm, and the body is another match statement,
185185
// we need curly braces around suggestion
186-
let parent_node_id = cx.tcx.hir().get_parent_node(match_expr.hir_id);
186+
let parent_node_id = cx.tcx.hir().parent_id(match_expr.hir_id);
187187
if let Node::Arm(arm) = &cx.tcx.hir().get(parent_node_id) {
188188
if let ExprKind::Match(..) = arm.body.kind {
189189
cbrace_end = format!("\n{indent}}}");

clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
186186
let map = &vis.cx.tcx.hir();
187187
let mut cur_id = vis.write_expr.hir_id;
188188
loop {
189-
let parent_id = map.get_parent_node(cur_id);
189+
let parent_id = map.parent_id(cur_id);
190190
if parent_id == cur_id {
191191
break;
192192
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
100100
}
101101

102102
// Exclude non-inherent impls
103-
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
103+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().parent_id(hir_id)) {
104104
if matches!(
105105
item.kind,
106106
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

clippy_lints/src/non_copy_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
366366
let mut dereferenced_expr = expr;
367367
let mut needs_check_adjustment = true;
368368
loop {
369-
let parent_id = cx.tcx.hir().get_parent_node(cur_expr.hir_id);
369+
let parent_id = cx.tcx.hir().parent_id(cur_expr.hir_id);
370370
if parent_id == cur_expr.hir_id {
371371
break;
372372
}

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
299299
}
300300

301301
// Exclude non-inherent impls
302-
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
302+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().parent_id(hir_id)) {
303303
if matches!(
304304
item.kind,
305305
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

clippy_lints/src/unit_types/unit_arg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
2121
return;
2222
}
2323
let map = &cx.tcx.hir();
24-
let opt_parent_node = map.find(map.get_parent_node(expr.hir_id));
24+
let opt_parent_node = map.find(map.parent_id(expr.hir_id));
2525
if_chain! {
2626
if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node;
2727
if is_questionmark_desugar_marked_call(parent_expr);
@@ -192,7 +192,7 @@ fn fmt_stmts_and_call(
192192

193193
let mut stmts_and_call_snippet = stmts_and_call.join(&format!("{}{}", ";\n", " ".repeat(call_expr_indent)));
194194
// expr is not in a block statement or result expression position, wrap in a block
195-
let parent_node = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(call_expr.hir_id));
195+
let parent_node = cx.tcx.hir().find(cx.tcx.hir().parent_id(call_expr.hir_id));
196196
if !matches!(parent_node, Some(Node::Block(_))) && !matches!(parent_node, Some(Node::Stmt(_))) {
197197
let block_indent = call_expr_indent + 4;
198198
stmts_and_call_snippet =

clippy_lints/src/unnecessary_wraps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
9191
}
9292

9393
// Abort if the method is implementing a trait or of it a trait method.
94-
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
94+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().parent_id(hir_id)) {
9595
if matches!(
9696
item.kind,
9797
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

clippy_lints/src/utils/internal_lints/metadata_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ fn get_parent_local<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) -
10581058
fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> {
10591059
let map = cx.tcx.hir();
10601060

1061-
match map.find(map.get_parent_node(hir_id)) {
1061+
match map.find(map.parent_id(hir_id)) {
10621062
Some(hir::Node::Local(local)) => Some(local),
10631063
Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id),
10641064
_ => None,

clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Ve
219219
match peel_hir_expr_refs(expr).0.kind {
220220
ExprKind::Path(ref qpath) => match cx.qpath_res(qpath, expr.hir_id) {
221221
Res::Local(hir_id) => {
222-
let parent_id = cx.tcx.hir().get_parent_node(hir_id);
222+
let parent_id = cx.tcx.hir().parent_id(hir_id);
223223
if let Some(Node::Local(Local { init: Some(init), .. })) = cx.tcx.hir().find(parent_id) {
224224
path_to_matched_type(cx, init)
225225
} else {

clippy_utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<
174174
if_chain! {
175175
if let Some(Node::Pat(pat)) = hir.find(hir_id);
176176
if matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..));
177-
let parent = hir.get_parent_node(hir_id);
177+
let parent = hir.parent_id(hir_id);
178178
if let Some(Node::Local(local)) = hir.find(parent);
179179
then {
180180
return local.init;
@@ -2075,7 +2075,7 @@ pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
20752075
/// }
20762076
/// ```
20772077
pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
2078-
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
2078+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().parent_id(hir_id)) {
20792079
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
20802080
} else {
20812081
false

0 commit comments

Comments
 (0)