Skip to content

Commit 49082f9

Browse files
committed
Auto merge of rust-lang#137397 - matthiaskrgr:rollup-ls2pilo, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#132876 (rustdoc book: acknowledge --document-hidden-items) - rust-lang#136148 (Optionally add type names to `TypeId`s.) - rust-lang#136609 (libcore/net: `IpAddr::as_octets()`) - rust-lang#137336 (Stabilise `os_str_display`) - rust-lang#137350 (Move methods from Map to TyCtxt, part 3.) - rust-lang#137353 (Implement `read_buf` for WASI stdin) - rust-lang#137361 (Refactor `OperandRef::extract_field` to prep for MCP838) - rust-lang#137367 (Do not exempt nonexistent platforms from platform policy) - rust-lang#137374 (Stacker now handles miri using a noop impl itself) - rust-lang#137392 (remove few unused fields) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8113d54 + c2d75cf commit 49082f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+96
-108
lines changed

clippy_lints/src/assigning_clones.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
107107
&& !cx.tcx.is_builtin_derived(resolved_impl)
108108
// Don't suggest calling a function we're implementing.
109109
&& resolved_impl.as_local().is_none_or(|block_id| {
110-
cx.tcx.hir().parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
110+
cx.tcx.hir_parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
111111
})
112112
&& let resolved_assoc_items = cx.tcx.associated_items(resolved_impl)
113113
// Only suggest if `clone_from`/`clone_into` is explicitly implemented

clippy_lints/src/doc/missing_headers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ pub fn check(
2424
if !check_private_items
2525
&& cx
2626
.tcx
27-
.hir()
28-
.parent_iter(owner_id.into())
27+
.hir_parent_iter(owner_id.into())
2928
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id)))
3029
{
3130
return;

clippy_lints/src/doc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
10571057
"assert" | "assert_eq" | "assert_ne"
10581058
)
10591059
{
1060-
self.is_const = self.cx.tcx.hir().is_inside_const_context(expr.hir_id);
1060+
self.is_const = self.cx.tcx.hir_is_inside_const_context(expr.hir_id);
10611061
self.panic_span = Some(macro_call.span);
10621062
}
10631063
}

clippy_lints/src/escape.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
8080

8181
let parent_id = cx
8282
.tcx
83-
.hir()
84-
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
83+
.hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
8584
.def_id;
8685

8786
let mut trait_self_ty = None;

clippy_lints/src/exit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
4747
&& let ExprKind::Path(ref path) = path_expr.kind
4848
&& let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id()
4949
&& cx.tcx.is_diagnostic_item(sym::process_exit, def_id)
50-
&& let parent = cx.tcx.hir().get_parent_item(e.hir_id)
50+
&& let parent = cx.tcx.hir_get_parent_item(e.hir_id)
5151
&& let OwnerNode::Item(Item{kind: ItemKind::Fn{ .. }, ..}) = cx.tcx.hir_owner_node(parent)
5252
// If the next item up is a function we check if it is an entry point
5353
// and only then emit a linter warning

clippy_lints/src/indexing_slicing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl IndexingSlicing {
112112
impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
113113
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
114114
if let ExprKind::Index(array, index, _) = &expr.kind
115-
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir().is_inside_const_context(expr.hir_id))
115+
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir_is_inside_const_context(expr.hir_id))
116116
&& let expr_ty = cx.typeck_results().expr_ty(array)
117117
&& let mut deref = deref_chain(cx, expr_ty)
118118
&& deref.any(|l| {
@@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
181181
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "slicing may panic", |diag| {
182182
diag.help(help_msg);
183183

184-
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
184+
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
185185
diag.note(note);
186186
}
187187
});
@@ -223,7 +223,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
223223
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "indexing may panic", |diag| {
224224
diag.help("consider using `.get(n)` or `.get_mut(n)` instead");
225225

226-
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
226+
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
227227
diag.note(note);
228228
}
229229
});

clippy_lints/src/large_stack_arrays.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
8383
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
8484
&& let Some(element_count) = cst.try_to_target_usize(cx.tcx)
8585
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
86-
&& !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
86+
&& !cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| {
8787
matches!(
8888
node,
8989
Node::Item(Item {

clippy_lints/src/loops/infinite_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(super) fn check<'tcx>(
6161
}
6262

6363
fn get_parent_fn_ret_ty<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<FnRetTy<'tcx>> {
64-
for (_, parent_node) in cx.tcx.hir().parent_iter(expr.hir_id) {
64+
for (_, parent_node) in cx.tcx.hir_parent_iter(expr.hir_id) {
6565
match parent_node {
6666
// Skip `Coroutine` closures, these are the body of `async fn`, not async closures.
6767
// This is because we still need to backtrack one parent node to get the `OpaqueDef` ty.

clippy_lints/src/loops/manual_find.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn last_stmt_and_ret<'tcx>(
134134
}
135135
None
136136
}
137-
let mut parent_iter = cx.tcx.hir().parent_iter(expr.hir_id);
137+
let mut parent_iter = cx.tcx.hir_parent_iter(expr.hir_id);
138138
if let Some((node_hir, Node::Stmt(..))) = parent_iter.next()
139139
// This should be the loop
140140
// This should be the function body

clippy_lints/src/loops/needless_range_loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(super) fn check<'tcx>(
5656

5757
// ensure that the indexed variable was declared before the loop, see #601
5858
if let Some(indexed_extent) = indexed_extent {
59-
let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id);
59+
let parent_def_id = cx.tcx.hir_get_parent_item(expr.hir_id);
6060
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
6161
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap();
6262
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
@@ -256,7 +256,7 @@ impl<'tcx> VarVisitor<'_, 'tcx> {
256256
let res = self.cx.qpath_res(seqpath, seqexpr.hir_id);
257257
match res {
258258
Res::Local(hir_id) => {
259-
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
259+
let parent_def_id = self.cx.tcx.hir_get_parent_item(expr.hir_id);
260260
let extent = self
261261
.cx
262262
.tcx

clippy_lints/src/matches/redundant_pattern_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn find_method_sugg_for_if_let<'tcx>(
199199
// type needs to be considered, not just the inner type of the branch being matched on.
200200
// Note the last expression in a block is dropped after all local bindings.
201201
let check_ty = if has_else
202-
|| (keyword == "if" && matches!(cx.tcx.hir().parent_iter(expr.hir_id).next(), Some((_, Node::Block(..)))))
202+
|| (keyword == "if" && matches!(cx.tcx.hir_parent_iter(expr.hir_id).next(), Some((_, Node::Block(..)))))
203203
{
204204
op_ty
205205
} else {

clippy_lints/src/methods/is_empty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_
4040

4141
fn is_under_cfg(cx: &LateContext<'_>, id: HirId) -> bool {
4242
cx.tcx
43-
.hir()
44-
.parent_id_iter(id)
43+
.hir_parent_id_iter(id)
4544
.any(|id| cx.tcx.hir().attrs(id).iter().any(|attr| attr.has_name(sym::cfg)))
4645
}
4746

clippy_lints/src/methods/iter_nth_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::sym;
1111
use super::ITER_NTH_ZERO;
1212

1313
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) {
14-
if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id))
14+
if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir_get_parent_item(expr.hir_id))
1515
&& let def_id = item.owner_id.to_def_id()
1616
&& is_trait_method(cx, expr, sym::Iterator)
1717
&& let Some(Constant::Int(0)) = ConstEvalCtxt::new(cx).eval(arg)

clippy_lints/src/methods/manual_c_str_literals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn peel_ptr_cast<'tcx>(e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
187187
/// ^ given this `x` expression, returns the `foo(...)` expression
188188
fn peel_ptr_cast_ancestors<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
189189
let mut prev = e;
190-
for (_, node) in cx.tcx.hir().parent_iter(e.hir_id) {
190+
for (_, node) in cx.tcx.hir_parent_iter(e.hir_id) {
191191
if let Node::Expr(e) = node
192192
&& get_cast_target(e).is_some()
193193
{

clippy_lints/src/methods/manual_inspect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
123123
};
124124
let mut prev_expr = e;
125125

126-
for (_, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
126+
for (_, parent) in cx.tcx.hir_parent_iter(e.hir_id) {
127127
if let Node::Expr(e) = parent {
128128
match e.kind {
129129
ExprKind::Field(_, name)

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4671,7 +4671,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
46714671
return;
46724672
}
46734673
let name = impl_item.ident.name.as_str();
4674-
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
4674+
let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
46754675
let item = cx.tcx.hir().expect_item(parent);
46764676
let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
46774677

clippy_lints/src/methods/or_fun_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(super) fn check<'tcx>(
9292
let in_sugg_method_implementation = {
9393
matches!(
9494
suggested_method_def_id.as_local(),
95-
Some(local_def_id) if local_def_id == cx.tcx.hir().get_parent_item(receiver.hir_id).def_id
95+
Some(local_def_id) if local_def_id == cx.tcx.hir_get_parent_item(receiver.hir_id).def_id
9696
)
9797
};
9898
if in_sugg_method_implementation {

clippy_lints/src/methods/str_splitn.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(super) fn check(
3535
};
3636
let manual = count == 2 && msrv.meets(msrvs::STR_SPLIT_ONCE);
3737

38-
match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir().parent_iter(expr.hir_id)) {
38+
match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir_parent_iter(expr.hir_id)) {
3939
Some(usage) if needless(usage.kind) => lint_needless(cx, method_name, expr, self_arg, pat_arg),
4040
Some(usage) if manual => check_manual_split_once(cx, method_name, expr, self_arg, pat_arg, &usage),
4141
None if manual => {
@@ -127,7 +127,7 @@ fn check_manual_split_once_indirect(
127127
pat_arg: &Expr<'_>,
128128
) -> Option<()> {
129129
let ctxt = expr.span.ctxt();
130-
let mut parents = cx.tcx.hir().parent_iter(expr.hir_id);
130+
let mut parents = cx.tcx.hir_parent_iter(expr.hir_id);
131131
if let (_, Node::LetStmt(local)) = parents.next()?
132132
&& let PatKind::Binding(BindingMode::MUT, iter_binding_id, _, None) = local.pat.kind
133133
&& let (iter_stmt_id, Node::Stmt(_)) = parents.next()?
@@ -220,7 +220,7 @@ fn indirect_usage<'tcx>(
220220
ControlFlow::Continue(Descend::from(path_to_binding.is_none()))
221221
});
222222

223-
let mut parents = cx.tcx.hir().parent_iter(path_to_binding?.hir_id);
223+
let mut parents = cx.tcx.hir_parent_iter(path_to_binding?.hir_id);
224224
let iter_usage = parse_iter_usage(cx, ctxt, &mut parents)?;
225225

226226
let (parent_id, _) = parents.find(|(_, node)| {

clippy_lints/src/methods/unnecessary_to_owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ fn get_input_traits_and_projections<'tcx>(
494494

495495
#[expect(clippy::too_many_lines)]
496496
fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<'a>) -> bool {
497-
for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) {
497+
for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) {
498498
match node {
499499
Node::Stmt(_) => return true,
500500
Node::Block(..) => {},

clippy_lints/src/min_ident_chars.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
121121
// Check whether the node is part of a `use` statement. We don't want to emit a warning if the user
122122
// has no control over the type.
123123
let usenode = opt_as_use_node(node).or_else(|| {
124-
cx.tcx
125-
.hir()
126-
.parent_iter(hir_id)
124+
cx
125+
.tcx
126+
.hir_parent_iter(hir_id)
127127
.find_map(|(_, node)| opt_as_use_node(node))
128128
});
129129

clippy_lints/src/missing_const_for_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
143143

144144
// Const fns are not allowed as methods in a trait.
145145
{
146-
let parent = cx.tcx.hir().get_parent_item(hir_id).def_id;
146+
let parent = cx.tcx.hir_get_parent_item(hir_id).def_id;
147147
if parent != CRATE_DEF_ID {
148148
if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) {
149149
if let hir::ItemKind::Trait(..) = &item.kind {

clippy_lints/src/missing_const_for_thread_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn is_unreachable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
8181
| sym::core_panic_2015_macro
8282
| sym::std_panic_2015_macro
8383
| sym::core_panic_2021_macro
84-
) && !cx.tcx.hir().is_inside_const_context(expr.hir_id))
84+
) && !cx.tcx.hir_is_inside_const_context(expr.hir_id))
8585
|| matches!(
8686
diag_name,
8787
sym::unimplemented_macro | sym::todo_macro | sym::unreachable_macro | sym::unreachable_2015_macro

clippy_lints/src/needless_borrowed_ref.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef {
4141
&& !ref_pat.span.from_expansion()
4242
&& cx
4343
.tcx
44-
.hir()
45-
.parent_iter(ref_pat.hir_id)
44+
.hir_parent_iter(ref_pat.hir_id)
4645
.map_while(|(_, parent)| if let Node::Pat(pat) = parent { Some(pat) } else { None })
4746
// Do not lint patterns that are part of an OR `|` pattern, the binding mode must match in all arms
4847
.all(|pat| !matches!(pat.kind, PatKind::Or(_)))

clippy_lints/src/needless_late_init.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fn check<'tcx>(
347347

348348
impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
349349
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
350-
let mut parents = cx.tcx.hir().parent_iter(local.hir_id);
350+
let mut parents = cx.tcx.hir_parent_iter(local.hir_id);
351351
if let LetStmt {
352352
init: None,
353353
pat:

clippy_lints/src/needless_pass_by_ref_mut.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ impl MutablyUsedVariablesCtxt<'_> {
350350
// The goal here is to find if the current scope is unsafe or not. It stops when it finds
351351
// a function or an unsafe block.
352352
fn is_in_unsafe_block(&self, item: HirId) -> bool {
353-
let hir = self.tcx.hir();
354-
for (parent, node) in hir.parent_iter(item) {
353+
for (parent, node) in self.tcx.hir_parent_iter(item) {
355354
if let Some(fn_sig) = self.tcx.hir_fn_sig_by_hir_id(parent) {
356355
return fn_sig.header.is_unsafe();
357356
} else if let Node::Block(block) = node {

clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
9090
if sig.decl.inputs.is_empty()
9191
&& name == sym::new
9292
&& cx.effective_visibilities.is_reachable(impl_item.owner_id.def_id)
93-
&& let self_def_id = cx.tcx.hir().get_parent_item(id.into())
93+
&& let self_def_id = cx.tcx.hir_get_parent_item(id.into())
9494
&& let self_ty = cx.tcx.type_of(self_def_id).instantiate_identity()
9595
&& self_ty == return_ty(cx, id)
9696
&& let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default)

clippy_lints/src/no_effect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl NoEffect {
141141
stmt.span,
142142
"statement with no effect",
143143
|diag| {
144-
for parent in cx.tcx.hir().parent_iter(stmt.hir_id) {
144+
for parent in cx.tcx.hir_parent_iter(stmt.hir_id) {
145145
if let Node::Item(item) = parent.1
146146
&& let ItemKind::Fn { .. } = item.kind
147147
&& let Node::Block(block) = cx.tcx.parent_hir_node(stmt.hir_id)

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
344344

345345
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
346346
if let ImplItemKind::Const(_, body_id) = &impl_item.kind {
347-
let item_def_id = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
347+
let item_def_id = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
348348
let item = cx.tcx.hir().expect_item(item_def_id);
349349

350350
match &item.kind {

clippy_lints/src/non_zero_suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for NonZeroSuggestions {
5555
check_non_zero_conversion(cx, rhs, Applicability::MachineApplicable);
5656
} else {
5757
// Check if the parent expression is a binary operation
58-
let parent_is_binary = cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
58+
let parent_is_binary = cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| {
5959
matches!(node, rustc_hir::Node::Expr(parent_expr) if matches!(parent_expr.kind, ExprKind::Binary(..)))
6060
});
6161

clippy_lints/src/operators/assign_op_pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(super) fn check<'tcx>(
2626
let rty = cx.typeck_results().expr_ty(rhs);
2727
if let Some((_, lang_item)) = binop_traits(op.node)
2828
&& let Some(trait_id) = cx.tcx.lang_items().get(lang_item)
29-
&& let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id).def_id
29+
&& let parent_fn = cx.tcx.hir_get_parent_item(e.hir_id).def_id
3030
&& trait_ref_of_method(cx, parent_fn).is_none_or(|t| t.path.res.def_id() != trait_id)
3131
&& implements_trait(cx, ty, trait_id, &[rty.into()])
3232
{

clippy_lints/src/operators/identity_op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>)
120120
// the parent HIR node is an expression, or if the parent HIR node
121121
// is a Block or Stmt, and the new left hand side would need
122122
// parenthesis be treated as a statement rather than an expression.
123-
if let Some((_, parent)) = cx.tcx.hir().parent_iter(binary.hir_id).next() {
123+
if let Some((_, parent)) = cx.tcx.hir_parent_iter(binary.hir_id).next() {
124124
match parent {
125125
Node::Expr(_) => return Parens::Needed,
126126
Node::Block(_) | Node::Stmt(_) => {
@@ -142,7 +142,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>)
142142
// This would mean that the rustfix suggestion will appear at the start of a line, which causes
143143
// these expressions to be interpreted as statements if they do not have parenthesis.
144144
let mut prev_id = binary.hir_id;
145-
for (_, parent) in cx.tcx.hir().parent_iter(binary.hir_id) {
145+
for (_, parent) in cx.tcx.hir_parent_iter(binary.hir_id) {
146146
if let Node::Expr(expr) = parent
147147
&& let ExprKind::Binary(_, lhs, _) | ExprKind::Cast(lhs, _) | ExprKind::Unary(_, lhs) = expr.kind
148148
&& lhs.hir_id == prev_id

clippy_lints/src/panic_unimplemented.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
9898
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
9999
if let Some(macro_call) = root_macro_call_first_node(cx, expr) {
100100
if is_panic(cx, macro_call.def_id) {
101-
if cx.tcx.hir().is_inside_const_context(expr.hir_id)
101+
if cx.tcx.hir_is_inside_const_context(expr.hir_id)
102102
|| self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id)
103103
{
104104
return;
@@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
139139
&& let Res::Def(DefKind::Fn, def_id) = expr_path.res
140140
&& match_def_path(cx, def_id, &paths::PANIC_ANY)
141141
{
142-
if cx.tcx.hir().is_inside_const_context(expr.hir_id)
142+
if cx.tcx.hir_is_inside_const_context(expr.hir_id)
143143
|| self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id)
144144
{
145145
return;

clippy_lints/src/ptr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
186186
}
187187

188188
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
189-
let hir = cx.tcx.hir();
190-
let mut parents = hir.parent_iter(body.value.hir_id);
189+
let mut parents = cx.tcx.hir_parent_iter(body.value.hir_id);
191190
let (item_id, sig, is_trait_item) = match parents.next() {
192191
Some((_, Node::Item(i))) => {
193192
if let ItemKind::Fn { sig, .. } = &i.kind {

0 commit comments

Comments
 (0)