Skip to content

Commit 8cf9eea

Browse files
committed
Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
1 parent fc532c5 commit 8cf9eea

File tree

102 files changed

+146
-150
lines changed

Some content is hidden

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

102 files changed

+146
-150
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
338338
return;
339339
}
340340

341-
let items = module.item_ids.iter().map(|&id| cx.tcx.hir().item(id));
341+
let items = module.item_ids.iter().map(|&id| cx.tcx.hir_item(id));
342342

343343
// Iterates over the items within a module.
344344
//

clippy_lints/src/async_yields_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
6060
// XXXkhuey maybe we should?
6161
return;
6262
},
63-
CoroutineSource::Block => cx.tcx.hir().body(*body_id).value,
63+
CoroutineSource::Block => cx.tcx.hir_body(*body_id).value,
6464
CoroutineSource::Closure => {
6565
// Like `async fn`, async closures are wrapped in an additional block
6666
// to move all of the closure's arguments into the future.
6767

68-
let async_closure_body = cx.tcx.hir().body(*body_id).value;
68+
let async_closure_body = cx.tcx.hir_body(*body_id).value;
6969
let ExprKind::Block(block, _) = async_closure_body.kind else {
7070
return;
7171
};

clippy_lints/src/attrs/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ pub(super) fn is_lint_level(symbol: Symbol, attr_id: AttrId) -> bool {
2222

2323
pub(super) fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
2424
if let ItemKind::Fn { body: eid, .. } = item.kind {
25-
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
25+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
2626
} else {
2727
true
2828
}
2929
}
3030

3131
pub(super) fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
3232
match item.kind {
33-
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value),
33+
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value),
3434
_ => false,
3535
}
3636
}
@@ -39,7 +39,7 @@ pub(super) fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> b
3939
match item.kind {
4040
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
4141
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
42-
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
42+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir_body(eid).value)
4343
},
4444
_ => false,
4545
}

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: &Msrv, expr: &Expr<'_>) -> Opti
452452
})
453453
},
454454
ExprKind::Closure(closure) => {
455-
let body = cx.tcx.hir().body(closure.body);
455+
let body = cx.tcx.hir_body(closure.body);
456456
let params = body
457457
.params
458458
.iter()

clippy_lints/src/collection_is_never_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
118118
let is_read_in_closure_arg = args.iter().any(|arg| {
119119
if let ExprKind::Closure(closure) = arg.kind
120120
// To keep things simple, we only check the first param to see if its read.
121-
&& let Body { params: [param, ..], value } = cx.tcx.hir().body(closure.body)
121+
&& let Body { params: [param, ..], value } = cx.tcx.hir_body(closure.body)
122122
{
123123
!has_no_read_access(cx, param.hir_id, *value)
124124
} else {

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
197197
&& let impl_item_hir = child.id.hir_id()
198198
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
199199
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
200-
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
200+
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
201201
&& let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
202202
&& let attrs = cx.tcx.hir().attrs(item.hir_id())
203203
&& !attrs.iter().any(|attr| attr.doc_str().is_some())

clippy_lints/src/doc/missing_headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn check(
6868
} else if let Some(body_id) = body_id
6969
&& let Some(future) = cx.tcx.lang_items().future_trait()
7070
&& let typeck = cx.tcx.typeck_body(body_id)
71-
&& let body = cx.tcx.hir().body(body_id)
71+
&& let body = cx.tcx.hir_body(body_id)
7272
&& let ret_ty = typeck.expr_ty(body.value)
7373
&& implements_trait_with_env(
7474
cx.tcx,

clippy_lints/src/doc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
597597
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id())
598598
|| item.span.in_external_macro(cx.tcx.sess.source_map()))
599599
{
600-
let body = cx.tcx.hir().body(body_id);
600+
let body = cx.tcx.hir_body(body_id);
601601

602602
let panic_info = FindPanicUnwrap::find_span(cx, cx.tcx.typeck(item.owner_id), body.value);
603603
missing_headers::check(
@@ -649,7 +649,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
649649
&& !impl_item.span.in_external_macro(cx.tcx.sess.source_map())
650650
&& !is_trait_impl_item(cx, impl_item.hir_id())
651651
{
652-
let body = cx.tcx.hir().body(body_id);
652+
let body = cx.tcx.hir_body(body_id);
653653

654654
let panic_span = FindPanicUnwrap::find_span(cx, cx.tcx.typeck(impl_item.owner_id), body.value);
655655
missing_headers::check(

clippy_lints/src/empty_drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl LateLintPass<'_> for EmptyDrop {
4444
&& let impl_item_hir = child.id.hir_id()
4545
&& let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir)
4646
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
47-
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
47+
&& let Body { value: func_expr, .. } = cx.tcx.hir_body(*b)
4848
&& let func_expr = peel_blocks(func_expr)
4949
&& let ExprKind::Block(block, _) = func_expr.kind
5050
&& block.stmts.is_empty()

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx
9797
&& matches!(c.fn_decl.output, FnRetTy::DefaultReturn(_))
9898
&& !expr.span.from_expansion()
9999
{
100-
cx.tcx.hir().body(c.body)
100+
cx.tcx.hir_body(c.body)
101101
} else {
102102
return;
103103
};

clippy_lints/src/extra_unused_type_parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> {
247247
}
248248

249249
fn is_empty_body(cx: &LateContext<'_>, body: BodyId) -> bool {
250-
matches!(cx.tcx.hir().body(body).value.kind, ExprKind::Block(b, _) if b.stmts.is_empty() && b.expr.is_none())
250+
matches!(cx.tcx.hir_body(body).value.kind, ExprKind::Block(b, _) if b.stmts.is_empty() && b.expr.is_none())
251251
}
252252

253253
impl<'tcx> LateLintPass<'tcx> for ExtraUnusedTypeParameters {

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ fn lint_impl_body(cx: &LateContext<'_>, impl_span: Span, impl_items: &[hir::Impl
9898

9999
for impl_item in impl_items {
100100
if impl_item.ident.name == sym::from
101-
&& let ImplItemKind::Fn(_, body_id) = cx.tcx.hir().impl_item(impl_item.id).kind
101+
&& let ImplItemKind::Fn(_, body_id) = cx.tcx.hir_impl_item(impl_item.id).kind
102102
{
103103
// check the body for `begin_panic` or `unwrap`
104-
let body = cx.tcx.hir().body(body_id);
104+
let body = cx.tcx.hir_body(body_id);
105105
let mut fpu = FindPanicUnwrap {
106106
lcx: cx,
107107
typeck_results: cx.tcx.typeck(impl_item.id.owner_id.def_id),

clippy_lints/src/format_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn is_format_trait_impl(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) -> Optio
262262
&& let Some(name) = cx.tcx.get_diagnostic_name(did)
263263
&& matches!(name, sym::Debug | sym::Display)
264264
{
265-
let body = cx.tcx.hir().body(body_id);
265+
let body = cx.tcx.hir_body(body_id);
266266
let formatter_name = body
267267
.params
268268
.get(1)

clippy_lints/src/from_over_into.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ fn convert_to_from(
175175
// bad suggestion/fix.
176176
return None;
177177
}
178-
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
178+
let impl_item = cx.tcx.hir_impl_item(impl_item_ref.id);
179179
let ImplItemKind::Fn(ref sig, body_id) = impl_item.kind else {
180180
return None;
181181
};
182-
let body = cx.tcx.hir().body(body_id);
182+
let body = cx.tcx.hir_body(body_id);
183183
let [input] = body.params else { return None };
184184
let PatKind::Binding(.., self_ident, None) = input.pat.kind else {
185185
return None;

clippy_lints/src/functions/impl_trait_in_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
5656
&& let hir::ItemKind::Impl(impl_) = item.kind
5757
&& let hir::Impl { of_trait, .. } = *impl_
5858
&& of_trait.is_none()
59-
&& let body = cx.tcx.hir().body(body_id)
59+
&& let body = cx.tcx.hir_body(body_id)
6060
&& cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public()
6161
&& !is_in_test(cx.tcx, impl_item.hir_id())
6262
{

clippy_lints/src/functions/must_use.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>
3737
check_must_use_candidate(
3838
cx,
3939
sig.decl,
40-
cx.tcx.hir().body(*body_id),
40+
cx.tcx.hir_body(*body_id),
4141
item.span,
4242
item.owner_id,
4343
item.span.with_hi(sig.decl.output.span().hi()),
@@ -59,7 +59,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
5959
check_must_use_candidate(
6060
cx,
6161
sig.decl,
62-
cx.tcx.hir().body(*body_id),
62+
cx.tcx.hir_body(*body_id),
6363
item.span,
6464
item.owner_id,
6565
item.span.with_hi(sig.decl.output.span().hi()),
@@ -79,7 +79,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
7979
if let Some(attr) = attr {
8080
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr, attrs, sig);
8181
} else if let hir::TraitFn::Provided(eid) = *eid {
82-
let body = cx.tcx.hir().body(eid);
82+
let body = cx.tcx.hir_body(eid);
8383
if attr.is_none() && is_public && !is_proc_macro(attrs) {
8484
check_must_use_candidate(
8585
cx,

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check_fn<'tcx>(
3030

3131
pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
3232
if let hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(eid)) = item.kind {
33-
let body = cx.tcx.hir().body(eid);
33+
let body = cx.tcx.hir_body(eid);
3434
check_raw_ptr(cx, sig.header.safety(), sig.decl, body, item.owner_id.def_id);
3535
}
3636
}

clippy_lints/src/implicit_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
130130
});
131131

132132
let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);
133-
for item in impl_.items.iter().map(|item| cx.tcx.hir().impl_item(item.id)) {
133+
for item in impl_.items.iter().map(|item| cx.tcx.hir_impl_item(item.id)) {
134134
ctr_vis.visit_impl_item(item);
135135
}
136136

@@ -154,7 +154,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
154154
body: body_id,
155155
..
156156
} => {
157-
let body = cx.tcx.hir().body(body_id);
157+
let body = cx.tcx.hir_body(body_id);
158158

159159
for ty in sig.decl.inputs {
160160
let mut vis = ImplicitHasherTypeVisitor::new(cx);

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
159159
}
160160
if method.ident.name.as_str() == "flat_map" && args.len() == 1 {
161161
if let ExprKind::Closure(&Closure { body, .. }) = args[0].kind {
162-
let body = cx.tcx.hir().body(body);
162+
let body = cx.tcx.hir_body(body);
163163
return is_infinite(cx, body.value);
164164
}
165165
}

clippy_lints/src/items_after_statements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LateLintPass<'_> for ItemsAfterStatements {
5959
.iter()
6060
.skip_while(|stmt| matches!(stmt.kind, StmtKind::Item(..)))
6161
.filter_map(|stmt| match stmt.kind {
62-
StmtKind::Item(id) => Some(cx.tcx.hir().item(id)),
62+
StmtKind::Item(id) => Some(cx.tcx.hir_item(id)),
6363
_ => None,
6464
})
6565
// Ignore macros since they can only see previously defined locals.

clippy_lints/src/items_after_test_module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn cfg_test_module<'tcx>(cx: &LateContext<'tcx>, item: &Item<'tcx>) -> bool {
5858

5959
impl LateLintPass<'_> for ItemsAfterTestModule {
6060
fn check_mod(&mut self, cx: &LateContext<'_>, module: &Mod<'_>, _: HirId) {
61-
let mut items = module.item_ids.iter().map(|&id| cx.tcx.hir().item(id));
61+
let mut items = module.item_ids.iter().map(|&id| cx.tcx.hir_item(id));
6262

6363
let Some((mod_pos, test_mod)) = items.by_ref().enumerate().find(|(_, item)| cfg_test_module(cx, item)) else {
6464
return;
@@ -91,7 +91,7 @@ impl LateLintPass<'_> for ItemsAfterTestModule {
9191
"items after a test module",
9292
|diag| {
9393
if let Some(prev) = mod_pos.checked_sub(1)
94-
&& let prev = cx.tcx.hir().item(module.item_ids[prev])
94+
&& let prev = cx.tcx.hir_item(module.item_ids[prev])
9595
&& let items_span = last.span.with_lo(test_mod.span.hi())
9696
&& let Some(items) = items_span.get_source_text(cx)
9797
{

clippy_lints/src/iter_without_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter {
142142
})
143143
&& let Some(iter_assoc_span) = imp.items.iter().find_map(|item| {
144144
if item.ident.name.as_str() == "IntoIter" {
145-
Some(cx.tcx.hir().impl_item(item.id).expect_type().span)
145+
Some(cx.tcx.hir_impl_item(item.id).expect_type().span)
146146
} else {
147147
None
148148
}

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ enum LenOutput {
316316

317317
fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&'tcx PathSegment<'tcx>> {
318318
if let ty::Alias(_, alias_ty) = ty.kind()
319-
&& let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir().get_if_local(alias_ty.def_id)
319+
&& let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir_get_if_local(alias_ty.def_id)
320320
&& let OpaqueTyOrigin::AsyncFn { .. } = opaque.origin
321321
&& let [GenericBound::Trait(trait_ref)] = &opaque.bounds
322322
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn could_use_elision<'tcx>(
275275
}
276276

277277
if let Some(body_id) = body {
278-
let body = cx.tcx.hir().body(body_id);
278+
let body = cx.tcx.hir_body(body_id);
279279

280280
let first_ident = body.params.first().and_then(|param| param.pat.simple_ident());
281281
if non_elidable_self_type(cx, func, first_ident, msrv) {

clippy_lints/src/lines_filter_map_ok.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn should_lint(cx: &LateContext<'_>, args: &[Expr<'_>], method_str: &str) -> boo
101101
ExprKind::Closure(Closure { body, .. }) => {
102102
if let Body {
103103
params: [param], value, ..
104-
} = cx.tcx.hir().body(*body)
104+
} = cx.tcx.hir_body(*body)
105105
&& let ExprKind::MethodCall(method, receiver, [], _) = value.kind
106106
&& path_to_local_id(receiver, param.pat.hir_id)
107107
&& let Some(method_did) = cx.typeck_results().type_dependent_def_id(value.hir_id)

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'tcx> Visitor<'tcx> for VarVisitor<'_, 'tcx> {
370370
}
371371
},
372372
ExprKind::Closure(&Closure { body, .. }) => {
373-
let body = self.cx.tcx.hir().body(body);
373+
let body = self.cx.tcx.hir_body(body);
374374
self.visit_expr(body.value);
375375
},
376376
_ => walk_expr(self, expr),

clippy_lints/src/loops/while_let_on_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
351351
loop_id: loop_expr.hir_id,
352352
after_loop: false,
353353
};
354-
v.visit_expr(cx.tcx.hir().body(cx.enclosing_body.unwrap()).value)
354+
v.visit_expr(cx.tcx.hir_body(cx.enclosing_body.unwrap()).value)
355355
.is_break()
356356
}
357357
}

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
168168
&& let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)) =
169169
kind
170170
{
171-
return Some(cx.tcx.hir().body(body));
171+
return Some(cx.tcx.hir_body(body));
172172
}
173173

174174
None

clippy_lints/src/manual_option_as_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn check_arms(cx: &LateContext<'_>, none_arm: &Arm<'_>, some_arm: &Arm<'_>) -> b
191191
fn returns_empty_slice(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
192192
match expr.kind {
193193
ExprKind::Path(_) => clippy_utils::is_path_diagnostic_item(cx, expr, sym::default_fn),
194-
ExprKind::Closure(cl) => is_empty_slice(cx, cx.tcx.hir().body(cl.body).value),
194+
ExprKind::Closure(cl) => is_empty_slice(cx, cx.tcx.hir_body(cl.body).value),
195195
_ => false,
196196
}
197197
}

clippy_lints/src/manual_retain.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn check_into_iter(
9292
&& SpanlessEq::new(cx).eq_expr(left_expr, struct_expr)
9393
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = target_expr.kind
9494
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
95-
&& let filter_body = cx.tcx.hir().body(closure.body)
95+
&& let filter_body = cx.tcx.hir_body(closure.body)
9696
&& let [filter_params] = filter_body.params
9797
{
9898
if match_map_type(cx, left_expr) {
@@ -139,7 +139,7 @@ fn check_iter(
139139
&& SpanlessEq::new(cx).eq_expr(left_expr, struct_expr)
140140
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind
141141
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
142-
&& let filter_body = cx.tcx.hir().body(closure.body)
142+
&& let filter_body = cx.tcx.hir_body(closure.body)
143143
&& let [filter_params] = filter_body.params
144144
{
145145
match filter_params.pat.kind {
@@ -198,7 +198,7 @@ fn check_to_owned(
198198
&& SpanlessEq::new(cx).eq_expr(left_expr, str_expr)
199199
&& let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind
200200
&& let hir::ExprKind::Closure(closure) = closure_expr.kind
201-
&& let filter_body = cx.tcx.hir().body(closure.body)
201+
&& let filter_body = cx.tcx.hir_body(closure.body)
202202
&& let [filter_params] = filter_body.params
203203
{
204204
if let hir::PatKind::Ref(pat, _) = filter_params.pat.kind {

clippy_lints/src/map_unit_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn unit_closure<'tcx>(
163163
expr: &hir::Expr<'_>,
164164
) -> Option<(&'tcx hir::Param<'tcx>, &'tcx hir::Expr<'tcx>)> {
165165
if let hir::ExprKind::Closure(&hir::Closure { fn_decl, body, .. }) = expr.kind
166-
&& let body = cx.tcx.hir().body(body)
166+
&& let body = cx.tcx.hir_body(body)
167167
&& let body_expr = &body.value
168168
&& fn_decl.inputs.len() == 1
169169
&& is_unit_expression(cx, body_expr)

clippy_lints/src/methods/bind_instead_of_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl BindInsteadOfMap {
163163

164164
match arg.kind {
165165
hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) => {
166-
let closure_body = cx.tcx.hir().body(body);
166+
let closure_body = cx.tcx.hir_body(body);
167167
let closure_expr = peel_blocks(closure_body.value);
168168

169169
if self.lint_closure_autofixable(cx, expr, recv, closure_expr, fn_decl_span) {

clippy_lints/src/methods/bytecount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(
1818
filter_arg: &'tcx Expr<'_>,
1919
) {
2020
if let ExprKind::Closure(&Closure { body, .. }) = filter_arg.kind
21-
&& let body = cx.tcx.hir().body(body)
21+
&& let body = cx.tcx.hir_body(body)
2222
&& let [param] = body.params
2323
&& let PatKind::Binding(_, arg_id, _, _) = strip_pat_refs(param.pat).kind
2424
&& let ExprKind::Binary(ref op, l, r) = body.value.kind

0 commit comments

Comments
 (0)