Skip to content

Commit

Permalink
Auto merge of rust-lang#120951 - matthiaskrgr:rollup-0nnm7dv, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#110483 (Create try_new function for ThinBox)
 - rust-lang#120740 (Make cmath.rs a single file)
 - rust-lang#120872 (hir: Refactor getters for HIR parents)
 - rust-lang#120880 (add note on comparing vtables / function pointers)
 - rust-lang#120885 (interpret/visitor: ensure we only see normalized types)
 - rust-lang#120888 (assert_unsafe_precondition cleanup)
 - rust-lang#120897 (Encode `coroutine_for_closure` for foreign crates)
 - rust-lang#120937 ([docs] Update armv6k-nintendo-3ds platform docs for outdated info)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 12, 2024
2 parents 70a8dc7 + fc8f662 commit 036d00b
Show file tree
Hide file tree
Showing 39 changed files with 78 additions and 102 deletions.
3 changes: 1 addition & 2 deletions clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
return;
};
if let ConstantSource::Constant = source
&& let Some(node) = cx.tcx.hir().find_parent(e.hir_id)
&& let Node::Item(Item {
kind: ItemKind::Const(..),
..
}) = node
}) = cx.tcx.parent_hir_node(e.hir_id)
{
return;
}
Expand Down
31 changes: 13 additions & 18 deletions clippy_lints/src/casts/cast_slice_different_sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,20 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
}

fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let map = cx.tcx.hir();
if let Some(parent_id) = map.opt_parent_id(expr.hir_id) {
let parent = cx.tcx.hir_node(parent_id);
let expr = match parent {
Node::Block(block) => {
if let Some(parent_expr) = block.expr {
parent_expr
} else {
return false;
}
},
Node::Expr(expr) => expr,
_ => return false,
};
let parent = cx.tcx.parent_hir_node(expr.hir_id);
let expr = match parent {
Node::Block(block) => {
if let Some(parent_expr) = block.expr {
parent_expr
} else {
return false;
}
},
Node::Expr(expr) => expr,
_ => return false,
};

matches!(expr.kind, ExprKind::Cast(..))
} else {
false
}
matches!(expr.kind, ExprKind::Cast(..))
}

/// Returns the type T of the pointed to *const [T] or *mut [T] and the mutability of the slice if
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/unnecessary_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(super) fn check<'tcx>(
&& let ExprKind::Path(qpath) = inner.kind
&& let QPath::Resolved(None, Path { res, .. }) = qpath
&& let Res::Local(hir_id) = res
&& let parent = cx.tcx.hir().get_parent(*hir_id)
&& let parent = cx.tcx.parent_hir_node(*hir_id)
&& let Node::Local(local) = parent
{
if let Some(ty) = local.ty
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/dbg_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl LateLintPass<'_> for DbgMacro {
ExprKind::Block(..) => {
// If the `dbg!` macro is a "free" statement and not contained within other expressions,
// remove the whole statement.
if let Some(Node::Stmt(_)) = cx.tcx.hir().find_parent(expr.hir_id)
if let Node::Stmt(_) = cx.tcx.parent_hir_node(expr.hir_id)
&& let Some(semi_span) = cx.sess().source_map().mac_call_stmt_semi_span(macro_call.span)
{
(macro_call.span.to(semi_span), String::new())
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/default_numeric_fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
},
_,
) => {
if let Some(parent) = self.cx.tcx.hir().find_parent(expr.hir_id)
&& let Some(fn_sig) = parent.fn_sig()
if let Some(fn_sig) = self.cx.tcx.parent_hir_node(expr.hir_id).fn_sig()
&& let FnRetTy::Return(_ty) = fn_sig.decl.output
{
// We cannot check the exact type since it's a `hir::Ty`` which does not implement `is_numeric`
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ fn report<'tcx>(
//
// e.g. `&mut x.y.z` where `x` is a union, and accessing `z` requires a
// deref through `ManuallyDrop<_>` will not compile.
let parent_id = cx.tcx.hir().parent_id(expr.hir_id);
let parent_id = cx.tcx.parent_hir_id(expr.hir_id);
if parent_id == data.first_expr.hir_id {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn is_argument(tcx: TyCtxt<'_>, id: HirId) -> bool {
_ => return false,
}

matches!(tcx.hir().find_parent(id), Some(Node::Param(_)))
matches!(tcx.parent_hir_node(id), Node::Param(_))
}

impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
Expand All @@ -156,8 +156,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
let map = &self.cx.tcx.hir();
if is_argument(self.cx.tcx, cmt.hir_id) {
// Skip closure arguments
let parent_id = map.parent_id(cmt.hir_id);
if let Some(Node::Expr(..)) = map.find_parent(parent_id) {
let parent_id = self.cx.tcx.parent_hir_id(cmt.hir_id);
if let Node::Expr(..) = self.cx.tcx.parent_hir_node(parent_id) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/functions/impl_trait_in_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body:

pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
if let ImplItemKind::Fn(_, body_id) = impl_item.kind
&& let hir::Node::Item(item) = cx.tcx.hir().get_parent(impl_item.hir_id())
&& let hir::Node::Item(item) = cx.tcx.parent_hir_node(impl_item.hir_id())
&& let hir::ItemKind::Impl(impl_) = item.kind
&& let hir::Impl { of_trait, .. } = *impl_
&& of_trait.is_none()
Expand All @@ -72,7 +72,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
pub(super) fn check_trait_item(cx: &LateContext<'_>, trait_item: &TraitItem<'_>, avoid_breaking_exported_api: bool) {
if !avoid_breaking_exported_api
&& let TraitItemKind::Fn(_, _) = trait_item.kind
&& let hir::Node::Item(item) = cx.tcx.hir().get_parent(trait_item.hir_id())
&& let hir::Node::Item(item) = cx.tcx.parent_hir_node(trait_item.hir_id())
// ^^ (Will always be a trait)
&& !item.vis_span.is_empty() // Is public
&& !is_in_test_function(cx.tcx, trait_item.hir_id())
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/ignored_unit_patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns {
return;
}

match cx.tcx.hir().get_parent(pat.hir_id) {
Node::Param(param) if matches!(cx.tcx.hir().get_parent(param.hir_id), Node::Item(_)) => {
match cx.tcx.parent_hir_node(pat.hir_id) {
Node::Param(param) if matches!(cx.tcx.parent_hir_node(param.hir_id), Node::Item(_)) => {
// Ignore function parameters
return;
},
Expand Down
11 changes: 3 additions & 8 deletions clippy_lints/src/index_refutable_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,19 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
} = *self;

if let Some(use_info) = slice_lint_info.get_mut(&local_id)
// Check if this is even a local we're interested in

&& let map = cx.tcx.hir()

// Checking for slice indexing
&& let parent_id = map.parent_id(expr.hir_id)
&& let parent_id = cx.tcx.parent_hir_id(expr.hir_id)
&& let hir::Node::Expr(parent_expr) = cx.tcx.hir_node(parent_id)
&& let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind
&& let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr)
&& let Ok(index_value) = index_value.try_into()
&& index_value < max_suggested_slice

// Make sure that this slice index is read only
&& let maybe_addrof_id = map.parent_id(parent_id)
&& let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.hir_node(maybe_addrof_id)
&& let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.parent_hir_node(parent_id)
&& let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind
{
use_info.index_use.push((index_value, map.span(parent_expr.hir_id)));
use_info.index_use.push((index_value, cx.tcx.hir().span(parent_expr.hir_id)));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/iter_without_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl {self_ty_without_ref} {{
// }
let span_behind_impl = cx
.tcx
.def_span(cx.tcx.hir().parent_id(item.hir_id()).owner.def_id)
.def_span(cx.tcx.parent_hir_id(item.hir_id()).owner.def_id)
.shrink_to_lo();

let sugg = format!(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ fn elision_suggestions(
.iter()
.filter(|usage| named_lifetime(usage).map_or(false, |id| elidable_lts.contains(&id)))
.map(|usage| {
match cx.tcx.hir().get_parent(usage.hir_id) {
match cx.tcx.parent_hir_node(usage.hir_id) {
Node::Ty(Ty {
kind: TyKind::Ref(..), ..
}) => {
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/loops/same_item_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ pub(super) fn check<'tcx>(
if let Node::Pat(pat) = node
&& let PatKind::Binding(bind_ann, ..) = pat.kind
&& !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut))
&& let parent_node = cx.tcx.hir().parent_id(hir_id)
&& let Node::Local(parent_let_expr) = cx.tcx.hir_node(parent_node)
&& let Node::Local(parent_let_expr) = cx.tcx.parent_hir_node(hir_id)
&& let Some(init) = parent_let_expr.init
{
match init.kind {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/manual_hash_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl LateLintPass<'_> for ManualHashOne {
&& let ExprKind::MethodCall(seg, build_hasher, [], _) = init.kind
&& seg.ident.name == sym!(build_hasher)

&& let Node::Stmt(local_stmt) = cx.tcx.hir().get_parent(local.hir_id)
&& let Node::Block(block) = cx.tcx.hir().get_parent(local_stmt.hir_id)
&& let Node::Stmt(local_stmt) = cx.tcx.parent_hir_node(local.hir_id)
&& let Node::Block(block) = cx.tcx.parent_hir_node(local_stmt.hir_id)

&& let mut stmts = block.stmts.iter()
.skip_while(|stmt| stmt.hir_id != local_stmt.hir_id)
Expand All @@ -91,7 +91,7 @@ impl LateLintPass<'_> for ManualHashOne {

// `hasher.finish()`, may be anywhere in a statement or the trailing expr of the block
&& let Some(path_expr) = local_used_once(cx, (maybe_finish_stmt, block.expr), hasher)
&& let Node::Expr(finish_expr) = cx.tcx.hir().get_parent(path_expr.hir_id)
&& let Node::Expr(finish_expr) = cx.tcx.parent_hir_node(path_expr.hir_id)
&& !finish_expr.span.from_expansion()
&& let ExprKind::MethodCall(seg, _, [], _) = finish_expr.kind
&& seg.ident.name == sym!(finish)
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/manual_rem_euclid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
&& let Node::Pat(_) = cx.tcx.hir_node(hir_id)
{
// Apply only to params or locals with annotated types
match cx.tcx.hir().find_parent(hir_id) {
Some(Node::Param(..)) => (),
Some(Node::Local(local)) => {
match cx.tcx.parent_hir_node(hir_id) {
Node::Param(..) => (),
Node::Local(local) => {
let Some(ty) = local.ty else { return };
if matches!(ty.kind, TyKind::Infer) {
return;
Expand Down
16 changes: 7 additions & 9 deletions clippy_lints/src/matches/match_single_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
.to_string();

// Do we need to add ';' to suggestion ?
if let Node::Stmt(stmt) = cx.tcx.hir().get_parent(expr.hir_id)
if let Node::Stmt(stmt) = cx.tcx.parent_hir_node(expr.hir_id)
&& let StmtKind::Expr(_) = stmt.kind
&& match match_body.kind {
// We don't need to add a ; to blocks, unless that block is from a macro expansion
Expand Down Expand Up @@ -146,18 +146,16 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e

/// Returns true if the `ex` match expression is in a local (`let`) or assign expression
fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> {
let map = &cx.tcx.hir();

if let Some(Node::Expr(parent_arm_expr)) = map.find_parent(ex.hir_id) {
return match map.find_parent(parent_arm_expr.hir_id) {
Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local {
if let Node::Expr(parent_arm_expr) = cx.tcx.parent_hir_node(ex.hir_id) {
return match cx.tcx.parent_hir_node(parent_arm_expr.hir_id) {
Node::Local(parent_let_expr) => Some(AssignmentExpr::Local {
span: parent_let_expr.span,
pat_span: parent_let_expr.pat.span(),
}),
Some(Node::Expr(Expr {
Node::Expr(Expr {
kind: ExprKind::Assign(parent_assign_expr, match_expr, _),
..
})) => Some(AssignmentExpr::Assign {
}) => Some(AssignmentExpr::Assign {
span: parent_assign_expr.span,
match_span: match_expr.span,
}),
Expand Down Expand Up @@ -191,7 +189,7 @@ fn sugg_with_curlies<'a>(

// If the parent is already an arm, and the body is another match statement,
// we need curly braces around suggestion
if let Node::Arm(arm) = &cx.tcx.hir().get_parent(match_expr.hir_id) {
if let Node::Arm(arm) = &cx.tcx.parent_hir_node(match_expr.hir_id) {
if let ExprKind::Match(..) = arm.body.kind {
cbrace_end = format!("\n{indent}}}");
// Fix body indent due to the match
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/redundant_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn get_pat_binding<'tcx>(
return span.map(|span| PatBindingInfo {
span,
byref_ident,
is_field: matches!(cx.tcx.hir().get_parent(local), Node::PatField(_)),
is_field: matches!(cx.tcx.parent_hir_node(local), Node::PatField(_)),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4458,7 +4458,7 @@ impl Methods {
_ => {},
},
("drain", ..) => {
if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.hir().get_parent(expr.hir_id)
if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.parent_hir_node(expr.hir_id)
&& matches!(kind, StmtKind::Semi(_))
&& args.len() <= 1
{
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/readonly_write_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ fn is_unwrap_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {

pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, receiver: &Expr<'_>) {
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(receiver).peel_refs(), sym::RwLock)
&& let Node::Expr(unwrap_call_expr) = cx.tcx.hir().get_parent(expr.hir_id)
&& let Node::Expr(unwrap_call_expr) = cx.tcx.parent_hir_node(expr.hir_id)
&& is_unwrap_call(cx, unwrap_call_expr)
&& let parent = cx.tcx.hir().get_parent(unwrap_call_expr.hir_id)
&& let parent = cx.tcx.parent_hir_node(unwrap_call_expr.hir_id)
&& let Node::Local(local) = parent
&& let Some(mir) = enclosing_mir(cx.tcx, expr.hir_id)
&& let Some((local, _)) = mir
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::UNNECESSARY_FOLD;
/// Changing `fold` to `sum` needs it sometimes when the return type can't be
/// inferred. This checks for some common cases where it can be safely omitted
fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
let parent = cx.tcx.hir().get_parent(expr.hir_id);
let parent = cx.tcx.parent_hir_node(expr.hir_id);

// some common cases where turbofish isn't needed:
// - assigned to a local variable with a type annotation
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_literal_unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub(super) fn check(
(expr.span.with_lo(call_args[0].span.hi()), String::new()),
];
// try to also remove the unsafe block if present
if let hir::Node::Block(block) = cx.tcx.hir().get_parent(expr.hir_id)
if let hir::Node::Block(block) = cx.tcx.parent_hir_node(expr.hir_id)
&& let hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::UserProvided) = block.rules
{
suggs.extend([
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/mixed_read_write_in_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,9 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
///
/// When such a read is found, the lint is triggered.
fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
let map = &vis.cx.tcx.hir();
let mut cur_id = vis.write_expr.hir_id;
loop {
let parent_id = map.parent_id(cur_id);
let parent_id = vis.cx.tcx.parent_hir_id(cur_id);
if parent_id == cur_id {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_ref_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
};

// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) {
if matches!(
item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
}

// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) {
if matches!(
item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
let mut dereferenced_expr = expr;
let mut needs_check_adjustment = true;
loop {
let parent_id = cx.tcx.hir().parent_id(cur_expr.hir_id);
let parent_id = cx.tcx.parent_hir_id(cur_expr.hir_id);
if parent_id == cur_expr.hir_id {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/operators/modulo_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(
}

fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find_parent(expr.hir_id) else {
let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) else {
return false;
};
let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/pass_by_ref_or_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
}

// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id) {
if matches!(
item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(super) fn check<'tcx>(
_ => return false,
};

if let Node::Expr(parent) = cx.tcx.hir().get_parent(e.hir_id)
if let Node::Expr(parent) = cx.tcx.parent_hir_node(e.hir_id)
&& parent.precedence().order() > ExprPrecedence::Cast.order()
{
sugg = format!("({sugg})");
Expand Down
9 changes: 3 additions & 6 deletions clippy_lints/src/tuple_array_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,10 @@ fn all_bindings_are_for_conv<'tcx>(
let Some(locals) = locals.iter().map(|e| path_to_local(e)).collect::<Option<Vec<_>>>() else {
return false;
};
let Some(local_parents) = locals
let local_parents = locals
.iter()
.map(|&l| cx.tcx.hir().find_parent(l))
.collect::<Option<Vec<_>>>()
else {
return false;
};
.map(|l| cx.tcx.parent_hir_node(*l))
.collect::<Vec<_>>();

local_parents
.iter()
Expand Down
Loading

0 comments on commit 036d00b

Please sign in to comment.